summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/DataModel.js21
-rw-r--r--www/js/EventCtrl.js10
-rw-r--r--www/js/EventServer.js26
-rw-r--r--www/js/app.js13
4 files changed, 47 insertions, 23 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 3f47b408..440857be 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -115,6 +115,9 @@ angular.module('zmApp.controllers')
// the ZM portal authentication, which is pretty messy. But unless
// the ZM authors fix this and streamline the access of images
// from APIs, I don't have an option
+
+ // FIXME: Move all of this into a neat JSON object
+
init: function () {
console.log("****** DATAMODEL INIT SERVICE CALLED ********");
@@ -156,10 +159,6 @@ angular.module('zmApp.controllers')
}
-
-
-
-
if (window.localStorage.getItem("username") != undefined) {
loginData.username =
window.localStorage.getItem("username");
@@ -353,6 +352,10 @@ angular.module('zmApp.controllers')
},
+ //--------------------------------------------------------------------------
+ // writes all params to local storage. FIXME: Move all of this into a JSON
+ // object
+ //--------------------------------------------------------------------------
setLogin: function (newLogin) {
loginData = newLogin;
zmLog("Saving all parameters to storage");
@@ -554,6 +557,10 @@ angular.module('zmApp.controllers')
},
+ //--------------------------------------------------------------------------
+ // Useful to know what ZMS is using as its cgi-bin. If people misconfigure
+ // the setting in the app, they can check their logs
+ //--------------------------------------------------------------------------
getPathZms: function()
{
var d = $q.defer();
@@ -576,6 +583,12 @@ angular.module('zmApp.controllers')
},
+ //--------------------------------------------------------------------------
+ // This is really a hack for now & is very ugly. I need to clean this up a lot
+ // it re-arranges monitors based on montage and hidden order so that
+ // I can reuse this from events and timeline view if persist monitor states
+ // is on
+ //--------------------------------------------------------------------------
applyMontageMonitorPrefs: function (mon, doOrder)
{
var montageOrder = []; // This array will keep the ordering in montage view
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js
index caa25672..09d75c92 100644
--- a/www/js/EventCtrl.js
+++ b/www/js/EventCtrl.js
@@ -15,12 +15,7 @@ angular.module('zmApp.controllers')
//---------------------------------------------------
// Controller main
//---------------------------------------------------
-
- // console.log ("******** NEW SOCKET IN EVENT");
-
-
-
- //EventServer.start();
+
var loginData = ZMDataModel.getLogin();
@@ -1168,8 +1163,7 @@ angular.module('zmApp.controllers')
var i;
for (i = 0; i < data.event.Frame.length; i++) {
if (data.event.Frame[i].Type == "Alarm") {
- //⬤
- // console.log ("**ALARM AT " + i);
+
$scope.slider_modal_options.scale.push({
val: i + 1,
label: ' '
diff --git a/www/js/EventServer.js b/www/js/EventServer.js
index 1c7f7c01..4e5f29ef 100644
--- a/www/js/EventServer.js
+++ b/www/js/EventServer.js
@@ -4,7 +4,10 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */
-// Websockets
+ //--------------------------------------------------------------------------
+ // This factory interacts with the ZM Event Server
+ // over websockets and is responsible for rendering real time notifications
+ //--------------------------------------------------------------------------
angular.module('zmApp.controllers')
@@ -14,8 +17,12 @@ angular.module('zmApp.controllers')
var ws;
+ // Display a max of 5 local notifications
var localNotificationId=5;
+ //--------------------------------------------------------------------------
+ // Called once at app start. Does a lazy definition of websockets open
+ //--------------------------------------------------------------------------
function init()
{
$rootScope.isAlarm = 0;
@@ -40,7 +47,7 @@ angular.module('zmApp.controllers')
});
-
+ // Transmit auth information to server
ws.$on ('$open', function() {
ZMDataModel.zmLog("Websocket open");
ws.$emit('auth',
@@ -54,6 +61,7 @@ angular.module('zmApp.controllers')
});
+ // Handles responses back from ZM ES
ws.$on ('$message', function(str) {
ZMDataModel.zmLog("Real-time event: " + JSON.stringify(str));
if (str.status != 'Success')
@@ -70,14 +78,15 @@ angular.module('zmApp.controllers')
var eventsToDisplay=[];
for (var iter=0; iter<str.events.length; iter++)
{
+ // lets stack the display so they don't overwrite
eventsToDisplay.push(str.events[iter].Name+": new event ("+str.events[iter].EventId+")");
localNotText = localNotText + str.events[iter].Name+",";
}
localNotText = localNotText.substring(0, localNotText.length - 1);
- // lets stack the display so they don't overwrite
-
+
+ // if we are in background, do a local notification, else do an in app display
if (!ZMDataModel.isBackground())
{
ZMDataModel.zmDebug("App is in foreground, displaying banner");
@@ -98,7 +107,8 @@ angular.module('zmApp.controllers')
localNotificationId = 5;
}
-
+ // This is how I am reusing local notifications
+ // I really don't want to stack local notififcations beyond 5
if ($cordovaLocalNotification.isPresent(localNotificationId))
{
ZMDataModel.zmDebug("Cancelling notification ID " + localNotificationId);
@@ -138,6 +148,8 @@ angular.module('zmApp.controllers')
$rootScope.isAlarm = 1;
+ // Show upto a max of 99 when it comes to display
+ // so aesthetics are maintained
if ($rootScope.alarmCount == "99")
{
$rootScope.alarmCount="99+";
@@ -158,7 +170,9 @@ angular.module('zmApp.controllers')
}
-
+ //--------------------------------------------------------------------------
+ // Called each time we resume
+ //--------------------------------------------------------------------------
function refresh()
{
var loginData = ZMDataModel.getLogin();
diff --git a/www/js/app.js b/www/js/app.js
index 8ebe7801..ef999f9a 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -28,7 +28,7 @@ angular.module('zmApp', [
//-----------------------------------------------
.constant('zm', {
- minAppVersion: '1.28.107',
+ minAppVersion: '1.28.107', // if ZM is less than this, the app won't work
httpTimeout: 15000,
largeHttpTimeout: 60000,
logFile: 'zmNinjaLog.txt',
@@ -54,7 +54,7 @@ angular.module('zmApp', [
montageScaleFrequency: 300,
eventsListDetailsHeight: 200.0,
eventsListScrubHeight: 300,
- loginScreenString: "var currentView = 'login'" // oh shit. Isn't there a better way?
+ loginScreenString: "var currentView = 'login'" // Isn't there a better way?
})
//------------------------------------------------------------------
@@ -210,8 +210,7 @@ angular.module('zmApp', [
{
// these can take time, so lets bump up timeout
config.timeout = zm.largeHttpTimeout;
- //ZMDataModel.zmDebug("timeoutHttpIntercept: HTTP request with long response time. Timeout set to "+config.timeout);
-
+
} else {
config.timeout = zm.httpTimeout;
}
@@ -565,7 +564,7 @@ angular.module('zmApp', [
console.log("Log file size is " + resp.size + " bytes");
}
- ZMDataModel.zmLog ("Setting up zmNinja for push notifications");
+ // ZMDataModel.zmLog ("Setting up zmNinja for push notifications");
/* $ionicPush.init({
"debug": true,
@@ -714,6 +713,10 @@ angular.module('zmApp', [
.config(function ($stateProvider, $urlRouterProvider, $httpProvider, $ionicConfigProvider, $provide) {
+ // This is an exception interceptor so it can show up in app logs
+ // if they occur. I suspect digest and other errors will be useful
+ // for me to see
+
$provide.decorator("$exceptionHandler", ['$delegate','$injector', function($delegate, $injector) {
return function(exception, cause) {