From fe4687baecf8963eb820bc65cad91bd35a153b9c Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 2 Dec 2019 14:33:55 -0500 Subject: #867 clean up global code --- www/css/style.css | 4 +++ www/js/HelpCtrl.js | 2 +- www/js/MonitorCtrl.js | 86 ++++++++++++++++++++------------------------- www/lang/locale-en.json | 3 ++ www/templates/monitors.html | 2 +- 5 files changed, 47 insertions(+), 50 deletions(-) diff --git a/www/css/style.css b/www/css/style.css index 913ed225..6d009c9b 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -1584,6 +1584,10 @@ videogular div.event-time { white-space: nowrap; } +.widepopup .popup { + width:70%; +} + .visred { fill: #FF0000; } diff --git a/www/js/HelpCtrl.js b/www/js/HelpCtrl.js index bc9c3f0b..2e40914e 100644 --- a/www/js/HelpCtrl.js +++ b/www/js/HelpCtrl.js @@ -65,7 +65,7 @@ angular.module('zmApp.controllers').controller('zmApp.HelpCtrl', ['$scope', '$ro options = { }; - console.log ('got '+url); + //console.log ('got '+url); if ($rootScope.platformOS == 'desktop' ) { window.open(url, '_blank', options); } else { diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 45d0d9a5..b396f5ee 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -82,23 +82,23 @@ angular.module('zmApp.controllers') $scope.changeConfig = function (monitorName, monitorId, enabled, func) { var checked = false; + var monitorsIds = []; if (monitorName == 'All') { monitorName = $translate.instant('kAll'); - } - - //console.log("called with " + monitorId + ":" + enabled + ":" + func); - if (enabled == '1') checked = true; - - //if monitorId is not specified, all monitors will be changed - var monitorsIds = []; - if (monitorId == '') { + // in all monitors, lets keep enabled on + enabled = '1'; for (var i = 0; i < $scope.monitors.length; i++) { monitorsIds[i] = $scope.monitors[i].Monitor.Id; } - } else { + } else { monitorsIds[0] = monitorId; } + //console.log("called with " + monitorId + ":" + enabled + ":" + func); + if (enabled == '1') checked = true; + + //if monitorId is not specified, all monitors will be changed + $scope.monFunctions = [{ text: $translate.instant('kMonModect'), value: "Modect" @@ -133,9 +133,11 @@ angular.module('zmApp.controllers') mypromises: [] }; + //console.log (JSON.stringify($scope.monfunc)); $rootScope.zmPopup = $ionicPopup.show({ scope: $scope, - template: 'Enabled {{item.text}} ', + cssClass:'widepopup', + template: ''+$translate.instant('kMotionEnabled')+'
'+$translate.instant('kChangeMode')+'
{{item.text}} ', title: $translate.instant('kChangeSettingsFor') + ' ' + monitorName, @@ -146,17 +148,18 @@ angular.module('zmApp.controllers') { text: $translate.instant('kButtonSave'), onTap: function (e) { - $scope.monfunc.mymonitorsIds.forEach(function (item, index) { - NVR.debug("MonitorCtrl:changeConfig selection:" + $scope.monfunc.myenabled + - $scope.monfunc.myfunc); - var loginData = NVR.getLogin(); - var apiRestart = loginData.apiurl + "/states/change/restart.json?"+$rootScope.authSession; - var apiMon = loginData.apiurl + "/monitors/" + item + ".json?"+$rootScope.authSession; - NVR.debug("MonitorCtrl: URLs for changeConfig save:" + apiMon); + var isEnabled = ""; + isEnabled = ($scope.monfunc.myenabled == true) ? '1' : '0'; + var loginData = NVR.getLogin(); - var isEnabled = ""; - isEnabled = ($scope.monfunc.myenabled == true) ? '1' : '0'; + $scope.monfunc.mymonitorsIds.forEach(function (item, index) { + var apiMon = loginData.apiurl + "/monitors/" + item + ".json?"+$rootScope.authSession; + NVR.debug("MonitorCtrl: URLs for changeConfig save:" + apiMon); + + var data = {}; + if ($scope.monfunc.myfunc) data['Monitor[Function]'] = $scope.monfunc.myfunc; + if (isEnabled) data['Monitor[Enabled]'] = isEnabled; $ionicLoading.show({ template: $translate.instant('kApplyingChanges') + "...", @@ -177,14 +180,10 @@ angular.module('zmApp.controllers') str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); var foo = str.join("&"); - // console.log("****RETURNING " + foo); NVR.debug("MonitorCtrl: parmeters constructed: " + foo); return foo; }, - data: { - 'Monitor[Function]': $scope.monfunc.myfunc, - 'Monitor[Enabled]': isEnabled, - } + data: data }) .then(function () { @@ -208,28 +207,10 @@ angular.module('zmApp.controllers') duration: 3000, }); } else { - // I am not restarting ZM after monitor change - /* NVR.debug ("MonitorCtrl: Restarting ZM"); - $ionicLoading.show({ - template: "Successfully changed Monitor. Please wait, restarting ZoneMinder...", - noBackdrop: true, - duration: zm.largeHttpTimeout, - }); - $http.post(apiRestart) - .then(function (success) { - $ionicLoading.hide(); - var refresh = NVR.getMonitors(1); - refresh.then(function (data) { - $scope.monitors = data; - $scope.$broadcast('scroll.refreshComplete'); - }); - - }, - function (error) { - $ionicLoading.hide(); - - });*/ - doRefresh(); + + doRefresh(); + + } }) .catch (noop); @@ -274,6 +255,7 @@ angular.module('zmApp.controllers') }); $scope.$on('$ionicView.enter', function () { // console.log("**VIEW ** Monitor Ctrl Entered"); + NVR.setAwake(false); $ionicSideMenuDelegate.canDragContent(true); $scope.areImagesLoading = true; @@ -305,7 +287,9 @@ angular.module('zmApp.controllers') $rootScope.tappedMid = 0; var monitem; - NVR.getMonitors(0) + NVR.flushAPICache() + .then (function () { + NVR.getMonitors(1) .then ( function (data) { $scope.monitors = data; for (var m = 0; m < $scope.monitors.length; m++) { @@ -316,6 +300,8 @@ angular.module('zmApp.controllers') } openModal(monitem.Monitor.Id, monitem.Monitor.Controllable, monitem.Monitor.ControlId, monitem.Monitor.connKey, monitem); }); + }); + @@ -529,7 +515,9 @@ angular.module('zmApp.controllers') } function doRefresh() { - $scope.monitors = []; + NVR.flushAPICache() + .then (function () { + $scope.monitors = []; var refresh = NVR.getMonitors(1); @@ -538,6 +526,8 @@ angular.module('zmApp.controllers') monitorStateCheck(); $scope.$broadcast('scroll.refreshComplete'); }); + }); + } $scope.doRefresh = function () { diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index 3dde1f75..6a62a389 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -36,6 +36,7 @@ "kButtonYes" :"Yes", "kCalcEventSize" :"calculating events size", "kCancellingAlarm" :"cancelling alarm", + "kChangeMode" :"Change Mode", "kChangeSettingsFor" :"Change settings for", "kChangeState" :"Change State", "kCheckCredentials" :"Please check your credentials", @@ -147,6 +148,7 @@ "kFrom" :"From", "kFromDate" :"From Date", "kFromTime" :"From Time", + "kFunction" :"Function", "kGifNoCrosswalk" :"Sorry, you need to be on Android 5.0 (Lollipop) or above for this feature to work.", "kGifWarning" :"The GIF animation will only be of alarmed frames and 1fps", "kGlobalConfiguration" :"Global Configuration", @@ -253,6 +255,7 @@ "kMontageShowSidebarsNote" :"for monitors with unseen events", "kMonth" :"Month", "kMore" :"more", + "kMotionEnabled" :"motion detection", "kNeedToKnow" :"I need to know your ZoneMinder login and path details to get started", "kNegotiatingStreamAuth" :"negotiating stream authentication", "kNewPost" :"new post", diff --git a/www/templates/monitors.html b/www/templates/monitors.html index 691a6844..6d7651ca 100644 --- a/www/templates/monitors.html +++ b/www/templates/monitors.html @@ -9,7 +9,7 @@
- {{'kGlobalConfiguration' + {{'kGlobalConfiguration' | translate}}

-- cgit v1.2.3