diff options
| -rw-r--r-- | www/js/EventsGraphsCtrl.js | 86 | ||||
| -rw-r--r-- | www/templates/events-graphs.html | 6 |
2 files changed, 13 insertions, 79 deletions
diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js index 2bd04e12..9dbf3efb 100644 --- a/www/js/EventsGraphsCtrl.js +++ b/www/js/EventsGraphsCtrl.js @@ -12,82 +12,10 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio } }]; - $scope.anotherChart = function() + $scope.generateChart = function(chartTitle) { //alert ("Well I got called!"); - $scope.chart2Object = {}; //test - $scope.chart2Object.data = [ - ['Monitor', 'Events', { - role: 'style' - }, { - role: 'annotation' - }], - ['', 0, '', ''] // needed to get rid of the initial error of charts - ]; - - - $scope.chart2Object.type = "BarChart"; - $scope.chart2Object.options = { - title: 'Events per monitor PER HOUR', - height: $rootScope.devHeight, - animation: { - duration: 700, - easing: 'out', - startup: 'false', - }, - - - } - - var monitors = []; - console.log("*** Grabbing lists of events and monitors "); - ZMDataModel.getMonitors(0).then(function (data) { - - monitors = data; - var loginData = ZMDataModel.getLogin(); - //var events = ZMDataModel.getAllPreexistingEvents(); - // lets get the event count for all - for (var i = 0; i < monitors.length; i++) { - (function (j) { - //monevents[monitors[j].Monitor.Id].monName = monitors[j].Monitor.Name; - - var url = loginData.apiurl + - "/events/index/MonitorId:" + monitors[j].Monitor.Id + - ".json?page=1"; - console.log("Monitor event URL:" + url); - $http.get(url) - .success(function (data) { - console.log("**** EVENT COUNT FOR MONITOR " + - monitors[j].Monitor.Id + " IS " + data.pagination.count); - - console.log("Pushing " + monitors[j].Monitor.Name + - " AND " + data.pagination.count); - - $scope.chart2Object.data.push - ([monitors[j].Monitor.Name, data.pagination.count, - 'opacity: 0.4', data.pagination.count]); - - }) - .error(function (data) { - console.log("**** EVENT COUNT FOR MONITOR " + - monitors[i].Monitor.Id + " IS ERROR "); - $scope.chart2Object.data.push([monitors[j].Monitor.Name, - 0, 'opacity: 0.4', 0]); - - }); - - })(i); // j - - } //for - - }); - - }; // scope function - - - - - $scope.chartObject = {}; //test + $scope.chartObject = {}; //test $scope.chartObject.data = [ ['Monitor', 'Events', { role: 'style' @@ -100,7 +28,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio $scope.chartObject.type = "BarChart"; $scope.chartObject.options = { - title: 'Events per monitor', + title: chartTitle, height: $rootScope.devHeight, animation: { duration: 700, @@ -154,4 +82,10 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio }); -});
\ No newline at end of file + }; // scope function + + + + + +}); diff --git a/www/templates/events-graphs.html b/www/templates/events-graphs.html index 96144d4b..97533ab1 100644 --- a/www/templates/events-graphs.html +++ b/www/templates/events-graphs.html @@ -4,7 +4,7 @@ <button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button> </ion-nav-buttons> <ion-tabs class="tabs-icon-top tabs-stable"> - <ion-tab title="Events" icon="ion-stats-bars"> + <ion-tab title="Events" icon="ion-stats-bars" on-select="generateChart('All Events')"> <ion-nav-view> <ion-content class="has-header"> @@ -15,12 +15,12 @@ </ion-nav-view> </ion-tab> - <ion-tab title="About" icon="ion-gear-a" on-select="anotherChart()"> + <ion-tab title="About" icon="ion-gear-a" on-select="generateChart('Events in the last hour')"> <ion-nav-view> <ion-content> <span></span> - <div google-chart chart="chart2Object"></div> + <div google-chart chart="chartObject"></div> This is 2-2 </ion-content> |
