summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/LoginCtrl.js5
-rw-r--r--www/js/MenuController.js7
-rw-r--r--www/js/MontageCtrl.js85
-rw-r--r--www/js/MontageHistoryCtrl.js2
-rw-r--r--www/js/NVR.js35
-rwxr-xr-xwww/js/app.js6
6 files changed, 60 insertions, 80 deletions
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index ba782bb2..55d384e2 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -402,10 +402,11 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
$scope.kioskPinConfig = function () {
- $scope.data = {};
+ var ld = NVR.getLogin();
+ $scope.data = {p1:ld.kioskPassword};
// An elaborate, custom popup
var myPopup = $ionicPopup.show({
- template: '<small>'+$translate.instant('kKioskPassword')+'</small><input type="password" ng-model="data.p1"><br/><small>'+$translate.instant('kKioskPasswordConfirm')+'</small><input type="password" ng-model="data.p2">',
+ template: '<small>'+$translate.instant('kKioskPassword')+'</small><input type="password" ng-model="data.p1"><br/><small>'+$translate.instant('kKioskPasswordConfirm')+'</small><input type="password" ng-model="data.p2">',
title: $translate.instant('kPassword'),
scope: $scope,
buttons: [
diff --git a/www/js/MenuController.js b/www/js/MenuController.js
index 511ba030..8496acff 100644
--- a/www/js/MenuController.js
+++ b/www/js/MenuController.js
@@ -2,7 +2,7 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */
-angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVR', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location', 'EventServer', 'zmAutoLogin', '$http', 'SecuredPopups', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVR, $rootScope, $ionicPopup, $translate, $timeout, $location, EventServer, zmAutoLogin, $http, SecuredPopups) {
+angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVR', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location', 'EventServer', 'zmAutoLogin', '$http', 'SecuredPopups', '$ionicLoading', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVR, $rootScope, $ionicPopup, $translate, $timeout, $location, EventServer, zmAutoLogin, $http, SecuredPopups, $ionicLoading) {
$scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
};
@@ -38,7 +38,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
window.stop();
// after window stop executes, in next cycle
// this _should_ ensure stop concludes before
- // exit/entry lifecycles kick in?
+ // exit/entry lifecycles kick in?z
+
$timeout (function() {$state.go(view,args);});
});*/
@@ -56,7 +57,7 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
{ text: $translate.instant('kButtonCancel'),
type: 'button-assertive',
onTap: function (e) {
-
+ $ionicSideMenuDelegate.toggleLeft();
}
},
{
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index 60b49541..e5274b81 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -18,6 +18,7 @@ angular.module('zmApp.controllers')
var intervalHandleReloadPage;
var intervalHandleEventStatus;
+
var gridcontainer;
var pckry, draggie;
var draggies;
@@ -58,59 +59,6 @@ angular.module('zmApp.controllers')
NVR.debug ("Auth success, recomputing rand value...");
randEachTime();
- /* var tnow = new Date();
- var s = Math.round((tnow - timeInMontage) / 1000);
- NVR.debug ("Montage re-auth: time since we are here: " + s +
- " seconds");
- if (s >= 20) {// lets not regen connkey if we just got into montage
- NVR.debug ("Montage-reauth: Regenerating connkeys");
- $timeout(function () { // after render
- if (simulStreaming) {
- NVR.debug("Re-creating all stream connkeys in montage ...");
- NVR.regenConnKeys();
- $scope.monitors = NVR.getMonitorsNow();
- $scope.MontageMonitors = angular.copy($scope.monitors);
- $timeout(function () // after render
- {
- initPackery();
- }, zm.packeryTimer);
-
-
- }
- });
- }
- else {
- NVR.debug ("Montage re-auth: ignoring as time is only "+s+" seconds");
- }*/
- // do nothing, we are reloading here anyway?
- /*
- if ($scope.singleMonitorModalOpen) {
- NVR.debug("Montage: Not creating streams, as modal is open");
- return;
- }
-
-
- NVR.debug("Montage Re-auth handler");
-
- //streamState = true;
-
- $timeout(function () { // after render
- if (simulStreaming) {
- NVR.debug("Re-creating all stream connkeys in montage ...");
- NVR.regenConnKeys();
- $scope.monitors = NVR.getMonitorsNow();
- $scope.MontageMonitors = angular.copy($scope.monitors);
- $timeout(function () // after render
- {
- initPackery();
- }, zm.packeryTimer);
-
-
- }
- });
- broadcastHandles.push(as);
- //console.log (">>>>>>>>>>>>>>>>>>>>>>>>>>>AS="+as);
- */
});
//--------------------------------------------------------------------------------------
@@ -860,10 +808,10 @@ angular.module('zmApp.controllers')
} // before reorder array
} // montage monitors
- console.log ("AFTER REORDER="+JSON.stringify(beforeReorderPositions));
+ // console.log ("AFTER REORDER="+JSON.stringify(beforeReorderPositions));
for (var n = 0; i < $scope.MontageMonitors.length; i++) {
- $scope.MontageMonitors[n].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ $scope.MontageMonitors[n].Monitor.connKey = NVR.regenConnKeys($scope.MontageMonitors[i]);
}
var ld = NVR.getLogin();
@@ -1469,9 +1417,7 @@ angular.module('zmApp.controllers')
for (var i = 0; i < $scope.MontageMonitors.length; i++) {
if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVR.resumeLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL, $scope.MontageMonitors[i].Monitor.Name);
}
- /* NVR.regenConnKeys();
- $scope.monitors = NVR.getMonitorsNow();
- $scope.MontageMonitors = angular.copy($scope.monitors);*/
+
}
@@ -1916,16 +1862,26 @@ angular.module('zmApp.controllers')
function getMode() {
var mode = (simulStreaming && currentStreamState != streamState.SNAPSHOT && currentStreamState != streamState.STOPPED) ? 'jpeg' : 'single';
- //console.log ("mode="+mode);
+ //console.log ("mode="+mode);
return mode;
}
$scope.processImageError = function(monitor) {
- // NVR.debug ("Image load error for: "+monitor.Monitor.Id+" regenerated connKey is:"+monitor.Monitor.connKey);
- //if (1) return; // REMOVE
- monitor.Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
- NVR.debug ("Image load error for: "+monitor.Monitor.Id+" regenerated connKey is:"+monitor.Monitor.connKey);
+
+ var mintimesec = 10;
+ var nowt = moment();
+ var thent = monitor.Monitor.regenTime || moment();
+ if (nowt.diff(thent, 'seconds') >=mintimesec) {
+ NVR.regenConnKeys(monitor);
+ NVR.debug ("Image load error for: "+monitor.Monitor.Id+" regenerated connKey is:"+monitor.Monitor.connKey);
+ } else {
+ dur = mintimesec - nowt.diff(thent, 'seconds');
+ NVR.debug ("Image load error for Monitor: "+monitor.Monitor.Id+" scheduling for connkey regen in "+dur+"s");
+ monitor.Monitor.regenHandle = $timeout ( function() {NVR.regenConnKeys(monitor);}, dur*1000 );
+ }
+
+
};
@@ -2148,8 +2104,7 @@ angular.module('zmApp.controllers')
broadcastHandles = [];
randToAvoidCacheMem = new Date().getTime();
currentStreamState = streamState.SNAPSHOT;
- // NVR.regenConnKeys();
- $scope.monitors = NVR.getMonitorsNow();
+ $scope.monitors = NVR.getMonitorsNow();
//console.log ("MONITORS:"+JSON.stringify($scope.monitors));
diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js
index 6b528ce8..ef3e07e3 100644
--- a/www/js/MontageHistoryCtrl.js
+++ b/www/js/MontageHistoryCtrl.js
@@ -237,8 +237,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc
NVR.debug(">>Initializing monitor array with history specific stuff...");
for (i = 0; i < $scope.MontageMonitors.length; i++) {
- //$scope.MontageMonitors[i].Monitor.connKey='';
- //$scope.MontageMonitors[i].Monitor.connKey = (Math.floor((Math.random() * 99999) + 1)).toString();
$scope.MontageMonitors[i].Monitor.eventUrl = 'img/noimage.png';
$scope.MontageMonitors[i].Monitor.eventType = "";
$scope.MontageMonitors[i].Monitor.eid = "-1";
diff --git a/www/js/NVR.js b/www/js/NVR.js
index d9991b38..be2265ff 100644
--- a/www/js/NVR.js
+++ b/www/js/NVR.js
@@ -1465,6 +1465,33 @@ angular.module('zmApp.controllers')
}
+ function regenConnKeys (mon) {
+ var nowt = moment();
+ if (mon) {
+ debug ("NVR: Regnerating connkey for Monitor:"+mon.Monitor.Id + " at "+nowt);
+ mon.Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ mon.Monitor.regenTime = nowt;
+ if (mon.Monitor.regenHandle) {
+ //debug ("cancelling regen timer for Monitor:"+mon.Monitor.Id);
+ $timeout.cancel(mon.Monitor.regenHandle);
+ mon.Monitor.regenHandle = null;
+ }
+
+ } else {
+ debug("NVR: Regenerating connkeys for all monitors at "+nowt);
+ for (var i = 0; i < monitors.length; i++) {
+ monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString();
+ monitors[i].Monitor.regenTime = nowt;
+ if (monitors[i].Monitor.regenHandle) {
+ $timeout.cancel(monitors[i].Monitor.regenHandle);
+ monitors[i].Monitor.regenHandle = null;
+ }
+ }
+
+ }
+ }
+
//--------------------------------------------------------------------------
// Banner display of messages
//--------------------------------------------------------------------------
@@ -2540,13 +2567,9 @@ angular.module('zmApp.controllers')
},
- regenConnKeys: function () {
+ regenConnKeys: function (mon) {
- debug("NVR: Regenerating connkeys...");
- for (var i = 0; i < monitors.length; i++) {
- monitors[i].Monitor.connKey = (Math.floor((Math.random() * 999999) + 1)).toString();
- monitors[i].Monitor.rndKey = (Math.floor((Math.random() * 999999) + 1)).toString();
- }
+ return regenConnKeys (mon);
},
getMonitors: function (forceReload) {
diff --git a/www/js/app.js b/www/js/app.js
index 08331872..89944da6 100755
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -1584,11 +1584,13 @@ angular.module('zmApp', [
}
if (requireLogin) {
+
+ NVR.displayBanner('error', [$translate.instant('kCredentialsBody')]);
- $ionicPopup.alert({
+ /* $ionicPopup.alert({
title: $translate.instant('kCredentialsTitle'),
template: $translate.instant('kCredentialsBody')
- });
+ });*/
// for whatever reason, .go was resulting in digest loops.
// if you don't prevent, states will stack
event.preventDefault();