From 2c0576644afc26f4153ad316d2af216919c04fe4 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 21 Mar 2016 18:50:25 +0100 Subject: NMS: Tweak searching of switch active ports etc --- web/nms.gathering.org/js/nms-info-box.js | 52 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'web/nms.gathering.org/js') diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 5f16ec2..545e62a 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -393,33 +393,37 @@ nmsInfoBox._makeCommentTable = function(content) { } nmsInfoBox._searchSmart = function(id, sw) { - if (nmsData.smanagement.switches[sw].distro == id) { - console.log("ieh"); - return true; - } - if (id.match("[a-z]+.active")) { - console.log("hei: " + sw); - var family = id.match("[a-z]+"); - var limit = id; - limit = limit.replace(family + ".active>",""); - limit = limit.replace(family + ".active<",""); - limit = limit.replace(family + ".active=",""); - var operator = id.replace(family + ".active","")[0]; - if (limit == parseInt(limit)) { - if (operator == ">" ) { - if (nmsData.switchstate.switches[sw][family].live > limit) { - return true; - } - } else if (operator == "<") { - if (nmsData.switchstate.switches[sw][family].live < limit) { - return true; - } - } else if (operator == "=") { - if (nmsData.switchstate.switches[sw][family].live == limit) { - return true; + try { + if (nmsData.smanagement.switches[sw].distro == id) { + return true; + } + if (id.match("active")) { + var limit = id; + limit = limit.replace("active>",""); + limit = limit.replace("active<",""); + limit = limit.replace("active=",""); + var operator = id.replace("active","")[0]; + if (limit == parseInt(limit)) { + if (operator == ">" ) { + if (nmsData.switchstate.switches[sw]['totals'].live > limit) { + return true; + } + } else if (operator == "<") { + if (nmsData.switchstate.switches[sw]['totals'].live < limit) { + return true; + } + } else if (operator == "=") { + if (nmsData.switchstate.switches[sw]['totals'].live == limit) { + return true; + } } } } + if (nmsData.snmp.snmp[sw].misc.sysDescr[0].match(id)) { + return true; + } + } catch (e) { + return false; } return false; } -- cgit v1.2.3 From d528cad67897dd2c3b98ec15a82868ac2764e2c7 Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Mon, 21 Mar 2016 20:26:58 +0100 Subject: NMS: Tweak search highlight and hotkeys --- web/nms.gathering.org/js/nms-info-box.js | 20 ++++++++++++++------ web/nms.gathering.org/js/nms-map.js | 26 ++++++++++++++++++-------- web/nms.gathering.org/js/nms.js | 8 ++++++++ 3 files changed, 40 insertions(+), 14 deletions(-) (limited to 'web/nms.gathering.org/js') diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index 5f16ec2..8527a03 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -436,6 +436,7 @@ nmsInfoBox._search = function() { id = el.value; } if(id) { + nmsMap.enableHighlights(); for(var sw in nmsData.switches.switches) { if (id[0] == "/") { if (nmsInfoBox._searchSmart(id.slice(1),sw)) { @@ -454,23 +455,30 @@ nmsInfoBox._search = function() { } } } else { - nmsMap.removeAllSwitchHighlights(); + nmsMap.disableHighlights(); } if(matches.length == 1) { document.getElementById("searchbox-submit").classList.add("btn-primary"); document.getElementById("searchbox").dataset.match = matches[0]; - document.getElementById("searchbox").addEventListener("keydown",nmsInfoBox._searchKeyListener,false); } else { document.getElementById("searchbox-submit").classList.remove("btn-primary"); document.getElementById("searchbox").dataset.match = ''; - document.getElementById("searchbox").removeEventListener("keydown",nmsInfoBox._searchKeyListener,false); } } nmsInfoBox._searchKeyListener = function(e) { - if(e.keyCode == 13) { - var sw = document.getElementById("searchbox").dataset.match; - nmsInfoBox.showWindow("switchInfo",sw); + switch (e.keyCode) { + case 13: + var sw = document.getElementById("searchbox").dataset.match; + if(sw != '') + nmsInfoBox.showWindow("switchInfo",sw); + break; + case 27: + document.getElementById("searchbox").dataset.match = ''; + document.getElementById("searchbox").value = ''; + nmsInfoBox._search(); + nmsInfoBox.hide(); + break; } } diff --git a/web/nms.gathering.org/js/nms-map.js b/web/nms.gathering.org/js/nms-map.js index b74626a..11ee142 100644 --- a/web/nms.gathering.org/js/nms-map.js +++ b/web/nms.gathering.org/js/nms-map.js @@ -10,7 +10,8 @@ * nmsMap.setSwitchColor(switch,color) * nmsMap.setSwitchInfo(switch,info) * nmsMap.setSwitchHighlight(switch,true/false) - * nmsMap.removeAllSwitchHighlights() + * nmsMap.enableHighlights() + * nmsMap.disableHighlights() */ @@ -47,6 +48,7 @@ var nmsMap = nmsMap || { _color: { }, _highlight: { }, + _highlightActive: false, _c: {} } @@ -76,15 +78,19 @@ nmsMap.setSwitchHighlight = function(sw, highlight) { if(highlight) highlight == true; if (this._highlight[sw] != highlight) { - this._highlight[sw] = highlight; - this._drawSwitch(sw); this.stats.highlightChange++; + this._highlight[sw] = highlight; } + this._drawSwitch(sw); } -nmsMap.removeAllSwitchHighlights = function() { - for(var sw in this._highlight) - this.setSwitchHighlight(sw,false); +nmsMap.enableHighlights = function() { + this._highlightActive = true; +} + +nmsMap.disableHighlights = function() { + this._highlightActive = false; + this._drawAllSwitches(); } nmsMap.reset = function() { @@ -247,8 +253,12 @@ nmsMap._drawSwitch = function(sw) return; var box = this._getBox(sw); var color = nmsMap._color[sw]; - if(nmsMap._highlight[sw]) { - color = red; + if(this._highlightActive) { + if(nmsMap._highlight[sw]) { + color = green; + } else { + color = white; + } } if (color == undefined) { color = blue; diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js index fd445d1..411fd1c 100644 --- a/web/nms.gathering.org/js/nms.js +++ b/web/nms.gathering.org/js/nms.js @@ -486,6 +486,7 @@ function initNMS() { detectHandler(); nms.playback.play(); setupKeyhandler(); + setupSearchKeyHandler(); } function detectHandler() { @@ -613,6 +614,13 @@ function setupKeyhandler() }); } +function setupSearchKeyHandler() +{ + $("#searchbox").keyup(function(e) { + nmsInfoBox._searchKeyListener(e); + }); +} + function getCookie(cname) { var name = cname + "="; -- cgit v1.2.3 From a90e2a42b2a082e4c92f991d16b552640ca8455a Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Tue, 22 Mar 2016 00:06:54 +0100 Subject: NMS: Sort switch edit fields alphabeticaly --- web/nms.gathering.org/js/nms-info-box.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'web/nms.gathering.org/js') diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index cbdf942..a484706 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -250,6 +250,8 @@ nmsInfoBox._windowTypes.switchInfo = { content.push([v, html]); } + content.sort(); + var table = nmsInfoBox._makeTable(content, "edit"); domObj.appendChild(table); -- cgit v1.2.3 From 13ae4dfb0952f604c527bdd3662be61a15b6fcb7 Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Tue, 22 Mar 2016 00:27:11 +0100 Subject: NMS: Show comments by default when click/searching --- web/nms.gathering.org/js/nms-info-box.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'web/nms.gathering.org/js') diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index a484706..7975bae 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -319,6 +319,7 @@ nmsInfoBox._windowTypes.switchInfo = { nmsInfoBox.click = function(sw) { this.showWindow("switchInfo",sw); + this._windowTypes.switchInfo.showComments(); } /* @@ -476,8 +477,10 @@ nmsInfoBox._searchKeyListener = function(e) { switch (e.keyCode) { case 13: var sw = document.getElementById("searchbox").dataset.match; - if(sw != '') + if(sw != '') { nmsInfoBox.showWindow("switchInfo",sw); + this._windowTypes.switchInfo.showComments(); + } break; case 27: document.getElementById("searchbox").dataset.match = ''; -- cgit v1.2.3