From 14810e783f49d7bd01e7c66d841fc663bde414aa Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 18 Apr 2018 10:42:28 -0400 Subject: #606 montage history cleanups and url cleanups --- www/js/MontageHistoryCtrl.js | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'www/js') diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js index 235e0c11..acf02d1b 100644 --- a/www/js/MontageHistoryCtrl.js +++ b/www/js/MontageHistoryCtrl.js @@ -7,7 +7,9 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc { var broadcastHandles = []; var isSimulStreaming = false; + $scope.isSimulStreaming = isSimulStreaming; var areStreamsStopped = false; + var viewCleaned = false; //-------------------------------------------------------------------------------------- // Handles bandwidth change, if required // @@ -895,10 +897,33 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc function onPause() { NVRDataModel.debug("MontageHistoryCtrl: onpause called"); - $interval.cancel($rootScope.eventQueryInterval); - $interval.cancel(intervalHandle); - // $interval.cancel(modalIntervalHandle); - // FIXME: Do I need to setAwake(false) here? + viewCleanup(); + viewCleaned = true; + } + + function viewCleanup() { + + if (viewCleaned) { + NVRDataModel.debug("Montage History View Cleanup was already done, skipping"); + return; + } + $interval.cancel(eventQueryHandle); + if (pckry) pckry.destroy(); + + + broadcastHandles = []; + + areStreamsStopped = true; + + $timeout(function () { + + NVRDataModel.debug("Killing all streams in montage to save memory/nw..."); + for (i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show') NVRDataModel.killLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL); + + } + + }); } function onResume() @@ -939,7 +964,10 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.$on('$ionicView.beforeLeave', function() { //console.log("**VIEW ** Event History Ctrl Left, force removing modal"); - + areStreamsStopped = true; + viewCleanup(); + viewCleaned = true; + // if ($scope.modal) $scope.modal.remove(); NVRDataModel.log("Cancelling event query timer"); @@ -1206,6 +1234,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc isSimulStreaming = false; NVRDataModel.log ("IOS detected, disabling simulstreaming"); } + $scope.isSimulStreaming = isSimulStreaming; areStreamsStopped = true; NVRDataModel.regenConnKeys(); @@ -1374,8 +1403,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc stream = monitor.Monitor.eventUrl + $rootScope.authSession + appendConnKey(monitor.Monitor.connKey); - console.log (JSON.stringify(monitor)); - console.log("STREAM=" + stream); + //console.log (JSON.stringify(monitor)); + //console.log("STREAM=" + stream); return stream; }; -- cgit v1.2.3