diff options
author | Kristian Lyngstol <kly@kly.no> | 2019-01-09 01:42:35 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2019-01-09 01:42:35 +0100 |
commit | 40ebbe2e0236b4cf3d5c91a7b21e286728800325 (patch) | |
tree | 4f09acbcb1df62b128861f37901e267d48e369f7 /web/js/nms-ui-switch.js | |
parent | 16fa2623327192ca44263ad77c19e45c03d5df11 (diff) |
Move switch-editing further away from nms-info-box
Still needs to be tidied up, but we're getting there.
Diffstat (limited to 'web/js/nms-ui-switch.js')
-rw-r--r-- | web/js/nms-ui-switch.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/web/js/nms-ui-switch.js b/web/js/nms-ui-switch.js index 571f215..326db1c 100644 --- a/web/js/nms-ui-switch.js +++ b/web/js/nms-ui-switch.js @@ -23,6 +23,44 @@ class nmsModSwitch extends nmsBox { //this.nav.add(new nmsString("Adding and editing stuff has immediate effects and blah blah blah, insert sensible help-text here.")); this.generateBaseTemplate() this.populate() + var save = new nmsButton("Save","btn-primary"); + save.panel = this; + save.html.onclick = this.save; + this.add(save) + var del = new nmsButton("Delete","btn btn-danger"); + del.panel = this + del.html.onclick = this.del; + this.add(del) + } + commit(data) { + $.ajax({ + type: "POST", + url: "/api/write/switches", + dataType: "text", + nmsBox:this, + data:JSON.stringify(data), + success: function (data, textStatus, jqXHR) { + var msg = new nmsString("Changed..."); + msg.attach(this.nmsBox._root); + msg.show() + this.nmsBox.destroy() + //nmsInfoBox.hide(); + nmsData.invalidate("switches"); + nmsData.invalidate("smanagement"); + } + }); + } + + del(e) { + if(confirm("This will delete the switch: " + this.nmsBox._sw)) { + this.nmsBox.panel.commit([{'sysname': this.nmsBox.panel.sw, 'deleted': true}]); + }; + } + save(e) { + var diff = this.nmsBox.panel.diff() + if (diff != undefined) { + this.nmsBox.panel.commit([diff]) + } } /* Pretty sure that the type-thing is OK, but what I want is to * generate a nmsTemplate or something that can be used to get/set |