summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/EventModalCtrl.js15
-rw-r--r--www/js/MonitorCtrl.js192
-rw-r--r--www/js/NVR.js7
3 files changed, 150 insertions, 64 deletions
diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js
index 351253c8..c62c2cf6 100644
--- a/www/js/EventModalCtrl.js
+++ b/www/js/EventModalCtrl.js
@@ -35,6 +35,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
var playState = 'play';
var isSeeking = false;
$scope.useFilters = true;
+
var broadcastHandles = [];
@@ -2136,7 +2137,19 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
}
- $scope.defaultVideo = event.Event.DefaultVideo;
+
+
+ var ld = NVR.getLogin();
+ if (ld.monitorSpecific[event.Event.MonitorId] &&
+ ld.monitorSpecific[event.Event.MonitorId].forceMjpeg) {
+ NVR.debug ('Monitor:'+event.Event.MonitorId+' has forced MJPEG playback');
+ $scope.defaultVideo ='';
+ } else {
+
+ $scope.defaultVideo = event.Event.DefaultVideo;
+ }
+
+
$scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js
index 1cd695b7..637998df 100644
--- a/www/js/MonitorCtrl.js
+++ b/www/js/MonitorCtrl.js
@@ -78,20 +78,33 @@ angular.module('zmApp.controllers')
// This function takes care of changing monitor parameters
// For now, I've only limited it to enable/disable and change monitor mode
// and changing monitor function
+ // if it's 'All' then rest are empty
//-----------------------------------------------------------------------
- $scope.changeConfig = function (monitorName, monitorId, enabled, func) {
+ $scope.changeConfig = function (monitorName, monitorId, enabled, func, mon_forceMjpeg) {
var checked = false;
+ var i;
+
+
+
+ $scope.forceMjpeg = {
+ value:false
+ };
+ if (!mon_forceMjpeg) $scope.forceMjpeg.value = true; // true if all monitors passed
var monitorsIds = [];
if (monitorName == 'All') {
monitorName = $translate.instant('kAll');
// in all monitors, lets keep enabled on
enabled = '1';
- for (var i = 0; i < $scope.monitors.length; i++) {
+
+ for (i = 0; i < $scope.monitors.length; i++) {
+ // console.log ("HUH "+$scope.monitors[i].Monitor.forceMjpeg);
monitorsIds[i] = $scope.monitors[i].Monitor.Id;
+ if (!$scope.monitors[i].Monitor.forceMjpeg) $scope.forceMjpeg.value = false; // if any is unset, global is unset
}
} else {
monitorsIds[0] = monitorId;
+ $scope.forceMjpeg.value = mon_forceMjpeg;
}
//console.log("called with " + monitorId + ":" + enabled + ":" + func);
@@ -133,11 +146,24 @@ angular.module('zmApp.controllers')
mypromises: []
};
+
+ var oldValues = {
+ myfunc: func,
+ myenabled: checked,
+ forceMjpeg: $scope.forceMjpeg.value
+ };
+
//console.log (JSON.stringify($scope.monfunc));
$rootScope.zmPopup = $ionicPopup.show({
scope: $scope,
cssClass:'widepopup',
- template: '<ion-toggle ng-model="monfunc.myenabled" toggle-class="toggle-calm">'+$translate.instant('kMotionEnabled')+'</ion-toggle><div class="item item-divider" style="background:#666666;color:white;">'+$translate.instant('kChangeMode')+'</div><ion-radio-fix ng-repeat="item in monFunctions" ng-value="item.value" ng-model="monfunc.myfunc"> {{item.text}} </ion-radio-fix>',
+ template: '<ion-toggle ng-model="monfunc.myenabled" toggle-class="toggle-calm">'
+ +$translate.instant('kMotionEnabled')+'</ion-toggle>'
+ +'<ion-toggle ng-model="forceMjpeg.value" toggle-class="toggle-calm">'
+ +$translate.instant('kForceMjpeg')+'</ion-toggle>'+
+ '<div class="item item-divider" style="background:#666666;color:white;">'
+ +$translate.instant('kChangeMode')
+ +'</div><ion-radio-fix ng-repeat="item in monFunctions" ng-value="item.value" ng-model="monfunc.myfunc"> {{item.text}} </ion-radio-fix>',
title: $translate.instant('kChangeSettingsFor') + ' ' + monitorName,
@@ -154,66 +180,93 @@ angular.module('zmApp.controllers')
var loginData = NVR.getLogin();
$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') + "...",
- noBackdrop: true,
- duration: zm.largeHttpTimeout,
- });
-
- var httpPromise = $http({
- url: apiMon,
- method: 'post',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Accept': '*/*',
- },
- transformRequest: function (obj) {
- var str = [];
- for (var p in obj)
- str.push(encodeURIComponent(p) + "=" +
- encodeURIComponent(obj[p]));
- var foo = str.join("&");
- NVR.debug("MonitorCtrl: parmeters constructed: " + foo);
- return foo;
- },
- data: data
-
- })
- .then(function () {
- NVR.debug("MonitorCtrl: Not restarting ZM - Make sure you have the patch installed in MonitorsController.php or this won't work");
- },
- function (data, status, headers, config) {
- NVR.debug("MonitorCtrl: Error changing monitor " + JSON.stringify(data));
- $scope.monfunc.myfailedIds.push(item);
- });
+ if (!loginData.monitorSpecific[item]) loginData.monitorSpecific[item] = {};
+ loginData.monitorSpecific[item].forceMjpeg = $scope.forceMjpeg.value;
- $scope.monfunc.mypromises.push(httpPromise);
- });
+ for (var m=0; m < $scope.monitors.length; m++) {
+ if ($scope.monitors[m].Monitor.Id == item) {
+ $scope.monitors[m].Monitor.forceMjpeg = $scope.forceMjpeg.value;
+ break;
+ }
+ }
- $q.all($scope.monfunc.mypromises).then(function (e) {
- $ionicLoading.hide();
- // if there's a failed ID, an error has occurred
- if ($scope.monfunc.myfailedIds.length != 0) {
+
+
+ if (oldValues.myfunc != $scope.monfunc.myfunc || oldValues.myenabled != isEnabled) {
+ // lets do HTTP requests only if stuff changes
+ 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('kErrorChangingMonitors') + ". Monitor IDs : " + $scope.monfunc.myfailedIds.toString(),
+ template: $translate.instant('kApplyingChanges') + "...",
noBackdrop: true,
- duration: 3000,
+ duration: zm.largeHttpTimeout,
});
- } else {
-
- doRefresh();
-
+
+ var httpPromise = $http({
+ url: apiMon,
+ method: 'post',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Accept': '*/*',
+ },
+ transformRequest: function (obj) {
+ var str = [];
+ for (var p in obj)
+ str.push(encodeURIComponent(p) + "=" +
+ encodeURIComponent(obj[p]));
+ var foo = str.join("&");
+ NVR.debug("MonitorCtrl: parmeters constructed: " + foo);
+ return foo;
+ },
+ data: data
+
+ })
+ .then(function () {
+ NVR.debug("MonitorCtrl: Not restarting ZM - Make sure you have the patch installed in MonitorsController.php or this won't work");
+ },
+ function (data, status, headers, config) {
+ NVR.debug("MonitorCtrl: Error changing monitor " + JSON.stringify(data));
+ $scope.monfunc.myfailedIds.push(item);
+ });
+
+ $scope.monfunc.mypromises.push(httpPromise);
+
+ } else {
+ NVR.debug ('Not invoing HTTP requests and no functional state changes detected');
+ }
+
+
+ }); //foreach
+
+ NVR.debug ('Updating forcedMjpeg status');
+ NVR.setLogin(loginData);
+
+ if ($scope.monfunc.mypromises.length) {
+ $q.all($scope.monfunc.mypromises).then(function (e) {
+ $ionicLoading.hide();
+ // if there's a failed ID, an error has occurred
+ if ($scope.monfunc.myfailedIds.length != 0) {
+ $ionicLoading.show({
+ template: $translate.instant('kErrorChangingMonitors') + ". Monitor IDs : " + $scope.monfunc.myfailedIds.toString(),
+ noBackdrop: true,
+ duration: 3000,
+ });
+ } else {
- }
- })
- .catch (noop);
+ doRefresh();
+
+
+ }
+ })
+ .catch (noop);
+
+ }
+
}
},
@@ -232,6 +285,17 @@ angular.module('zmApp.controllers')
// console.log("**VIEW ** Monitor Ctrl Loaded");
});
+
+ $scope.changeForceMjpeg = function (mid, value) {
+ NVR.debug ("change forceMjpeg for mid:"+mid+" to "+value);
+ var ld = NVR.getLogin();
+ if (!ld.monitorSpecific[mid]) ld.monitorSpecific[mid] = {};
+ ld.monitorSpecific[mid].forceMjpeg = value;
+ console.log ("UPDATE array:"+JSON.stringify(ld.monitorSpecific));
+ NVR.setLogin(ld);
+
+ };
+
//-------------------------------------------------------------------------
// Lets make sure we set screen dim properly as we enter
// The problem is we enter other states before we leave previous states
@@ -309,11 +373,7 @@ angular.module('zmApp.controllers')
});
- $scope.$on('$ionicView.leave', function () {
- // console.log("**VIEW ** Monitor Ctrl Left, force removing modal");
- if ($scope.modal) $scope.modal.remove();
- });
-
+
$scope.$on('$ionicView.unloaded', function () {
// console.log("**VIEW ** Monitor Ctrl Unloaded");
});
@@ -414,6 +474,14 @@ angular.module('zmApp.controllers')
if (!$scope.monitors.length) {
$scope.monitorLoadStatus = $translate.instant ('kNoMonitors');
+ } else {
+ var mid;
+ for (var i=0; i < $scope.monitors.length; i++) {
+ mid = $scope.monitors[i].Monitor.Id;
+ $scope.monitors[i].Monitor.forceMjpeg = (ld.monitorSpecific[mid] && ld.monitorSpecific[mid].forceMjpeg) ? true:false;
+ // console.log ('********** Monitor :'+mid+" MJPEG="+$scope.monitors[i].Monitor.forceMjpeg );
+
+ }
}
if (!$scope.monitors[0].Monitor_Status ) {
diff --git a/www/js/NVR.js b/www/js/NVR.js
index 2278ad54..196fe66e 100644
--- a/www/js/NVR.js
+++ b/www/js/NVR.js
@@ -227,7 +227,8 @@ angular.module('zmApp.controllers')
'montageHideFooter': false,
'httpCordovaNoEncode': false,
'currentZMGroupNames': [],
- 'unsupported': {}
+ 'unsupported': {},
+ 'monitorSpecific': {}
};
@@ -1762,6 +1763,10 @@ angular.module('zmApp.controllers')
if (typeof loginData.unsupported == 'undefined') {
loginData.unsupported = {};
}
+
+ if (typeof loginData.monitorSpecific == 'undefined') {
+ loginData.monitorSpecific = {};
+ }