diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-08-19 15:12:58 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-08-19 15:12:58 -0400 |
| commit | d2b35b896c5960b27047321769186b32819e9a0b (patch) | |
| tree | 92172015955f95e3db1e139f647a943acc60ec6e /www/js/ModalCtrl.js | |
| parent | 9f0172691266b92b5204e440c0b31188f0eeb4ac (diff) | |
Fixed monitor view and montage performance - nph-zms instances were building up at the server killing it after repeated use. phew
Diffstat (limited to 'www/js/ModalCtrl.js')
| -rw-r--r-- | www/js/ModalCtrl.js | 90 |
1 files changed, 86 insertions, 4 deletions
diff --git a/www/js/ModalCtrl.js b/www/js/ModalCtrl.js index 87ec4b54..18db21f1 100644 --- a/www/js/ModalCtrl.js +++ b/www/js/ModalCtrl.js @@ -9,8 +9,8 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco console.log("**** INSIDE MODAL CTRL, recomputing rand *****"); - $scope.rand = Math.floor((Math.random() * 100000) + 1); - $rootScope.rand = Math.floor((Math.random() * 100000) + 1); + // $scope.rand = Math.floor((Math.random() * 100000) + 1); + // $rootScope.rand = Math.floor((Math.random() * 100000) + 1); //$state.go($state.current, {}, {reload: true}); // This holds the PTZ menu control @@ -24,12 +24,16 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco // the custom slider view is messed up till the image loads // in modal view $scope.showModalRangeSider = false; + $scope.isModalActive = true; $timeout( function() { $scope.showModalRangeSider = true; - console.log ("****SHOWING SLIDER"); + // console.log ("****SHOWING SLIDER"); },2000); + document.addEventListener("pause", onPause, false); + document.addEventListener("resume", onResume, false); + $scope.radialMenuOptions = { content: '', @@ -139,9 +143,58 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco } }, ]}; + + $interval.cancel(intervalModalHandle); + intervalModalHandle= $interval(function () { + loadModalNotifications(); + // console.log ("Refreshing Image..."); + }.bind(this), 1000); + loadModalNotifications(); + + + function onPause() { + console.log("*** Modal: Moving to Background ***"); // Handle the pause event + console.log("*** MODAL: CANCELLING INTERVAL ****"); + $interval.cancel(intervalModalHandle); + // $interval.cancel(modalIntervalHandle); + + // FIXME: Do I need to setAwake(false) here? + } + function onResume() + { + + if ($scope.isModalActive) + { + ZMDataModel.zmLog ("MODAL: Restarting Modal timer on resume"); + + $interval.cancel(intervalModalHandle); + intervalModalHandle= $interval(function () { + loadModalNotifications(); + // console.log ("Refreshing Image..."); + }.bind(this), 1000); + + + $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); + + } + + + + } + + +function loadModalNotifications() { + + console.log ("Inside Modal timer..."); + $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); + + } + + var intervalModalHandle ; + //------------------------------------------------------------- @@ -343,7 +396,8 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco $scope.reloadView = function() { ZMDataModel.zmLog ("Reloading view for modal view, recomputing rand"); - $rootScope.rand = Math.floor((Math.random() * 100000) + 1); + $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); + $scope.isModalActive = true; }; $scope.scaleImage = function() { @@ -351,5 +405,33 @@ $scope.reloadView = function() $scope.imageFit = !$scope.imageFit; }; + $scope.$on ('$ionicView.enter', function() { + + + + }); + + $scope.$on('$ionicView.leave', function () { + console.log("**MODAL: Stopping modal timer"); + $scope.isModalActive = false; + $interval.cancel(intervalModalHandle); + }); + + $scope.$on('$ionicView.unloaded', function () { + $scope.isModalActive = false; + console.log("**MODAL UNLOADED: Stopping modal timer"); + $interval.cancel(intervalModalHandle); + + // console.log("Modal monitor left"); + }); + + $scope.$on('modal.removed', function() { + $scope.isModalActive = false; + console.log("**MODAL REMOVED: Stopping modal timer"); + $interval.cancel(intervalModalHandle); + + // Execute action + }); + }]); |
