diff options
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/DataModel.js | 7 | ||||
| -rw-r--r-- | www/js/EventServer.js | 11 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 27 |
3 files changed, 38 insertions, 7 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 12d172b7..b62af980 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -66,6 +66,7 @@ angular.module('zmApp.controllers') 'ZM_PATH_ZMS':'' }; + // credit: http://stackoverflow.com/questions/4994201/is-object-empty function isEmpty(obj) { // null and undefined are "empty" @@ -98,7 +99,8 @@ angular.module('zmApp.controllers') function setLogin(newLogin) { loginData = newLogin; - + + zmLog("Saving all parameters to storage"); zmDebug ("DataModel/setLogin: writing " + JSON.stringify(newLogin)); @@ -120,8 +122,6 @@ angular.module('zmApp.controllers') function displayBanner (mytype, mytext, myinterval, mytimer) { - console.log ("FACTORY DISPLAY: " + JSON.stringify(mytext)); - console.log ("FACTTORY DISPLAY: interval:" + myinterval + " timer:" + mytimer); var contentBannerInstance = $ionicContentBanner.show({ text: mytext || 'no text', @@ -886,6 +886,7 @@ angular.module('zmApp.controllers') for ( i = 0; i< monitors.length; i++) { monitors[i].Monitor.listDisplay='show'; + monitors[i].Monitor.isAlarmed = 'false'; // monitors[i].Monitor.sortOrder=i; } d.resolve(monitors); diff --git a/www/js/EventServer.js b/www/js/EventServer.js index 8b43fa1d..a9b44a8f 100644 --- a/www/js/EventServer.js +++ b/www/js/EventServer.js @@ -83,10 +83,6 @@ angular.module('zmApp.controllers') - - - - //-------------------------------------------------------------------------- // Called once at app start. Does a lazy definition of websockets open //-------------------------------------------------------------------------- @@ -171,6 +167,8 @@ angular.module('zmApp.controllers') if (str.status == 'Success' && str.event == 'alarm') // new events { + + new Audio('sounds/blop.mp3').play(); var localNotText = "Latest Alarms: "; $rootScope.isAlarm = 1; @@ -186,10 +184,12 @@ angular.module('zmApp.controllers') var eventsToDisplay = []; + var listOfMonitors=[]; for (var iter = 0; iter < str.events.length; iter++) { // lets stack the display so they don't overwrite eventsToDisplay.push(str.events[iter].Name + ": latest new alarm (" + str.events[iter].EventId + ")"); localNotText = localNotText + str.events[iter].Name + ","; + listOfMonitors.push(str.events[iter].MonitorId); } @@ -197,6 +197,9 @@ angular.module('zmApp.controllers') // if we are in background, do a local notification, else do an in app display if (!ZMDataModel.isBackground()) { + + //emit alarm details - this is when received over websockets + $rootScope.$emit('alarm',{message:listOfMonitors}); ZMDataModel.zmDebug("App is in foreground, displaying banner"); if (eventsToDisplay.length > 0) { diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 2e5feb8c..40b3a69c 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -199,6 +199,33 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', ' $scope.modal.remove(); }; + + + //---------------------------------------------------------------- + // Alarm emit handling + //---------------------------------------------------------------- + $rootScope.$on("alarm", function (event, args) { + console.log ("***EVENT TRAP***"); + var alarmMonitors = args.message; + for (var i=0; i< alarmMonitors.length; i++) + { + console.log ("**** TRAPPED EVENT: "+alarmMonitors[i]); + + for (var j=0; i<$scope.monitors.length; i++) + { + if ($scope.monitors[j].Monitor.Id == alarmMonitors[i]) + { + $scope.monitors[j].Monitor.isAlarmed="true"; + } + } + + } + + + + + + }); //---------------------------------------------------------------- // Alarm notification handling |
