From c07d973c02d9fba7f7ee744a96f4a684426243b0 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 28 Dec 2018 07:47:05 -0500 Subject: rename DataModel to NVR - more logical --- www/js/MonitorModalCtrl.js | 220 ++++++++++++++++++++++----------------------- 1 file changed, 110 insertions(+), 110 deletions(-) (limited to 'www/js/MonitorModalCtrl.js') diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js index 41eac0ed..4fb320bb 100644 --- a/www/js/MonitorModalCtrl.js +++ b/www/js/MonitorModalCtrl.js @@ -3,14 +3,14 @@ /* jslint browser: true*/ /* global saveAs, cordova,StatusBar,angular,console,ionic, moment, imagesLoaded, chrome */ -angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', '$translate', '$cordovaFile', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups, $translate, $cordovaFile) { +angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'NVR', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', '$translate', '$cordovaFile', function ($scope, $rootScope, zm, NVR, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups, $translate, $cordovaFile) { $scope.animationInProgress = false; $scope.imageFit = true; $scope.isModalActive = true; var intervalModalHandle; var cycleHandle; - var ld = NVRDataModel.getLogin(); + var ld = NVR.getLogin(); $scope.svgReady = false; $scope.zoneArray = []; var originalZones = []; @@ -28,26 +28,26 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.currentStreamMode = 'single'; - NVRDataModel.log("Using stream mode " + $scope.currentStreamMode); + NVR.log("Using stream mode " + $scope.currentStreamMode); - NVRDataModel.debug("MonitorModalCtrl called from " + $ionicHistory.currentStateName()); + NVR.debug("MonitorModalCtrl called from " + $ionicHistory.currentStateName()); //no need to recompute auth in modal /*$rootScope.validMonitorId = $scope.monitors[0].Monitor.Id; - NVRDataModel.getAuthKey($rootScope.validMonitorId, $scope.monitors[0].Monitor.connKey) + NVR.getAuthKey($rootScope.validMonitorId, $scope.monitors[0].Monitor.connKey) .then(function (success) { $ionicLoading.hide(); $rootScope.authSession = success; - NVRDataModel.log("Modal: Stream authentication construction: " + $rootScope.authSession); + NVR.log("Modal: Stream authentication construction: " + $rootScope.authSession); }, function (error) { $ionicLoading.hide(); - NVRDataModel.debug("ModalCtrl: Error details of stream auth:" + error); + NVR.debug("ModalCtrl: Error details of stream auth:" + error); //$rootScope.authSession=""; - NVRDataModel.log("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); + NVR.log("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); }); */ @@ -117,7 +117,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.togglePTZ(); } else { // rest of the functions are PTZ if (!$scope.showPTZ) { - NVRDataModel.debug("PTZ is not on, or disabled"); + NVR.debug("PTZ is not on, or disabled"); return; } // coming here means PTZ is on @@ -152,10 +152,10 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ break; } if (cmd) { - NVRDataModel.debug("Invoking controlPTZ with " + cmd); + NVR.debug("Invoking controlPTZ with " + cmd); $scope.controlPTZ($scope.monitorId, cmd); } else { - NVRDataModel.debug("ignoring invalid PTZ command"); + NVR.debug("ignoring invalid PTZ command"); } } @@ -287,17 +287,17 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ var as = $scope.$on("auth-success", function () { - NVRDataModel.debug("MonitorModalCtrl: Re-login detected, resetting everything & re-generating connkey"); - //NVRDataModel.stopNetwork("MonitorModal-auth success"); + NVR.debug("MonitorModalCtrl: Re-login detected, resetting everything & re-generating connkey"); + //NVR.stopNetwork("MonitorModal-auth success"); $scope.isModalStreamPaused = false; $timeout(function () { if (0 && $rootScope.platformOS == 'ios') { - NVRDataModel.debug("Webkit hack, hammering window.stop();"); - NVRDataModel.stopNetwork(); + NVR.debug("Webkit hack, hammering window.stop();"); + NVR.stopNetwork(); } else { - NVRDataModel.killLiveStream($scope.connKey, $scope.controlURL); + NVR.killLiveStream($scope.connKey, $scope.controlURL); } @@ -320,13 +320,13 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.toggleCycle = function () { //console.log ("HERE"); $scope.isCycle = !$scope.isCycle; - var ld = NVRDataModel.getLogin(); + var ld = NVR.getLogin(); ld.cycleMonitors = $scope.isCycle; - NVRDataModel.setLogin(ld); + NVR.setLogin(ld); $scope.cycleText = $scope.isCycle ? $translate.instant('kOn') : $translate.instant('kOff'); if ($scope.isCycle) { - NVRDataModel.log("re-starting cycle timer"); + NVR.log("re-starting cycle timer"); $interval.cancel(cycleHandle); cycleHandle = $interval(function () { @@ -334,7 +334,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ // console.log ("Refreshing Image..."); }.bind(this), ld.cycleMonitorsInterval * 1000); } else { - NVRDataModel.log("cancelling cycle timer"); + NVR.log("cancelling cycle timer"); $interval.cancel(cycleHandle); } @@ -367,17 +367,17 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ //------------------------------------------------------------- function onPause() { - NVRDataModel.debug("ModalCtrl: onpause called"); + NVR.debug("ModalCtrl: onpause called"); $interval.cancel(intervalModalHandle); $interval.cancel(cycleHandle); - NVRDataModel.debug("Killing single stream..."); + NVR.debug("Killing single stream..."); if (0 && $rootScope.platformOS == 'ios') { - NVRDataModel.debug("Webkit hack, hammering window.stop();"); - NVRDataModel.stopNetwork(); + NVR.debug("Webkit hack, hammering window.stop();"); + NVR.stopNetwork(); } else { - NVRDataModel.killLiveStream($scope.connKey, $scope.controlURL); + NVR.killLiveStream($scope.connKey, $scope.controlURL); } // $interval.cancel(modalIntervalHandle) // FIXME: Do I need to setAwake(false) here? @@ -385,21 +385,21 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function onResume() { if (1) return; // Do we really need this as it should go to Portal Login - NVRDataModel.debug("ModalCtrl: Modal resume called"); + NVR.debug("ModalCtrl: Modal resume called"); if ($scope.isModalActive) { - NVRDataModel.log("ModalCtrl: Restarting Modal timer on resume"); + NVR.log("ModalCtrl: Restarting Modal timer on resume"); $interval.cancel(intervalModalHandle); $interval.cancel(cycleHandle); - var ld = NVRDataModel.getLogin(); + var ld = NVR.getLogin(); intervalModalHandle = $interval(function () { loadModalNotifications(); }.bind(this), zm.alarmStatusTime); if (ld.cycleMonitors) { - NVRDataModel.debug("Cycling enabled at " + ld.cycleMonitorsInterval); + NVR.debug("Cycling enabled at " + ld.cycleMonitorsInterval); $interval.cancel(cycleHandle); @@ -421,12 +421,12 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ //------------------------------------------------------------- function loadModalNotifications() { - if (NVRDataModel.versionCompare($rootScope.apiVersion, "1.30") == -1) { + if (NVR.versionCompare($rootScope.apiVersion, "1.30") == -1) { return; } - if (NVRDataModel.getLogin().enableLowBandwidth) + if (NVR.getLogin().enableLowBandwidth) return; var status = [$translate.instant('kMonIdle'), @@ -436,13 +436,13 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $translate.instant('kMonRecord') ]; //console.log ("Inside Modal timer..."); - var apiurl = NVRDataModel.getLogin().apiurl; + var apiurl = NVR.getLogin().apiurl; var alarmurl = apiurl + "/monitors/alarm/id:" + $scope.monitorId + "/command:status.json"; - NVRDataModel.log("Invoking " + alarmurl); + NVR.log("Invoking " + alarmurl); $http.get(alarmurl) .then(function (data) { - // NVRDataModel.debug ("Success in monitor alarmed status " + JSON.stringify(data)); + // NVR.debug ("Success in monitor alarmed status " + JSON.stringify(data)); $scope.monStatus = status[parseInt(data.data.status)]; @@ -450,7 +450,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function (error) { $scope.monStatus = ""; - NVRDataModel.debug("Error in monitor alarmed status "); + NVR.debug("Error in monitor alarmed status "); }); } @@ -735,7 +735,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ }*/ $scope.isModalStreamPaused = false; - //NVRDataModel.debug("Modal image loaded, switching to streaming"); + //NVR.debug("Modal image loaded, switching to streaming"); @@ -789,7 +789,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ var ptzData = ""; if (cmd.lastIndexOf("preset", 0) === 0) { - NVRDataModel.debug("PTZ command is a preset, so skipping xge/lge"); + NVR.debug("PTZ command is a preset, so skipping xge/lge"); ptzData = { view: "request", request: "control", @@ -820,7 +820,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ duration: zm.loadingTimeout, }); - var loginData = NVRDataModel.getLogin(); + var loginData = NVR.getLogin(); $ionicLoading.hide(); $ionicLoading.show({ template: $translate.instant('kSendingPTZ') + "...", @@ -858,7 +858,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function (resp) { $ionicLoading.hide(); //console.log("ERROR: " + JSON.stringify(resp)); - NVRDataModel.log("Error sending PTZ:" + JSON.stringify(resp), "error"); + NVR.log("Error sending PTZ:" + JSON.stringify(resp), "error"); }); @@ -877,10 +877,10 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.onSwipe = function (m, d) { if ($scope.isZoneEdit) { - NVRDataModel.log("swipe disabled as you are in edit mode"); + NVR.log("swipe disabled as you are in edit mode"); return; } - var ld = NVRDataModel.getLogin(); + var ld = NVR.getLogin(); if (!ld.canSwipeMonitors) return; if ($ionicScrollDelegate.$getByHandle("imgscroll").getScrollPosition().zoom != 1) { @@ -896,12 +896,12 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ if ($scope.isZoneEdit) { - NVRDataModel.log("Not cycling, as you are editing zones"); + NVR.log("Not cycling, as you are editing zones"); return; } if ($scope.monitors.length <= 1) { - NVRDataModel.log("Not cycling, as you only have at most 1 monitors"); + NVR.log("Not cycling, as you only have at most 1 monitors"); return; } @@ -911,14 +911,14 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ var curstate = $ionicHistory.currentStateName(); var found = 0; var mid; - mid = NVRDataModel.getNextMonitor(m, d); + mid = NVR.getNextMonitor(m, d); $scope.showPTZ = false; // FIXME: clean this up - in a situation where // no monitors are enabled, will it loop for ever? do { - mid = NVRDataModel.getNextMonitor(m, d); + mid = NVR.getNextMonitor(m, d); m = mid; //console.log("Next Monitor is " + m); @@ -931,10 +931,10 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.monitors[i].Monitor.Enabled != '0') { found = 1; //console.log(mid + "is part of the monitor list"); - NVRDataModel.debug("ModalCtrl: swipe detected, moving to " + mid); + NVR.debug("ModalCtrl: swipe detected, moving to " + mid); break; } else { - NVRDataModel.debug("skipping " + $scope.monitors[i].Monitor.Id + + NVR.debug("skipping " + $scope.monitors[i].Monitor.Id + " listDisplay=" + $scope.monitors[i].Monitor.listDisplay + " Function=" + $scope.monitors[i].Monitor.Function + " Enabled=" + $scope.monitors[i].Monitor.Enabled); @@ -945,14 +945,14 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ while (found != 1); // now kill stream and set up next - NVRDataModel.debug("Killing stream before we move on to next monitor..."); + NVR.debug("Killing stream before we move on to next monitor..."); $scope.isModalStreamPaused = true; var element = angular.element(document.getElementById("monitorimage")); var slidein; var slideout; $timeout(function () { - NVRDataModel.killLiveStream($scope.connKey, $scope.controlURL); + NVR.killLiveStream($scope.connKey, $scope.controlURL); // we should now have a paused stream, time to animate out @@ -977,9 +977,9 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function outWithOld() { - NVRDataModel.log(">>>Old image out"); - // NVRDataModel.log("ModalCtrl:Stopping network pull..."); - //NVRDataModel.stopNetwork("MonitorModal-outwithOld"); + NVR.log(">>>Old image out"); + // NVR.log("ModalCtrl:Stopping network pull..."); + //NVR.stopNetwork("MonitorModal-outwithOld"); $scope.rand = Math.floor((Math.random() * 100000) + 1); @@ -989,8 +989,8 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); $scope.monitorId = mid; - $scope.monitorName = NVRDataModel.getMonitorName(mid); - $scope.monitor = NVRDataModel.getMonitorObject(mid); + $scope.monitorName = NVR.getMonitorName(mid); + $scope.monitor = NVR.getMonitorObject(mid); $scope.controlURL = $scope.monitor.Monitor.controlURL; $scope.zoneArray = []; $scope.circlePoints = []; @@ -1006,11 +1006,11 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.isModalStreamPaused = false; - var ld = NVRDataModel.getLogin(); + var ld = NVR.getLogin(); carouselUtils.setStop(false); $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); // get new key for new id $scope.animationInProgress = false; // has to be AFTER new connkey - NVRDataModel.log("<<