summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-08-19 15:12:58 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-08-19 15:12:58 -0400
commitd2b35b896c5960b27047321769186b32819e9a0b (patch)
tree92172015955f95e3db1e139f647a943acc60ec6e /www/js
parent9f0172691266b92b5204e440c0b31188f0eeb4ac (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')
-rw-r--r--www/js/ModalCtrl.js90
-rw-r--r--www/js/MonitorCtrl.js16
-rw-r--r--www/js/MontageCtrl.js61
-rw-r--r--www/js/app.js13
4 files changed, 130 insertions, 50 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
+ });
+
}]);
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js
index a44e4a95..d0d5a37e 100644
--- a/www/js/MonitorCtrl.js
+++ b/www/js/MonitorCtrl.js
@@ -30,21 +30,7 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu
};
- //-----------------------------------------------------------------------
- // All we do here is create a new random val for the URL so the
- // image regenerates
- //-----------------------------------------------------------------------
- $scope.reloadView = function () {
- console.log("*** Refreshing Modal view ***");
- $rootScope.rand =Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111;
- $scope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111;
- $ionicLoading.show({
- template: "refreshed view",
- noBackdrop: true,
- duration: 2000
- });
- };
-
+
//-----------------------------------------------------------------------
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index 7210b52d..1620472d 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -4,7 +4,7 @@
/* global cordova,StatusBar,angular,console,ionic */
-angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '$rootScope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', function ($scope, $rootScope, ZMDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm,$ionicPopover,$controller, imageLoadingDataShare) {
+angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '$rootScope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$ionicPopup', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$ionicPlatform', 'zm', '$ionicPopover', '$controller', 'imageLoadingDataShare', '$window', function ($scope, $rootScope, ZMDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $ionicPopup, $stateParams, $ionicHistory, $ionicScrollDelegate, $ionicPlatform, zm,$ionicPopover,$controller, imageLoadingDataShare, $window) {
$controller('zmApp.BaseController', { $scope: $scope });
//---------------------------------------------------------------------
@@ -170,28 +170,14 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
function loadNotifications() {
- // randomval is appended to img src, so after each interval the image reloads
- // let's make sure no image is loading
- //if (imageLoadingDataShare.get() == 0)
- // {
- //$scope.randomval = (new Date()).getTime();
-
-
- $rootScope.rand = Math.floor((Math.random() * 100000) + 1);
- console.log ("Montage Random....");
+
+ $rootScope.rand = Math.floor((Math.random() * 100000) + 1);
+ console.log ("Inside Montage timer...");
- //}
- //else
- //{
- // console.log ("Not generating rand as image is loading");
- // }
-
- // console.log ("*** REMOVE ME Montage timer: "+$rootScope.rand);
- // console.log ("New " + $scope.randomval);
}
var intervalHandle ;
- var isModalActive = false;
+ $scope.isModalActive = false;
var modalIntervalHandle;
@@ -430,13 +416,13 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
//---------------------------------------------------------------------
$scope.openModal = function (mid, controllable, controlid) {
console.log("Open Monitor Modal with monitor Id=" + mid + " and Controllable:" + controllable + " with control ID:" + controlid);
- isModalActive = true;
+ // $scope.isModalActive = true;
// Note: no need to setAwake(true) as its already awake
// in montage view
ZMDataModel.zmLog("Cancelling montage timer, opening Modal");
// ZMDataModel.zmLog("Starting Modal timer");
- $interval.cancel(intervalHandle);
+ $interval.cancel(intervalHandle);
// let's start modal timer
// modalIntervalHandle= $interval(function () {
@@ -488,7 +474,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
});
$scope.isControllable = controllable;
$scope.showPTZ = false;
- $scope.modal.show();
+
+ $scope.isModalActive = true;
+
+
+ $scope.modal.show();
+
});
};
@@ -499,15 +490,17 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
$scope.closeModal = function () {
console.log("Close & Destroy Monitor Modal");
- isModalActive = false;
+ // $scope.isModalActive = false;
// Note: no need to setAwake(false) as needs to be awake
// in montage view
$scope.modal.remove();
+
$rootScope.rand = Math.floor((Math.random() * 100000) + 1);
+ $scope.isModalActive = false;
ZMDataModel.zmLog("Restarting montage timer, closing Modal...");
- $interval.cancel(intervalHandle);
+ $interval.cancel(intervalHandle);
intervalHandle= $interval(function () {
loadNotifications();
// console.log ("Refreshing Image...");
@@ -590,12 +583,23 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
function onResume()
{
- console.log ("Restarting montage timer on resume");
+ if (!$scope.isModalActive)
+ {
+ ZMDataModel.zmLog ("Restarting montage timer on resume");
+ $rootScope.rand = Math.floor((Math.random() * 100000) + 1);
$interval.cancel(intervalHandle);
intervalHandle= $interval(function () {
loadNotifications();
// console.log ("Refreshing Image...");
- }.bind(this), 1000);
+ }.bind(this), 1000);
+ }
+ else // modal is active
+ {
+ $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1);
+ }
+
+
+
}
@@ -636,7 +640,8 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
});
$scope.$on('$ionicView.unloaded', function () {
- console.log("**VIEW ** Montage Ctrl Unloaded");
+ // console.log("**************** CLOSING WINDOW ***************************");
+ // $window.close();
});
//---------------------------------------------------------
@@ -698,7 +703,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
// This rand is really used to reload the monitor image in img-src so it is not cached
// I am making sure the image in montage view is always fresh
// I don't think I am using this anymore FIXME: check and delete if needed
- $rootScope.rand = Math.floor((Math.random() * 100000) + 1);
+ // $rootScope.rand = Math.floor((Math.random() * 100000) + 1);
});
diff --git a/www/js/app.js b/www/js/app.js
index 89e85f59..3d6c7f48 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -109,6 +109,7 @@ angular.module('zmApp', [
link: function ($scope, $element, $attributes) {
if ($attributes.imageSpinnerLoader) {
+ // console.log ("DIRECTIVE: IMAGE SPINNER");
var loader = $compile('<div class="image-loader-container"><ion-spinner style="position:fixed;top:5%;left:5%" class="image-loader" icon="' + $attributes.imageSpinnerLoader + '"></ion-spinner></div>')($scope);
$element.after(loader);
}
@@ -116,7 +117,7 @@ angular.module('zmApp', [
loadImage();
$attributes.$observe('imageSpinnerSrc', function(value){
- //console.log ("SOURCE CHANGED");
+ //console.log ("DIRECTIVE SOURCE CHANGED");
imageLoadingDataShare.set(1);
loadImage();
//deregistration();
@@ -126,6 +127,7 @@ angular.module('zmApp', [
// show an image-missing image
$element.bind('error',function () {
+ // console.log ("DIRECTIVE: IMAGE ERROR");
loader.remove();
imageLoadingDataShare.set(0);
@@ -136,6 +138,7 @@ angular.module('zmApp', [
function loadImage() {
$element.bind("load", function (e) {
if ($attributes.imageSpinnerLoader) {
+ // console.log ("DIRECTIVE: IMAGE LOADED");
loader.remove();
imageLoadingDataShare.set(0);
}
@@ -153,8 +156,10 @@ angular.module('zmApp', [
$element[0].style.backgroundImage = 'url(' + $attributes.imageSpinnerSrc + ')'; // set style attribute on element (it will load image)
};
bgImg.src = $attributes.imageSpinnerSrc;
+ //console.log ("DIRECTIVE: BGIMAGE SRC SET TO " + $attributes.imageSpinnerSrc);
} else {
$element[0].src = $attributes.imageSpinnerSrc; // set src attribute on element (it will load image)
+ //console.log ("DIRECTIVE: IMAGE SRC SET TO "+$attributes.imageSpinnerSrc);
}
}
@@ -163,7 +168,9 @@ angular.module('zmApp', [
}
$element.on('$destroy', function () {
+ // console.log ("**************** DIRECTIVE DESTROY IMAGE: " + $element[0].src);
});
+ $element[0].src="img/novideo.png";
}
};
@@ -215,13 +222,13 @@ angular.module('zmApp', [
if (zmSess[1])
{
//console.log ("***RESPONSE HEADER COOKIE " + zmSess[1]);
- console.log ("WHOLE STRING " + cookies);
+ // console.log ("WHOLE STRING " + cookies);
zmCookie=zmSess[1];
}
}
else
{
- console.log ("WHOLE STRING " + cookies);
+ // console.log ("WHOLE STRING " + cookies);
}
}
return response;