From 21a84c029b7d58413e8de6516fe2ec1e3d20bbc8 Mon Sep 17 00:00:00 2001 From: "michael.mead" Date: Thu, 1 Feb 2018 13:30:56 -0600 Subject: [PATCH] some fix --- src/api/static/js/dashboard.js | 49 ++++++++++++++++++-------------- src/api/templates/dashboard.html | 4 +-- src/utils/agents/manager.py | 2 ++ 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/api/static/js/dashboard.js b/src/api/static/js/dashboard.js index d2b7f5d..092f2fe 100755 --- a/src/api/static/js/dashboard.js +++ b/src/api/static/js/dashboard.js @@ -18,18 +18,25 @@ dashboard = { initChartist: function(){ var getData = $.get('/1/app/usage/trend'); getData.done(function(results) { - var data = JSON.parse(results) - console.log('data...',data) - + var data = JSON.parse(results); + console.log('data...',data); + if ($.isEmptyObject(data)){ + console.log('data is empty, setting testing values.'); + data = [[1,2,3,4,5], [2,5,7,9], [1,3,4,6,8,9]] + } + console.log('data', data); // monitoring apps chart var dataChart = { labels: ['24','23','22','21','20','19','18','17','16','15','14','13','12','11','10','9','8','7','6','5','4','3','2','1' ], - series: [[1,2,3], [4,5,6], [1,2,3,5], ] // TODO: Check the order, the graph is by index not name. + series: data //[[1,2,3], [4,5,6], [1,2,3,5] ] // TODO: Check the order, the graph is by index not name. }; - dataChartArray = dataChart.series - var maxlist = dataChartArray.map(dataChartArray => Math.max.apply(null, dataChartArray)); - maxNum = Math.max.apply(null, maxlist) + dataChartArray = dataChart.series; + var maxlist = dataChartArray.map(function (dataChartArray) { + return Math.max.apply(null, dataChartArray); + }); + + maxNum = Math.max.apply(null, maxlist); var optionsChart = { lineSmooth: false, @@ -38,13 +45,13 @@ dashboard = { showArea: true, height: "245px", axisX: { - showGrid: false, + showGrid: false }, lineSmooth: Chartist.Interpolation.simple({ divisor: 1 }), showLine: true, - showPoint: false, + showPoint: false }; var responsiveChart = [ @@ -111,7 +118,7 @@ dashboard = { scrollwheel: false, //we disable de scroll over the map, it is a really annoing when you scroll through page styles: [{"featureType":"water","stylers":[{"saturation":43},{"lightness":-11},{"hue":"#0088ff"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"hue":"#ff0000"},{"saturation":-100},{"lightness":99}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#808080"},{"lightness":54}]},{"featureType":"landscape.man_made","elementType":"geometry.fill","stylers":[{"color":"#ece2d9"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#ccdca1"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#767676"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#ffffff"}]},{"featureType":"poi","stylers":[{"visibility":"off"}]},{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#b8cb93"}]},{"featureType":"poi.park","stylers":[{"visibility":"on"}]},{"featureType":"poi.sports_complex","stylers":[{"visibility":"on"}]},{"featureType":"poi.medical","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","stylers":[{"visibility":"simplified"}]}] - } + }; var map = new google.maps.Map(document.getElementById("map"), mapOptions); var marker = new google.maps.Marker({ @@ -138,9 +145,9 @@ dashboard = { align: align } }); - }, + } -} +}; /** @@ -154,29 +161,29 @@ g.summary = {} * Initializing the top section of the dashboard (apps and folders) */ g.summary.factory = function (url,pointer) { - var object = {} - object.url = url - var observer = null + var object = {}; + object.url = url; + var observer = null; var TIME_ELLAPSED = 2000 ; object.callback = function (r) { - r = JSON.parse(r.responseText) + r = JSON.parse(r.responseText); pointer(r) //observer.notify() - } + }; object.init = function (observer) { observer = observer - var httpclient = HttpClient.instance() + var httpclient = HttpClient.instance(); //httpclient.setAsync(false) - httpclient.get(this.url, this.callback) + httpclient.get(this.url, this.callback); setTimeout(function(){ observer.notify() },TIME_ELLAPSED) ; //observer.notify() - } + }; return object -} +}; diff --git a/src/api/templates/dashboard.html b/src/api/templates/dashboard.html index 27d8ad1..92d4b85 100644 --- a/src/api/templates/dashboard.html +++ b/src/api/templates/dashboard.html @@ -50,7 +50,7 @@ {# #} {# #}