diff options
| author | pliablepixels <pliablepixels@gmail.com> | 2016-05-10 15:37:56 -0400 |
|---|---|---|
| committer | pliablepixels <pliablepixels@gmail.com> | 2016-05-10 15:37:56 -0400 |
| commit | c7c3aa501954ba2731b55feee67564a4a8474160 (patch) | |
| tree | a28e31d3bf3c3839b7901a57404edc8a1622f962 /www/js/MonitorModalCtrl.js | |
| parent | 1ce2c52bd902bec7d97530b9dd84528b0a784575 (diff) | |
#245 - api integrated
Former-commit-id: e721d873a89be48a42840b82db3e22fa363415d3
Diffstat (limited to 'www/js/MonitorModalCtrl.js')
| -rw-r--r-- | www/js/MonitorModalCtrl.js | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js index c01ef369..9ae6f60a 100644 --- a/www/js/MonitorModalCtrl.js +++ b/www/js/MonitorModalCtrl.js @@ -12,7 +12,7 @@ d) gapless */ -angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup) { +angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups) { // from parent scope @@ -829,6 +829,72 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ } + $scope.enableAlarm = function(mid,mode) + { + + if (mode) // trigger alarm + { + $rootScope.zmPopup = SecuredPopups.show('show',{ + title: 'Confirm', + template: "Are you sure you want to force an alarm for Monitor:"+$scope.monitorName+"?", + buttons: [ + { + text: 'Yes', + onTap: function(e) + { + enableAlarm(mid, mode); + } + }, + { + text: 'No', + onTap: function (e) + { + return; + } + } + ] + + }); + } + else + enableAlarm(mid,mode); + + function enableAlarm(mid,mode) + { + var apiurl = ZMDataModel.getLogin().apiurl; + var c = mode? "on":"off"; + var alarmurl = apiurl+"/monitors/alarm/id:"+mid+"/command:"+c+".json"; + ZMDataModel.zmLog ("Invoking " + alarmurl); + + var status = mode? "forcing alarm": "cancelling alarm"; + $ionicLoading.show({ + template: status, + noBackdrop: true, + duration: zm.largeHttpTimeout, + }); + + $http.get(alarmurl) + .then (function (data) { + $ionicLoading.show({ + template: "success", + noBackdrop: true, + duration: 2000, + }); + }, + function (error) { + + $ionicLoading.show({ + template: "error - please make sure your API supports this feature", + noBackdrop: true, + duration: 3000, + }); + ZMDataModel.zmDebug ("Error in enableAlarm " + JSON.stringify(error)); + }); + } + + + + }; //----------------------------------------------------------------------- |
