aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms-info-box.js
diff options
context:
space:
mode:
authorKristian Lyngstøl <kly@kly.no>2019-01-03 17:58:09 +0100
committerGitHub <noreply@github.com>2019-01-03 17:58:09 +0100
commit65f156aa871f3e51f45e490e1a0ea797f5eff003 (patch)
tree6715e71eff1421101da6405ab13f159c0ec401da /web/js/nms-info-box.js
parent90d918d3859482c19a8e37d6c6eb261d6c195fea (diff)
parentb7f0ccac45c824461a7bc959cedaeb11ee582c48 (diff)
Merge pull request #172 from olemathias/master
Cleanup of latencychart
Diffstat (limited to 'web/js/nms-info-box.js')
-rw-r--r--web/js/nms-info-box.js51
1 files changed, 38 insertions, 13 deletions
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js
index 1eea112..c42c7ae 100644
--- a/web/js/nms-info-box.js
+++ b/web/js/nms-info-box.js
@@ -40,7 +40,7 @@ var nmsInfoBox = nmsInfoBox || {
'views': {
'initial': {
'name': 'Summary',
- 'panels': ['switchSummary','switchComments']
+ 'panels': ['switchLatency','switchSummary','switchComments']
},
'ports': {
'name': 'Ports',
@@ -1170,6 +1170,42 @@ var switchCommentsPanel = function () {
nmsInfoBox.addPanelType("switchComments",switchCommentsPanel);
/*
+ * Panel type: Switch latency
+ *
+ * Display a live line chart with latency
+ *
+ */
+var switchLatencyPanel = function() {
+ nmsInfoPanel.call(this,"switchLatency");
+ var latencyChart;
+ this.init = function() {
+ this.addHandler("ticker");
+ this.refresh();
+ };
+ this.refresh = function(reason) {
+ if (this.sw == false) {
+ console.log("ugh, cleanup failed?");
+ return;
+ }
+
+ if(reason == 'handler-ticker' && latencyChart != undefined) {
+ drawLatency(this.sw+'latency_chart',this.sw, latencyChart);
+ return;
+ }
+
+ var topper = document.createElement("div");
+ var latency = document.createElement("canvas");
+ latency.id = this.sw+'latency_chart';
+ latency.width = 500;
+ latency.height = 250;
+ drawLatency(this.sw+'latency_chart',this.sw, false, function(chart) { latencyChart = chart; });
+ topper.appendChild(latency);
+ this._render(topper);
+ };
+};
+nmsInfoBox.addPanelType("switchLatency",switchLatencyPanel);
+
+/*
* Panel type: Switch summary
*
* Display a live summary of key metrics
@@ -1188,12 +1224,6 @@ var switchSummaryPanel = function() {
console.log("ugh, cleanup failed?");
return;
}
-
- if(reason == 'handler-ticker' && latencyChart != undefined) {
- drawLatency(this.sw+'latency_chart',this.sw, latencyChart);
- //TODO Fix so it will update table to
- return;
- }
var topper = document.createElement("div");
for ( var h in handlers ) {
if (handlers[h].getInfo != undefined) {
@@ -1214,12 +1244,6 @@ var switchSummaryPanel = function() {
contentCleaned.push(content[i]);
}
var table = nmsInfoBox._makeTable(contentCleaned);
- var latency = document.createElement("canvas");
- latency.id = this.sw+'latency_chart';
- latency.width = 500;
- latency.height = 250;
- drawLatency(this.sw+'latency_chart',this.sw, false, function(chart) { latencyChart = chart; });
- topper.appendChild(latency);
topper.appendChild(table);
this._render(topper);
@@ -1234,6 +1258,7 @@ nmsInfoBox.setLegendPick = function(tag,id) {
}
nms.legendPick = {handler: tag, idx: id};
}
+
nmsInfoBox.addPanelType("switchSummary",switchSummaryPanel);
var switchLinks = function() {