aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2019-01-11 22:18:33 +0100
committerKristian Lyngstol <kly@kly.no>2019-01-11 22:18:33 +0100
commite5db805157b2c7118ddfd3916e0427b2156e6e49 (patch)
treebdf57012c0e8224cdeb2467969e89b6fc348158e
parenta4919da3a91236131f7b4e084761ff6a5f73b94f (diff)
Move the info summary in the info-box into nmsBox-logic
Also some other random drive-by fixes :D Fixes #180 References #181
-rw-r--r--web/css/nms.css10
-rw-r--r--web/index.html1
-rw-r--r--web/js/nms-info-box.js31
-rw-r--r--web/js/nms-map-handlers.js6
-rw-r--r--web/js/nms-oplog.js4
-rw-r--r--web/js/nms-ui-boxes.js4
-rw-r--r--web/js/nms-ui-switch.js2
7 files changed, 21 insertions, 37 deletions
diff --git a/web/css/nms.css b/web/css/nms.css
index 90fa362..32f302c 100644
--- a/web/css/nms.css
+++ b/web/css/nms.css
@@ -66,6 +66,9 @@ h1.map-mode-title {
.logbook-mini p {
margin: 0
}
+.table p {
+ margin: 0
+}
.nightmode .logbook-mini {
background-color: rgba(0,0,0,0.1);
text-shadow: -4px -4px 5px black,-4px 0px 5px black,0px -4px 5px black,0px 0px 5px black,4px 4px 5px black,4px 0px 5px black,0px 4px 5px black;
@@ -137,3 +140,10 @@ div.map-mode-legend button {
z-index: 120;
}
+button,input {
+ margin-left: 1px;
+ margin-left: 2px;
+}
+.form-control[disabled] {
+ background-color: darkkhaki;
+}
diff --git a/web/index.html b/web/index.html
index cdd2840..05fd582 100644
--- a/web/index.html
+++ b/web/index.html
@@ -326,6 +326,7 @@
<script type="text/javascript" src="js/nms-draw-chart.js"></script>
<script type="text/javascript" src="js/nms-types.js"></script>
<script type="text/javascript" src="js/nms-ui-switch.js"></script>
+ <script type="text/javascript" src="js/nms-ui-switch-summary.js"></script>
<script src="js/jquery.datetimepicker.full.js" type="text/javascript"></script>
<script type="text/javascript">
initNMS();
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js
index efb2d7b..6915b03 100644
--- a/web/js/nms-info-box.js
+++ b/web/js/nms-info-box.js
@@ -937,34 +937,13 @@ var switchSummaryPanel = function() {
this.refresh();
};
this.refresh = function(reason) {
- var content = [];
- if (this.sw == false) {
- console.log("ugh, cleanup failed?");
+ if (this.box) {
+ this.box.refresh();
return;
}
- var topper = document.createElement("div");
- for ( var h in handlers ) {
- if (handlers[h].getInfo != undefined) {
- var tmp = handlers[h].getInfo(this.sw);
- for (var x in tmp.data) {
- if (tmp.data[x].value != undefined) {
- var d = "<div class=\"clickable\" onclick='nmsInfoBox.setLegendPick(\""+ handlers[h].tag + "\", " + x + ");'>" + tmp.data[x].value + '</div>';
- content.push([tmp.data[x].description, d]);
- }
- }
- }
- }
-
- var contentCleaned = [];
- for(var i in content) {
- if(content[i][1] == '' || content[i][1] == null)
- continue;
- contentCleaned.push(content[i]);
- }
- var table = nmsInfoBox._makeTable(contentCleaned);
- topper.appendChild(table);
-
- this._render(topper);
+ this.box = new nmsSwitchSummary(this.sw);
+ this.box.attach(this.me)
+ this.box.show()
};
};
nmsInfoBox.setLegendPick = function(tag,id) {
diff --git a/web/js/nms-map-handlers.js b/web/js/nms-map-handlers.js
index 90f6922..d553fc0 100644
--- a/web/js/nms-map-handlers.js
+++ b/web/js/nms-map-handlers.js
@@ -387,11 +387,11 @@ function tempInfo(sw)
var ret = new handlerInfo("temp","Temperature");
ret.why = "Temp";
ret.score = 0;
- ret.data[0].value = "N/A";
+ ret.data[0].value = undefined;
if (testTree(nmsData,['switchstate','switches',sw,'temp'])) {
var temp = nmsData.switchstate.switches[sw].temp;
if (temp == undefined) {
- ret.data[0].value = "N/A";
+ ret.data[0].value = undefined;
} else {
temp = parseInt(temp);
ret.data[0].value = temp + "°C";
@@ -475,7 +475,7 @@ function pingInfo(sw)
ret.score = 900;
}
} else {
- ret.data[0].value = "N/A - no ping replies";
+ ret.data[0].value = "No ping replies";
ret.why = "No ping replies";
ret.score = 999;
}
diff --git a/web/js/nms-oplog.js b/web/js/nms-oplog.js
index 42452ff..33b2c00 100644
--- a/web/js/nms-oplog.js
+++ b/web/js/nms-oplog.js
@@ -65,12 +65,8 @@ class nmsOplogInput extends nmsBox {
this.nmsBox.searchbox.oninput();
}
this.add(this._systems)
- // This is to provide spacing.... should probably be solved in CSS.
- // If this annoys you, then fix it.
- this.add(new nmsBox("p",{html:{textContent:" ",style:{display: "inline"}}}))
this._entry = new nmsBox("input", {html:{className:"form-control",type:"text",size:"30",placeholder:"Log entry"}});
this.add(this._entry)
- this.add(new nmsBox("p",{html:{textContent:" ",style:{display: "inline"}}}))
var button = new nmsBox("button",{html:{className:"btn btn-default",type:"button"}});
button.html.textContent = "Log";
button.container = this;
diff --git a/web/js/nms-ui-boxes.js b/web/js/nms-ui-boxes.js
index dda77c9..3de8ff2 100644
--- a/web/js/nms-ui-boxes.js
+++ b/web/js/nms-ui-boxes.js
@@ -214,13 +214,9 @@ class nmsTable extends nmsBox {
var td1;
var td2;
tr = new nmsBox("tr");
- tr.html.className = content[0].toLowerCase().replace(/[^a-z0-9_]/g,"");
for (var x in content) {
var td = new nmsBox("td");
var child = content[x];
- if (x == 0) {
- td.html.classList.add("left");
- }
if (child instanceof nmsBox) {
td.add(child);
} else {
diff --git a/web/js/nms-ui-switch.js b/web/js/nms-ui-switch.js
index 0a9c52f..7887656 100644
--- a/web/js/nms-ui-switch.js
+++ b/web/js/nms-ui-switch.js
@@ -196,12 +196,14 @@ class nmsEditRow extends nmsBox {
input.row = this;
if (value.ro) {
input.html.disabled = true;
+ input.html.title = "Read/only attribute";
}
if (value instanceof nmsTypeSecret) {
input.html.type = "password"
input.html.autocomplete = "off"
input.html.onfocus = function f() { this.type = "text" }
input.html.oninput = function f() { this.type = "text" }
+ input.html.onblur = function f() { this.type = "password" }
}
input.html.onchange = function() {
this.nmsBox.row.value = this.value