diff options
Diffstat (limited to 'web/js')
| -rw-r--r-- | web/js/nms-draw-chart.js | 8 | ||||
| -rw-r--r-- | web/js/nms-info-box.js | 51 | 
2 files changed, 42 insertions, 17 deletions
| diff --git a/web/js/nms-draw-chart.js b/web/js/nms-draw-chart.js index 60698c0..491b216 100644 --- a/web/js/nms-draw-chart.js +++ b/web/js/nms-draw-chart.js @@ -12,7 +12,7 @@ function setNightModeChart(night) {  }  function drawLatency(canvas, sw, chart, callback) { -        var q = encodeURIComponent('SELECT mean("latency") AS "mean_latency" FROM "ping" WHERE time > now() - 30m AND "switch"=\''+sw+'\' GROUP BY time(60s), "version" fill(null)'); +        var q = encodeURIComponent('SELECT mean("latency") AS "mean_latency" FROM "ping" WHERE time > now() - 3h AND "switch"=\''+sw+'\' GROUP BY time(60s), "version" fill(null)');          var dataset = [];          $.getJSON( "/query?db=gondul&q="+q, function( results ) { @@ -47,7 +47,7 @@ function drawLatency(canvas, sw, chart, callback) {  						xAxes:[{  							type: 'time',  							time: { -								format: "HH:mm", +								parser: "HH:mm",  								unit: 'minute',  								tooltipFormat: 'HH:mm',  								displayFormats: { @@ -176,7 +176,7 @@ function drawSumOfPorts(canvas, sw) {                                          xAxes:[{                                                  type: 'time',                                                  time: { -                                                        format: "HH:mm", +                                                        parser: "HH:mm",                                                          unit: 'minute',                                                          tooltipFormat: 'HH:mm',                                                          displayFormats: { @@ -300,7 +300,7 @@ function drawPort(canvas, sw, port) {                                          xAxes:[{                                                  type: 'time',                                                  time: { -                                                        format: "HH:mm", +                                                        parser: "HH:mm",                                                          unit: 'minute',                                                          tooltipFormat: 'HH:mm',                                                          displayFormats: { 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', @@ -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() { | 
