Skip to content

Commit

Permalink
#319 - you can now cycle monitors. Time Interval can be specified in …
Browse files Browse the repository at this point in the history
…developer settings.
  • Loading branch information
pliablepixels committed Sep 4, 2016
1 parent cbb05e1 commit 65cc025
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 4 deletions.
16 changes: 15 additions & 1 deletion www/js/DataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ angular.module('zmApp.controllers')
'forceImageModePath': false,
'disableNative': false,
'vibrateOnPush': true,
'soundOnPush': true
'soundOnPush': true,
'cycleMonitors': false,
'cycleMonitorsInterval':10, // 10sec



Expand Down Expand Up @@ -673,6 +675,18 @@ angular.module('zmApp.controllers')
loginData.soundOnPush = true;

}

if (typeof loginData.cycleMonitors == 'undefined') {

loginData.cycleMonitors = false;

}

if (typeof loginData.cycleMonitorsInterval == 'undefined') {

loginData.cycleMonitorsInterval = 10;

}


log("DataModel init recovered this loginData as " + JSON.stringify(loginData));
Expand Down
5 changes: 4 additions & 1 deletion www/js/DevOptionsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope'
NVRDataModel.debug("SaveDevOptions: called");



if (parseInt($scope.loginData.cycleMonitorsInterval) < zm.minCycleTime)
{
$scope.loginData.cycleMonitorsInterval = zm.minCycleTime.toString();
}
if ((parseInt($scope.loginData.maxFPS) < 0) || (parseInt($scope.loginData.maxFPS) > zm.maxFPS)) {
$scope.loginData.maxFPS = zm.defaultFPS.toString();
}
Expand Down
64 changes: 64 additions & 0 deletions www/js/MonitorModalCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
$scope.imageFit = true;
$scope.isModalActive = true;
var intervalModalHandle;
var cycleHandle;
var nphTimer;
var ld = NVRDataModel.getLogin();

Expand Down Expand Up @@ -54,6 +55,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$


$interval.cancel(intervalModalHandle);
$interval.cancel(cycleHandle);

intervalModalHandle = $interval(function () {
loadModalNotifications();
Expand Down Expand Up @@ -247,6 +249,34 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
// console.log ("ERROR");
});
};


$scope.toggleCycle = function()
{
//console.log ("HERE");
$scope.isCycle = !$scope.isCycle;
var ld = NVRDataModel.getLogin();
ld.cycleMonitors = $scope.isCycle;
NVRDataModel.setLogin(ld);
$scope.cycleText = $scope.isCycle ? $translate.instant ('kOn'):$translate.instant ('kOff');

if ($scope.isCycle)
{
NVRDataModel.log ("re-starting cycle timer");
$interval.cancel(cycleHandle);

cycleHandle = $interval(function () {
moveToMonitor($scope.monitorId,1);
// console.log ("Refreshing Image...");
}.bind(this), ld.cycleMonitorsInterval * 1000);
}
else
{
NVRDataModel.log ("cancelling cycle timer");
$interval.cancel(cycleHandle);
}

};

//-------------------------------------------------------------
// PTZ enable/disable
Expand Down Expand Up @@ -282,6 +312,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
function onPause() {
NVRDataModel.debug("ModalCtrl: onpause called");
$interval.cancel(intervalModalHandle);
$interval.cancel(cycleHandle);
// $interval.cancel(modalIntervalHandle);

// FIXME: Do I need to setAwake(false) here?
Expand All @@ -294,12 +325,26 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
NVRDataModel.log("ModalCtrl: Restarting Modal timer on resume");

$interval.cancel(intervalModalHandle);
$interval.cancel(cycleHandle);

var ld = NVRDataModel.getLogin();

intervalModalHandle = $interval(function () {
loadModalNotifications();
}.bind(this), 5000);

if (ld.cycleMonitors)
{
NVRDataModel.debug ("Cycling enabled at "+ld.cycleMonitorsInterval);

$interval.cancel(cycleHandle);

cycleHandle = $interval(function () {
moveToMonitor($scope.monitorId,1);
// console.log ("Refreshing Image...");
}.bind(this), ld.cycleMonitorsInterval * 1000);

}

$rootScope.modalRand = Math.floor((Math.random() * 100000) + 1);

Expand Down Expand Up @@ -858,6 +903,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
// console.log("**MODAL: Stopping modal timer");
$scope.isModalActive = false;
$interval.cancel(intervalModalHandle);
$interval.cancel(cycleHandle);
});


Expand All @@ -880,13 +926,15 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
$scope.isModalActive = false;

$interval.cancel(intervalModalHandle);
$interval.cance(cycleHandle);

});

$scope.$on('modal.removed', function () {
$scope.isModalActive = false;
//console.log("**MODAL REMOVED: Stopping modal timer");
$interval.cancel(intervalModalHandle);
$interval.cancel(cycleHandle);

NVRDataModel.debug("Modal removed - killing connkey");
controlStream(17, "", $scope.connKey, -1);
Expand Down Expand Up @@ -1228,8 +1276,24 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
//console.log ("************* GENERATED CONNKEY " + $scope.connKey);
$scope.currentFrame = 1;
$scope.monStatus = "";
$scope.isCycle = ld.cycleMonitors;
$scope.cycleText = $scope.isCycle ? $translate.instant ('kOn'):$translate.instant ('kOff');

configurePTZ($scope.monitorId);

if (ld.cycleMonitors)
{
NVRDataModel.debug ("Cycling enabled at "+ld.cycleMonitorsInterval);

$interval.cancel(cycleHandle);

cycleHandle = $interval(function () {
moveToMonitor($scope.monitorId,1);
// console.log ("Refreshing Image...");
}.bind(this), ld.cycleMonitorsInterval * 1000);

}


});

Expand Down
3 changes: 2 additions & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ angular.module('zmApp', [
eventPlaybackQuery: 3000,
packeryTimer: 500,
dbName: 'zmninja',
cipherKey: 'sdf#@#%FSXSA_AR'
cipherKey: 'sdf#@#%FSXSA_AR',
minCycleTime: 5,


})
Expand Down
2 changes: 2 additions & 0 deletions www/lang/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"kCredentialsTitle" :"Credentials Required",
"kCurrentState" :"current state",
"kCustomRange" :"Custom Range",
"kCycleMonitorsInterval" :"monitor cycle interval",
"kCycleMonitors" :"cycle monitors",
"kDay" :"Day",
"kDecreaseSize" :"decrease size",
"kDelete" :"Delete",
Expand Down
10 changes: 9 additions & 1 deletion www/templates/devoptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@
</div>

<label>

<ion-toggle ng-model="loginData.enableLogs" ng-checked="{{loginData.enableLogs}}" toggle-class="toggle-calm">{{'kEnableLogs' | translate}}</ion-toggle>
</label>



<div class="item item-input-inset" >
{{'kCycleMonitorsInterval'|translate}}(s)&nbsp;
<label class="item-input-wrapper">
<input type="tel" placeholder="" ng-model="loginData.cycleMonitorsInterval">
</label>
</div>

<label>

Expand Down
7 changes: 7 additions & 0 deletions www/templates/monitors-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
</li>
<li>
<a href="" ng-click="enableAlarm(monitorId,false)"> <i class="icon ion-flash-off"></i></a>


</li>
<li>
<a href="" ng-click="toggleCycle()"> <i class="icon ion-android-bicycle"></i>-{{cycleText}}</a>


</li>

<!--
Expand Down

0 comments on commit 65cc025

Please sign in to comment.