aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms-ui-switch.js
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2019-01-09 01:16:16 +0100
committerKristian Lyngstol <kly@kly.no>2019-01-09 01:16:16 +0100
commit16fa2623327192ca44263ad77c19e45c03d5df11 (patch)
treefcaea77a92deb7efba5f042c8205d526a3e82d0c /web/js/nms-ui-switch.js
parent9a93c82da5d7de308e810d3f63c94e0b2569a4b6 (diff)
Expose new-style edit-stuff in old-style panel
The integration is a hack, but a first step. I will eventually remove all the code in nms-info-box, but I needed a simple test. This also demonstrates how to add a new switch.... simply hit edit, then change the name. It aint pretty, and shouldn't work like it does today, but it's a decent example. Also, had to fix the backend again now that I actually tested the write-api :D
Diffstat (limited to 'web/js/nms-ui-switch.js')
-rw-r--r--web/js/nms-ui-switch.js35
1 files changed, 29 insertions, 6 deletions
diff --git a/web/js/nms-ui-switch.js b/web/js/nms-ui-switch.js
index 3e6dd47..571f215 100644
--- a/web/js/nms-ui-switch.js
+++ b/web/js/nms-ui-switch.js
@@ -10,7 +10,7 @@
* it to avoid complicating things.
*
*/
-class nmsModSwitch extends nmsPanel {
+class nmsModSwitch extends nmsBox {
constructor(sw) {
var title;
if (sw == undefined) {
@@ -18,9 +18,9 @@ class nmsModSwitch extends nmsPanel {
} else {
title = "Edit " + sw;
}
- super(title)
+ super("div",{html:{className: "panel-body"}});
this._sw = sw;
- this.nav.add(new nmsString("Adding and editing stuff has immediate effects and blah blah blah, insert sensible help-text here."));
+ //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()
}
@@ -76,14 +76,18 @@ class nmsModSwitch extends nmsPanel {
var template = {}
for (var v in swi) {
console.assert(this._template[v] instanceof nmsType)
- this._template[v].value = swi[v];
+ if (swi[v] != null) {
+ this._template[v].value = swi[v];
+ }
}
for (var v in swm) {
if (v == "last_updated") {
continue;
}
console.assert(this._template[v] instanceof nmsType)
- this._template[v].value = swm[v];
+ if (swm[v] != null) {
+ this._template[v].value = swm[v];
+ }
}
}
populate() {
@@ -103,7 +107,26 @@ class nmsModSwitch extends nmsPanel {
this.title = "saw row change on " + row.name + " to " + row.value;
}
get value() {
- return this.table.value;
+ var ret = {};
+ for (var idx in this.rows) {
+ ret[idx] = this.rows[idx].value;
+ }
+ return ret;
+ }
+ diff() {
+ var ret = {};
+ var changed = 0;
+ for (var idx in this.rows) {
+ if (this.rows[idx].value != this.rows[idx].original) {
+ ret[idx] = this.rows[idx].value;
+ changed++;
+ }
+ }
+ if (!changed) {
+ return undefined;
+ }
+ ret["sysname"] = this.rows["sysname"].value;
+ return ret;
}
}