summaryrefslogtreecommitdiff
path: root/www/js/MontageCtrl.js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2018-04-08 20:29:20 -0400
committerPliable Pixels <pliablepixels@gmail.com>2018-04-08 20:29:20 -0400
commite5cc1c5826f65b5d40892cd92714cc9f070198a9 (patch)
tree8384bbb90d81808e0dca96bee889dd38eb158b43 /www/js/MontageCtrl.js
parenta9273df91eced721b23f311e37b8d820f5951ada (diff)
broadcast handler cleanups and others
Diffstat (limited to 'www/js/MontageCtrl.js')
-rw-r--r--www/js/MontageCtrl.js31
1 files changed, 26 insertions, 5 deletions
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index 3d1a211c..9cf5e77d 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -32,13 +32,16 @@ angular.module('zmApp.controllers')
var simulStreaming = 0; // will be 1 if you multiport
+ var broadcastHandles = [];
- $rootScope.$on("auth-success", function () {
- NVRDataModel.debug("Montage Re-auth handler; stopping network...");
+
+ var as = $rootScope.$on("auth-success", function () {
+ NVRDataModel.debug("Montage Re-auth handler");
//console.log ("RETAUTH");
// NVRDataModel.stopNetwork();
});
+ broadcastHandles.push(as);
//--------------------------------------------------------------------------------------
@@ -46,7 +49,7 @@ angular.module('zmApp.controllers')
//
//--------------------------------------------------------------------------------------
- $rootScope.$on("bandwidth-change", function(e, data)
+ var bc = $rootScope.$on("bandwidth-change", function(e, data)
{
// not called for offline, I'm only interested in BW switches
NVRDataModel.debug("Got network change:" + data);
@@ -93,6 +96,8 @@ angular.module('zmApp.controllers')
}
});
+ broadcastHandles.push(bc);
+
// --------------------------------------------------------
// Handling of back button in case modal is open should
// close the modal
@@ -768,7 +773,7 @@ angular.module('zmApp.controllers')
//----------------------------------------------------------------
// Alarm emit handling
//----------------------------------------------------------------
- $rootScope.$on("alarm", function(event, args)
+ var al = $rootScope.$on("alarm", function(event, args)
{
// FIXME: I should probably unregister this instead
if (typeof $scope.monitors === undefined)
@@ -793,6 +798,8 @@ angular.module('zmApp.controllers')
});
+ broadcastHandles.push(al);
+
function scheduleRemoveFlash(id)
{
NVRDataModel.debug("Scheduled a " + zm.alarmFlashTimer + "ms timer for dis-alarming monitor ID:" + $scope.MontageMonitors[id].Monitor.Id);
@@ -1295,11 +1302,18 @@ angular.module('zmApp.controllers')
$interval.cancel(intervalHandleAlarmStatus);
$interval.cancel(intervalHandleReloadPage);
+ NVRDataModel.debug ("Deregistering broadcast handles");
+ for (var i=0; i < broadcastHandles.length; i++) {
+ broadcastHandles[i]();
+ }
+ broadcastHandles = [];
+
+
// if modal is open stream gets killed
// inside monitorModal
if (!$scope.singleMonitorModalOpen && simulStreaming=='1') {
NVRDataModel.debug ("Killing all streams in montage to save memory/nw...");
- for (var i=0; i < $scope.MontageMonitors.length; i++) {
+ for (i=0; i < $scope.MontageMonitors.length; i++) {
NVRDataModel.killStream($scope.MontageMonitors[i].Monitor.connKey);
}
}
@@ -1927,6 +1941,13 @@ angular.module('zmApp.controllers')
$scope.$on('$ionicView.beforeLeave', function()
{
+
+ NVRDataModel.debug ("Deregistering broadcast handles");
+ for (var i=0; i < broadcastHandles.length; i++) {
+ broadcastHandles[i]();
+ }
+ broadcastHandles = [];
+
// console.log("**VIEW ** Montage Ctrl Left, force removing modal");
//console.log ("beforeLeave:Cancelling timer");