From d442629aa825aab6bc55ab6be19e3aba060867fe Mon Sep 17 00:00:00 2001 From: PliablePixels Date: Sun, 21 Jun 2015 18:05:01 -0400 Subject: remove simulation code completely to keep things easy to understand. --- www/js/DataModel.js | 211 ++++++++------------------------ www/js/DevOptionsCtrl.js | 2 +- www/js/EventCtrl.js | 13 -- www/js/EventsGraphsCtrl.js | 149 +++++++++-------------- www/js/LoginCtrl.js | 44 +++---- www/js/ModalCtrl.js | 67 ++--------- www/js/MonitorCtrl.js | 54 --------- www/js/StateCtrl.js | 247 +++++++++++++++++++------------------- www/js/app.js | 31 +---- www/templates/devoptions.html | 9 +- www/templates/events-graphs.html | 18 +-- www/templates/events-modal.html | 38 ++---- www/templates/events.html | 60 +++------ www/templates/help.html | 80 ++++++------ www/templates/login.html | 2 - www/templates/monitors-modal.html | 43 ++----- www/templates/monitors.html | 24 ++-- www/templates/montage.html | 92 +++++++------- www/templates/state.html | 2 +- 19 files changed, 402 insertions(+), 784 deletions(-) diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 72dfc747..ec2deeb3 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -10,8 +10,6 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ionicLoading', '$ionicBackdrop', function ($http, $q, $ionicLoading, $ionicBackdrop) { // var deferred=''; var monitorsLoaded = 0; - var simSize = 30; // how many monitors to simulate - var eventSimSize = 40; // events to simulare per monitor var montageSize = 3; var monitors = []; var oldevents = []; @@ -20,83 +18,10 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion 'password': '', 'url': '', // This is the ZM portal path 'apiurl': '', // This is the API path - 'simulationMode': false, // if true, data will be simulated. Not using this now 'maxMontage': "10", //total # of monitors to display in montage 'streamingurl': "", - 'maxFPS':"3", // image streaming FPS - 'montageQuality':"50", // montage streaming quality in % - }; - - // This is really a test mode. This is how I am validating - // how my app behaves if you have many monitors. If you set simulationMode to true - // then this is the function that getMonitors and getEvents calls - - var simulation = { - fillSimulatedMonitors: function (cnt) { - var simmonitors = []; - console.log("*** SIM MONITORS: Returning " + cnt + " simulated monitors"); - for (var i = 0; i < cnt; i++) { - - - simmonitors.push({ - "Monitor": { - // Obviously this is dummy data - "Id": i.toString(), - "Name": "Sim-Monitor" + i.toString(), - "Type": "Remote", - "Function": "Modect", - "Enabled": "1", - "Width": "1280", - "Height": "960", - "Colours": "4", - "MaxFPS": "10.00", - "AlarmMaxFPS": "10.00", - "AlarmFrameCount": "10.00" - } - }); - - } - return simmonitors; - }, - - fillSimulatedEvents: function (cnt) { - var simevents = []; - if (monitors.length == 0) // we have arrived at events before simulating monitors - { // not sure if it will ever happen as I have a route resolve - console.log("Monitors have not been simulated yet. Filling them in"); - monitors = simulation.fillSimulatedMonitors(simSize); - } - console.log("*** Returning " + cnt + " simulated events Per " + monitors.length + "Monitors"); - var causes = ["Motion", "Signal", "Something else"]; - for (var mon = 0; mon < monitors.length; mon++) { - console.log("Simulating " + cnt + "events for Monitor " + mon); - for (var i = 0; i < cnt; i++) { - - - simevents.push({ - "Event": { - // Obviously this is dummy data - "Id": Math.floor(Math.random() * (5000 - 100 + 1)) + 1000, - "MonitorId": mon.toString(), - "Cause": causes[Math.floor(Math.random() * (2 - 0 + 1)) + 0], - "Length": Math.floor(Math.random() * (700 - 20 + 1)) + 20, - "Name": "Event Simulation " + i.toString(), - "Frames": Math.floor(Math.random() * (700 - 20 + 1)) + 20, - "AlarmFrames": Math.floor(Math.random() * (700 - 20 + 1)) + 20, - "TotScore": Math.floor(Math.random() * (100 - 2 + 1)) + 2, - "StartTime": "2015-04-24 09:00:00", - "Notes": "This is simulated", - - } - }); - - } // for i - } // for mon - // console.log ("Simulated: "+JSON.stringify(simmonitors)); - return simevents; - }, - - + 'maxFPS': "3", // image streaming FPS + 'montageQuality': "50", // montage streaming quality in % }; return { @@ -121,7 +46,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion } - if (window.localStorage.getItem("montageQuality") != undefined) { + if (window.localStorage.getItem("montageQuality") != undefined) { loginData.montageQuality = window.localStorage.getItem("montageQuality"); @@ -145,14 +70,6 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion } - if (window.localStorage.getItem("simulationMode") != undefined) { - // Remember to convert back to Boolean! - var tvar = window.localStorage.getItem("simulationMode"); - loginData.simulationMode = (tvar === "true"); - console.log("***** STORED SIMULATION IS " + tvar); - console.log("******* BOOLEAN VALUE IS " + loginData.simulationMode); - - } if (window.localStorage.getItem("maxMontage") != undefined) { loginData.maxMontage = @@ -173,7 +90,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion console.log("maxFPS " + loginData.maxFPS); } - if (window.localStorage.getItem("montageQuality") != undefined) { + if (window.localStorage.getItem("montageQuality") != undefined) { loginData.montageQuality = window.localStorage.getItem("montageQuality"); console.log("montageQuality " + loginData.montageQuality); @@ -194,14 +111,6 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion return 0; {} }, - isSimulated: function () { - return loginData.simulationMode; - }, - - setSimulated: function (mode) { - loginData.simulationMode = mode; - }, - getLogin: function () { return loginData; }, @@ -212,12 +121,10 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion window.localStorage.setItem("password", loginData.password); window.localStorage.setItem("url", loginData.url); window.localStorage.setItem("apiurl", loginData.apiurl); - window.localStorage.setItem("simulationMode", loginData.simulationMode); window.localStorage.setItem("streamingurl", loginData.streamingurl); - if (loginData.maxFPS >30) - { - console.log ("MAXFPS Too high, maxing to 30"); + if (loginData.maxFPS > 30) { + console.log("MAXFPS Too high, maxing to 30"); loginData.maxFPS = "30"; } window.localStorage.setItem("maxFPS", loginData.maxFPS); @@ -237,7 +144,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion window.localStorage.setItem("maxMontage", loginData.maxMontage); - window.localStorage.setItem("montageQuality", loginData.montageQuality); + window.localStorage.setItem("montageQuality", loginData.montageQuality); }, @@ -247,9 +154,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion // if 0. then it will return back the previously loaded monitor list if one exists, else // will issue a new HTTP API to get it - // I've wrapped this function in my own promise even though http returns a promise. This is because - // depending on forceReload and simulation mode, http may or may not be called. So I'm promisifying - // the non http stuff too to keep it consistent to the calling function. + // I've wrapped this function in my own promise even though http returns a promise. getMonitors: function (forceReload) { console.log("** Inside ZMData getMonitors with forceReload=" + forceReload); @@ -262,7 +167,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion showDelay: 0 }); var d = $q.defer(); - if (((monitorsLoaded == 0) || (forceReload == 1)) && (loginData.simulationMode != true)) // monitors are empty or force reload + if ((monitorsLoaded == 0) || (forceReload == 1)) // monitors are empty or force reload { console.log("ZMDataModel: Invoking HTTP get to load monitors"); var apiurl = loginData.apiurl; @@ -289,10 +194,6 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion } else // monitors are loaded { - if (loginData.simulationMode == true) { - monitors = simulation.fillSimulatedMonitors(simSize); - //fillSimulatedMonitors - } console.log("Returning pre-loaded list of " + monitors.length + " monitors"); d.resolve(monitors); $ionicLoading.hide(); @@ -347,22 +248,20 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion console.log("ZMData getEvents called with ID=" + monitorId + "and Page=" + pageId); - if (!loadingStr) - { - loadingStr = "Loading Events..."; - } + if (!loadingStr) { + loadingStr = "Loading Events..."; + } //if (loadingStr) loa - if (loadingStr != 'none') - { - $ionicLoading.show({ - template: loadingStr, - animation: 'fade-in', - showBackdrop: true, - maxWidth: 200, - showDelay: 0, - duration: 15000, //specifically for Android - http seems to get stuck at times - }); + if (loadingStr != 'none') { + $ionicLoading.show({ + template: loadingStr, + animation: 'fade-in', + showBackdrop: true, + maxWidth: 200, + showDelay: 0, + duration: 15000, //specifically for Android - http seems to get stuck at times + }); } //$ionicBackdrop.retain(); @@ -378,46 +277,38 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion } console.log("Constructed URL is " + myurl); - if (loginData.simulationMode == true) { - console.log("Events will be simulated"); - myevents = simulation.fillSimulatedEvents(eventSimSize); - d.resolve(myevents); - if (loadingStr != 'none') $ionicLoading.hide(); - return d.promise; - } else { // not simulated - $http.get(myurl /*,{timeout:15000}*/ ) - .success(function (data) { - if (loadingStr != 'none') $ionicLoading.hide(); - //myevents = data.events; - myevents = data.events.reverse(); - if (monitorId == 0) { - oldevents = myevents; - } - //console.log (JSON.stringify(data)); - console.log("DataModel Returning " + myevents.length + "events for page"+pageId); - d.resolve(myevents); - return d.promise; + $http.get(myurl /*,{timeout:15000}*/ ) + .success(function (data) { + if (loadingStr != 'none') $ionicLoading.hide(); + //myevents = data.events; + myevents = data.events.reverse(); + if (monitorId == 0) { + oldevents = myevents; + } + //console.log (JSON.stringify(data)); + console.log("DataModel Returning " + myevents.length + "events for page" + pageId); + d.resolve(myevents); + return d.promise; - }) - .error(function (err) { - if (loadingStr != 'none') $ionicLoading.hide(); - console.log("HTTP Events error " + err); - // I need to reject this as I have infinite scrolling - // implemented in EventCtrl.js --> and if it does not know - // it got an error going to the next page, it will get into - // an infinite loop as we are at the bottom of the list always - - d.reject(myevents); - - // FIXME: Check what pagination does to this logic - if (monitorId == 0) { - oldevents = []; - } - return d.promise; - }); - return d.promise; - } // not simulated + }) + .error(function (err) { + if (loadingStr != 'none') $ionicLoading.hide(); + console.log("HTTP Events error " + err); + // I need to reject this as I have infinite scrolling + // implemented in EventCtrl.js --> and if it does not know + // it got an error going to the next page, it will get into + // an infinite loop as we are at the bottom of the list always + + d.reject(myevents); + + // FIXME: Check what pagination does to this logic + if (monitorId == 0) { + oldevents = []; + } + return d.promise; + }); + return d.promise; }, getMontageSize: function () { diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js index 9964b036..7c9cfce7 100644 --- a/www/js/DevOptionsCtrl.js +++ b/www/js/DevOptionsCtrl.js @@ -29,7 +29,7 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope' } - if ((parseInt($scope.loginData.montageQuality) <10) || (parseInt($scope.loginData.montageQuality)>100)) + if ((parseInt($scope.loginData.montageQuality) <10) || (parseInt($scope.loginData.montageQuality)>70)) { $scope.loginData.montageQuality='50'; } diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 98c3b6c9..2cda31bf 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -146,16 +146,6 @@ angular.module('zmApp.controllers').controller('zmApp.EventCtrl', ['$ionicPlatfo $scope.controlEventStream = function (cmd) { console.log("Command value " + cmd); - if (ZMDataModel.isSimulated()) { - var str = "simulation mode. no action taken"; - $ionicLoading.show({ - template: str, - noBackdrop: true, - duration: 3000 - }); - return; - } - $ionicLoading.hide(); $ionicLoading.show({ template: "please wait...", @@ -421,9 +411,6 @@ $ionicLoading.show({ maxwidth:100, scope:$scope, template: ' diff --git a/www/templates/events-graphs.html b/www/templates/events-graphs.html index 3f3c2305..91b58001 100644 --- a/www/templates/events-graphs.html +++ b/www/templates/events-graphs.html @@ -7,11 +7,11 @@ - + - - + + @@ -31,12 +31,12 @@
- +
- + - + @@ -49,7 +49,7 @@
- +
@@ -63,8 +63,8 @@ -
- +
+
diff --git a/www/templates/events-modal.html b/www/templates/events-modal.html index 221e0dc7..c904c9d0 100644 --- a/www/templates/events-modal.html +++ b/www/templates/events-modal.html @@ -11,37 +11,25 @@ --> -
- - +
+ - -
- - - + + + diff --git a/www/templates/events.html b/www/templates/events.html index 7c3b2bf3..0f9a5570 100644 --- a/www/templates/events.html +++ b/www/templates/events.html @@ -1,5 +1,5 @@ - + @@ -7,48 +7,26 @@ - - - - - - - - + + -
- - +
+ + + +
- - - - - - + - +
@@ -77,22 +55,22 @@
-
{{event.Event.MonitorName}} ({{event.Event.Name}})
+
+ {{event.Event.MonitorName}} ({{event.Event.Name}}) +
{{event.Event.Frames}}   {{event.Event.AlarmFrames}}   {{event.Event.TotScore}} - - + +
- -
+
 {{event.Event.StartTime}} diff --git a/www/templates/help.html b/www/templates/help.html index decdf47e..e5f18bd8 100644 --- a/www/templates/help.html +++ b/www/templates/help.html @@ -6,63 +6,57 @@ -
+
- -

What is an API path?

- The latest versions of ZoneMinder have an API that is supposed to replace the XML skin. - It is only available starting Zoneminder 1.29. If you don't have - the API installed the client WILL NOT WORK. + +

What is an API path?

The latest versions of ZoneMinder have an API that is supposed to replace the XML skin. It is only available starting Zoneminder 1.29. If you don't have the API installed the client WILL NOT WORK. -
+
- -

What is ZM base URL, portal alias and API path

- Okay, there are multiple ways you can install ZoneMinder. For example, let's say you access zoneminder via http://yourserver.com:8000/zm. Then, http://yoursever.com:8000 is the base portal URL and the alias is zm. It's important you get these right, otherwise the app won't be able to display the data. -
+ +

What is ZM base URL, portal alias and API path

Okay, there are multiple ways you can install ZoneMinder. For example, let's say you access zoneminder via http://yourserver.com:8000/zm. Then, http://yoursever.com:8000 is the base portal URL and the alias is zm. It's important you get these right, otherwise the app won't be able to display the data. +
- -

What should I be entering in the Base URL and API URL?

- The base url is typically of the format "http://yourserver:port/" (don't specify zm) - The API url is typically of the format "http://yourserver:port/zm/api" - But it depends on how you've installed ZoneMinder -
+ +

What should I be entering in the Base URL and API URL?

The base url is typically of the format "http://yourserver:port/" (don't specify zm) The API url is typically of the format "http://yourserver:port/zm/api" But it depends on how you've installed ZoneMinder +
- -

I do not have authentication enabled but the app keeps asking me to specify authentication

- If you don't use ZM authentication, just enter an "x" in both user name and password. -
+ +

I do not have authentication enabled but the app keeps asking me to specify authentication

If you don't use ZM authentication, just enter an "x" in both user name and password. +
- -

The data is not refreshing!

- Most screens that show lists of data has a pull down action. Pull down to refresh and your data - should be reloaded. -
+ +

The data is not refreshing!

Most screens that show lists of data has a pull down action. Pull down to refresh and your data should be reloaded. +
- -

What do all the colors in the Monitor view mean?

- Checking
- All good
- Not running
- Not running (pending)
- Disabled
- Unknown
+ +

What do all the colors in the Monitor view mean?

+ Checking +
+ All good +
+ Not running +
+ Not running (pending) +
+ Disabled +
+ Unknown +
-
+
- -

I want to contribute!

- Awesome. Grab the source code! -
+ +

I want to contribute!

Awesome. Grab the source code! +
- -

How do I contact the author?

- Send me an email -
+ +

How do I contact the author?

Send me an email +
diff --git a/www/templates/login.html b/www/templates/login.html index 1ad11b0c..bf1fc487 100644 --- a/www/templates/login.html +++ b/www/templates/login.html @@ -27,8 +27,6 @@
- -
diff --git a/www/templates/monitors-modal.html b/www/templates/monitors-modal.html index f8f15029..0e1401ab 100644 --- a/www/templates/monitors-modal.html +++ b/www/templates/monitors-modal.html @@ -1,59 +1,30 @@ - -
- - + -
- - -
+ - - -
-
- - +
+ + + + diff --git a/www/templates/monitors.html b/www/templates/monitors.html index 7b6b00b3..1945fa22 100644 --- a/www/templates/monitors.html +++ b/www/templates/monitors.html @@ -9,27 +9,24 @@
- +
- - {{monitor.Monitor.Name}} - + + {{monitor.Monitor.Name}} + - - - +
- - {{monitor.Monitor.Name}} - - - + + {{monitor.Monitor.Name}} + +
@@ -41,7 +38,8 @@
Alarm Max FPS:{{monitor.Monitor.AlarmMaxFPS}}
Alarm Frame Count: {{monitor.Monitor.AlarmFrameCount}}
Status: {{monitor.Monitor.isRunningText}} -

+
+

diff --git a/www/templates/montage.html b/www/templates/montage.html index 822212bc..d1106e2e 100644 --- a/www/templates/montage.html +++ b/www/templates/montage.html @@ -10,63 +10,55 @@ - +
- - - - + -
- +
+ - - + + -
+
-
- - - -
  - {{monitor.Monitor.Name}} 
- - -
-
- -
- - - - -
- - {{monitor.Monitor.Enabled=="1"?"Enabled":"Not Enabled"}} -   - - - - :{{monitor.Monitor.Function}} - -
-
- - -
-
- -
-
- - +
+ + + +
  + {{monitor.Monitor.Name}} 
+
+
+ + +
+ + + +
+ + {{monitor.Monitor.Enabled=="1"?"Enabled":"Not Enabled"}} +   + + + + :{{monitor.Monitor.Function}} + +
+
+
+
+ +
+
+ +
-
+ - diff --git a/www/templates/state.html b/www/templates/state.html index a326652b..56679db2 100644 --- a/www/templates/state.html +++ b/www/templates/state.html @@ -60,7 +60,7 @@ -- cgit v1.2.3