From 7bffc0e73848b6315fc8a89277f45668801a674b Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Tue, 13 Oct 2015 15:03:42 -0400 Subject: comments updated --- www/js/DataModel.js | 21 +++++++++++++++++---- www/js/EventCtrl.js | 10 ++-------- www/js/EventServer.js | 26 ++++++++++++++++++++------ www/js/app.js | 13 ++++++++----- 4 files changed, 47 insertions(+), 23 deletions(-) (limited to 'www/js') 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