diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2018-10-31 14:51:39 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2018-10-31 14:51:39 -0400 |
| commit | 38aecc45c37dbaf35a0523f3e8a880570b64f47a (patch) | |
| tree | a8b56e79bcb7490d377278ac7595e0919a6b7acc /www | |
| parent | 91c6171487cc4f88b935deb8b3cf61ef9728e009 (diff) | |
#733 use new Monitor_Status if available
Diffstat (limited to 'www')
| -rw-r--r-- | www/js/DataModel.js | 31 | ||||
| -rw-r--r-- | www/js/EventCtrl.js | 2 | ||||
| -rw-r--r-- | www/js/MonitorCtrl.js | 54 |
3 files changed, 84 insertions, 3 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 17305f22..c558d884 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -2081,6 +2081,29 @@ angular.module('zmApp.controllers') },*/ + getMultiServersCached: function () { + return multiservers; + }, + + // use non cached for daemon status + getMultiServers: function () { + return $http.get (loginData.apiurl+'/servers.json'); + + }, + + getMultiServer: function (id) { + + var ndx = -1; + for (var i=0; i < multiservers.length; i++) { + if (multiservers[i].Server.Id == id) { + ndx = i; + break; + } + } + return ndx == -1 ? {}:multiservers[ndx]; + + }, + regenConnKeys: function () { debug("DataModel: Regenerating connkeys..."); @@ -2144,7 +2167,7 @@ angular.module('zmApp.controllers') data = data.data; // We found a server list API, so lets make sure // we get the hostname as it will be needed for playback - log("multi server list loaded" + JSON.stringify(data)); + log("multi server list loaded:" + JSON.stringify(data)); multiservers = data.servers; var multiserver_scheme = "http://"; @@ -2158,6 +2181,8 @@ angular.module('zmApp.controllers') for (var i = 0; i < monitors.length; i++) { // make them all show for now + + monitors[i].Monitor.listDisplay = 'show'; monitors[i].Monitor.isAlarmed = false; monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); @@ -2276,11 +2301,13 @@ angular.module('zmApp.controllers') } else { //monitors[i].Monitor.listDisplay = 'show'; + debug ("No servers matched, filling defaults..."); monitors[i].Monitor.isAlarmed = false; monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString(); var st2 = loginData.streamingurl; + controlURL = loginData.url; if (zmsPort > 0 && !loginData.disableSimulStreaming) { // we need to insert minport @@ -2302,6 +2329,8 @@ angular.module('zmApp.controllers') if (p3.path) controlURL += p3.path; } + debug ("Storing streaming="+st2+" recording="+controlURL); + monitors[i].Monitor.streamingURL = st2; monitors[i].Monitor.controlURL = controlURL; //debug ("Streaming URL for Monitor " + monitors[i].Monitor.Id + " is " + monitors[i].Monitor.streamingURL ); diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index caf27220..66ff6463 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -2815,7 +2815,7 @@ angular.module('zmApp.controllers') function recomputeThumbSize() { - NVRDataModel.debug("EventCtrl: recompute thumbnails"); + // NVRDataModel.debug("EventCtrl: recompute thumbnails"); for (var i = 0; i < $scope.events.length; i++) { var tempMon = NVRDataModel.getMonitorObject($scope.events[i].Event.MonitorId); diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 8926688b..6008a4a0 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -415,8 +415,60 @@ angular.module('zmApp.controllers') //----------------------------------------------------------------------- function monitorStateCheck() { + + var ld = NVRDataModel.getLogin(); + // force get for latest status of monitors if av. + NVRDataModel.getMonitors(1) + .then (function (data) { + + $scope.monitors = data; + if (!$scope.monitors[0].Monitor_Status ) { + NVRDataModel.debug ("no Monitor_Status found reverting to daemonCheck..."); + forceDaemonCheck(); + } + else { + NVRDataModel.debug ("reporting status of monitors from multi-server API"); + processMonitorStatus(); + } + + }, + function (err) { + NVRDataModel.debug ("Monitor fetch error, reverting to daemonCheck..."); + forceDaemonCheck(); + }) + + } + + function processMonitorStatus () { + + //array('Unknown','NotRunning','Running','NoSignal','Signal'), + + + // console.log (JSON.stringify($scope.monitors)); + for (var j=0; j < $scope.monitors.length; j++) { + + if ($scope.monitors[j].Monitor_Status.Status == 'Connected') { + $scope.monitors[j].Monitor.isRunning = "true"; + $scope.monitors[j].Monitor.color = zm.monitorRunningColor; + $scope.monitors[j].Monitor.char = "ion-checkmark-circled"; + $scope.monitors[j].Monitor.isRunningText = $scope.monitors[j].Monitor_Status.Status; + } + else { + $scope.monitors[j].Monitor.isRunning = "false"; + $scope.monitors[j].Monitor.color = zm.monitorNotRunningColor; + $scope.monitors[j].Monitor.char = "ion-close-circled"; + $scope.monitors[j].Monitor.isRunningText = $scope.monitors[j].Monitor_Status.Status; + } + + } + + } + + function forceDaemonCheck() { var apiMonCheck; + $scope.loginData = NVRDataModel.getLogin(); + // The status is provided by zmdc.pl // "not running", "pending", "running since", "Unable to connect" var i; @@ -426,7 +478,7 @@ angular.module('zmApp.controllers') $scope.monitors[j].Monitor.isRunning = "..."; $scope.monitors[j].Monitor.color = zm.monitorCheckingColor; $scope.monitors[j].Monitor.char = "ion-checkmark-circled"; - apiMonCheck = loginData.apiurl + "/monitors/daemonStatus/id:" + $scope.monitors[j].Monitor.Id + "/daemon:zmc.json"; + apiMonCheck = $scope.loginData.apiurl + "/monitors/daemonStatus/id:" + $scope.monitors[j].Monitor.Id + "/daemon:zmc.json"; NVRDataModel.debug("MonitorCtrl:monitorStateCheck: " + apiMonCheck); |
