summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2015-11-12 17:02:18 -0500
committerArjun Roychowdhury <pliablepixels@gmail.com>2015-11-12 17:02:18 -0500
commit4e5e7d28a94106dab8ecf8ff08acfdf5589fe4c6 (patch)
treef84ddadb7267f430dd918f17e0dbb3b5d1b0f6a1 /www
parent63f4c7e94db1243084f3d7cef023c7a1124f03b5 (diff)
#82 - initial commits towards showing monitor specific alarm notitications in montage
Former-commit-id: 278d0c8fb24ef38e607caf66f1f6279b2e36f70b
Diffstat (limited to 'www')
-rw-r--r--www/css/style.css9
-rw-r--r--www/js/DataModel.js7
-rw-r--r--www/js/EventServer.js11
-rw-r--r--www/js/MontageCtrl.js27
-rw-r--r--www/templates/montage.html14
5 files changed, 59 insertions, 9 deletions
diff --git a/www/css/style.css b/www/css/style.css
index c9238ff5..00557085 100644
--- a/www/css/style.css
+++ b/www/css/style.css
@@ -77,6 +77,15 @@ Credit: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
opactity:80%;
}
+.alarmed-header {
+ background: #ba3e3e;
+ color:#ffffff;
+ border-color: #ba3e3e;
+ border-style: solid;
+ border-width:1px;
+ opactity:80%;
+}
+
.footer {
background: #666666;
border-color:#AAAAAA;
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
diff --git a/www/templates/montage.html b/www/templates/montage.html
index 99a5d4c8..6a583847 100644
--- a/www/templates/montage.html
+++ b/www/templates/montage.html
@@ -38,8 +38,18 @@
<span ng-repeat="monitor in MontageMonitors|limitTo: monLimit"
ng-if="monitor.Monitor.Function!='None' && monitor.Monitor.listDisplay!='noshow'">
<span ng-show="!minimal">
- <header class="header">&nbsp;<i class="ion-monitor"></i>
- {{monitor.Monitor.Name}}&nbsp;</header>
+ <div ng-if="monitor.Monitor.isAlarmed=='true'">
+ <header class="alarmed-header animated infinite flash">&nbsp;<i class="ion-monitor"></i>
+ {{monitor.Monitor.Name}}&nbsp;
+ </header>
+ </div>
+
+ <div ng-if="monitor.Monitor.isAlarmed!='true'">
+ <header class="header">&nbsp;<i class="ion-monitor"></i>
+ {{monitor.Monitor.Name}}&nbsp;
+ </header>
+ </div>
+
</span>
<article class="main">