diff options
| author | ARC <arjunrc@gmail.com> | 2015-04-25 09:13:54 -0400 |
|---|---|---|
| committer | ARC <arjunrc@gmail.com> | 2015-04-25 09:13:54 -0400 |
| commit | 86e4e291bfda3365c0bb82bacb2b9990a86ce759 (patch) | |
| tree | c9729d4bd5366656e39761319546593c02f0f709 /www/js/EventsGraphsCtrl.js | |
First Commit
Diffstat (limited to 'www/js/EventsGraphsCtrl.js')
| -rw-r--r-- | www/js/EventsGraphsCtrl.js | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js new file mode 100644 index 00000000..2bd04e12 --- /dev/null +++ b/www/js/EventsGraphsCtrl.js @@ -0,0 +1,157 @@ +angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', function ($ionicPlatform, $scope, ZMDataModel, $ionicSideMenuDelegate, $rootScope, $http) { + console.log("Inside Graphs controller"); + $scope.openMenu = function () { + $ionicSideMenuDelegate.toggleLeft(); + } + + $scope.navTitle = 'Tab Page'; + $scope.leftButtons = [{ + type: 'button-icon icon ion-navicon', + tap: function (e) { + $scope.toggleMenu(); + } + }]; + + $scope.anotherChart = function() + { + //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.data = [ + ['Monitor', 'Events', { + role: 'style' + }, { + role: 'annotation' + }], + ['', 0, '', ''] // needed to get rid of the initial error of charts + ]; + + + $scope.chartObject.type = "BarChart"; + $scope.chartObject.options = { + title: 'Events per monitor', + 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.chartObject.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.chartObject.data.push([monitors[j].Monitor.Name, + 0, 'opacity: 0.4', 0]); + + }); + + })(i); // j + + } //for + + }); + +});
\ No newline at end of file |
