From 167617437ebaaa54799e45165f1dbb83433d1bf6 Mon Sep 17 00:00:00 2001 From: "Ole Mathias Aa. Heggem" Date: Fri, 14 Sep 2018 18:16:47 +0000 Subject: Cleanup of latencychart --- web/js/nms-info-box.js | 51 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'web/js/nms-info-box.js') diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js index a7ddfc1..ba6446d 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', @@ -1169,6 +1169,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 * @@ -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() { -- cgit v1.2.3