summaryrefslogtreecommitdiff
path: root/www/js/MontageCtrl.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/MontageCtrl.js')
-rw-r--r--www/js/MontageCtrl.js239
1 files changed, 113 insertions, 126 deletions
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index 1e0c1a64..b39d2aac 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -6,8 +6,92 @@
angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '$rootScope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams','$ionicHistory','$ionicScrollDelegate', function ($scope, $rootScope, ZMDataModel, message, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http,$state, $stateParams, $ionicHistory,$ionicScrollDelegate) {
+ //---------------------------------------------------------------------
+ // Controller main
+ //---------------------------------------------------------------------
+ document.addEventListener("pause", onPause, false);
+
+ // I was facing a lot of problems with Chrome/crosswalk getting stuck with
+ // pending HTTP requests after a while. There is a problem with chrome handling
+ // multiple streams of always open HTTP get's (image streaming). This problem
+ // does not arise when the image is streamed for a single monitor - just multiple
+
+ // To work around this I am taking a single snapshot of ZMS and have implemented a timer
+ // to reload the snapshot every 1 second. Seems to work reliably even thought its a higer
+ // load. Will it bonk with many monitors? Who knows. I have tried with 5 and 1280x960@32bpp
+
+
+ this.loadNotifications = function () {
+ // randomval is appended to img src, so after each interval the image reloads
+ $scope.randomval = (new Date()).getTime();
+ //console.log ("**** NOTIFICATION with rand="+$scope.randomval+"*****");
+ };
+
+ var timestamp = new Date().getUTCMilliseconds();
+ $scope.minimal = $stateParams.minimal;
+ $scope.isRefresh = $stateParams.isRefresh;
+
+ var isLongPressActive = false;
+ var intervalHandleMontage; // will hold image resize timer on long press
+ var montageIndex = 0; // will hold monitor ID to scale in timer
+
+ $scope.monitorSize = []; // array with montage sizes per monitor
+ $scope.scaleDirection = []; // 1 = increase -1 = decrease
+
+ $scope.slider = {};
+ $scope.slider.monsize = ZMDataModel.getMontageSize();
+
+ console.log ("******** HAVE ALL MONITORS");
+ $scope.monitors = message;
+
+
+ // Do we have a saved montage array size? No?
+ if (window.localStorage.getItem("montageArraySize") == undefined)
+ {
+
+ for ( var i = 0; i<$scope.monitors.length; i++)
+ {
+ $scope.monitorSize.push(ZMDataModel.getMontageSize() );
+ $scope.scaleDirection.push(1);
+ }
+ }
+ else // recover previous settings
+ {
+ var msize = window.localStorage.getItem("montageArraySize");
+ console.log ("MontageArrayString is=>"+msize);
+ $scope.monitorSize= msize.split(":");
+ var j;
+
+ for ( j = 0; j<$scope.monitorSize.length; j++)
+ {
+ // convert to number other wise adding to it concatenates :-)
+ $scope.monitorSize[j] = parseInt($scope.monitorSize[j]);
+ $scope.scaleDirection.push(1);
+ console.log ("Montage size for monitor " + j + " is " + $scope.monitorSize[j]);
+
+ }
+
+ }
+ console.log ("******** SETTING VARS");
+ // $scope.monitorSize = monitorSize;
+ // $scope.scaleDirection = scaleDirection;
+
+ $scope.LoginData = ZMDataModel.getLogin();
+ $scope.monLimit = $scope.LoginData.maxMontage;
+ console.log("********* Inside Montage Ctrl, MAX LIMIT=" + $scope.monLimit);
+
+
+ var intervalHandle = $interval(function () {
+ this.loadNotifications();
+ // console.log ("Refreshing Image...");
+ }.bind(this), 1000);
+
+ this.loadNotifications();
+
+ //---------------------------------------------------------------------
// Triggered when you enter/exit full screen
+ //---------------------------------------------------------------------
$scope.switchMinimal = function()
{
$scope.minimal = !$scope.minimal;
@@ -21,15 +105,18 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
});
$state.go("montage", {minimal: $scope.minimal,
isRefresh:true});
- //$state.reload();
- };
+ };
- // Show/Hide PTZ control
+ //---------------------------------------------------------------------
+ // Show/Hide PTZ control in monitor view
+ //---------------------------------------------------------------------
$scope.togglePTZ = function () {
$scope.showPTZ = !$scope.showPTZ;
};
-
+ //---------------------------------------------------------------------
+ // main monitor modal open
+ //---------------------------------------------------------------------
$scope.openModal = function (mid, controllable) {
console.log("Open Monitor Modal");
@@ -55,48 +142,21 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
$scope.modal.show();
});
- // do a post login for PTZ
- var loginData = ZMDataModel.getLogin();
- console.log("*** MODAL PORTAL LOGIN ****");
- $http({
- method: 'POST',
- url: loginData.url + '/index.php',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Accept': 'application/json',
- },
- transformRequest: function (obj) {
- var str = [];
- for (var p in obj)
- str.push(encodeURIComponent(p) + "=" +
- encodeURIComponent(obj[p]));
- var foo = str.join("&");
- console.log("****RETURNING " + foo);
- return foo;
- },
-
- data: {
- username: loginData.username,
- password: loginData.password,
- action: "login",
- view: "console"
- }
- })
- .success(function (data) {
- console.log("**** PORTAL LOGIN OK");
- })
- .error(function (error) {
- console.log("**** PORTAL LOGIN FAILED");
- });
-
};
+ //---------------------------------------------------------------------
+ //
+ //---------------------------------------------------------------------
+
$scope.closeModal = function () {
console.log("Close & Destroy Monitor Modal");
$scope.modal.remove();
};
+ //---------------------------------------------------------------------
+ // allows you to resize individual montage windows
+ //---------------------------------------------------------------------
function scaleMontage()
{
var index = montageIndex;
@@ -123,6 +183,10 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
window.localStorage.setItem("montageArraySize", monsizestring);
}
+ //---------------------------------------------------------------------
+ // if you long press on a montage window, it calls scale montage
+ // at a 200ms freq
+ //---------------------------------------------------------------------
$scope.onHold = function (index)
{
montageIndex = index;
@@ -134,6 +198,9 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
};
+ //---------------------------------------------------------------------
+ // stop scaling montage window on release
+ //---------------------------------------------------------------------
$scope.onRelease = function (index)
{
console.log ("Press release on " + index);
@@ -143,11 +210,12 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
-
+ //---------------------------------------------------------------------
// In Android, the app runs full steam while in background mode
// while in iOS it gets suspended unless you ask for specific resources
// So while this view, we DON'T want Android to keep sending 1 second
- // refreshes to the server for images we are not seeing!
+ // refreshes to the server for images we are not seeing
+ //---------------------------------------------------------------------
function onPause() {
console.log("*** Moving to Background ***"); // Handle the pause event
@@ -155,23 +223,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
$interval.cancel(intervalHandle);
}
- document.addEventListener("pause", onPause, false);
-
- // I was facing a lot of problems with Chrome/crosswalk getting stuck with
- // pending HTTP requests after a while. There is a problem with chrome handling
- // multiple streams of always open HTTP get's (image streaming). This problem
- // does not arise when the image is streamed for a single monitor - just multiple
-
- // To work around this I am taking a single snapshot of ZMS and have implemented a timer
- // to reload the snapshot every 1 second. Seems to work reliably even thought its a higer
- // load. Will it bonk with many monitors? Who knows. I have tried with 5 and 1280x960@32bpp
-
-
- this.loadNotifications = function () {
- // randomval is appended to img src, so after each interval the image reloads
- $scope.randomval = (new Date()).getTime();
- //console.log ("**** NOTIFICATION with rand="+$scope.randomval+"*****");
- };
$scope.openMenu = function () {
@@ -200,23 +251,19 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
console.log("**VIEW ** Montage Ctrl Unloaded");
});
-
- $scope.isSimulated = function () {
- return ZMDataModel.isSimulated();
- };
-
-
-
+ //---------------------------------------------------------
// slider is tied to the view slider for montage
//Remember not to use a variable. I'm using an object
// so it's passed as a reference - otherwise it makes
// a copy and the value never changes
+ //---------------------------------------------------------
$scope.sliderChanged = function ()
{
console.log('Slider has changed');
ZMDataModel.setMontageSize($scope.slider.monsize);
- console.log("Rootscope Montage is " + ZMDataModel.getMontageSize() + " and slider montage is " + $scope.slider.monsize);
+ console.log("Rootscope Montage is " + ZMDataModel.getMontageSize() +
+ " and slider montage is " + $scope.slider.monsize);
// Now go ahead and reset sizes of entire monitor array
var monsizestring="";
var i;
@@ -243,6 +290,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
+
$scope.doRefresh = function () {
console.log("***Pull to Refresh");
$scope.monitors = [];
@@ -255,66 +303,5 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
};
- var timestamp = new Date().getUTCMilliseconds();
- $scope.minimal = $stateParams.minimal;
- $scope.isRefresh = $stateParams.isRefresh;
-
- var isLongPressActive = false;
- var intervalHandleMontage; // will hold image resize timer on long press
- var montageIndex = 0; // will hold monitor ID to scale in timer
-
- // don't init here -will mess up scrolling
- $scope.monitorSize = []; // array with montage sizes per monitor
- $scope.scaleDirection = []; // 1 = increase -1 = decrease
-
- $scope.slider = {};
- $scope.slider.monsize = ZMDataModel.getMontageSize();
-
- //$scope.monitors = [];
- console.log ("******** HAVE ALL MONITORS");
- $scope.monitors = message;
-
-
- // Do we have a saved montage array size? No?
- if (window.localStorage.getItem("montageArraySize") == undefined)
- {
- for ( var i = 0; i<$scope.monitors.length; i++)
- {
- $scope.monitorSize.push(ZMDataModel.getMontageSize() );
- $scope.scaleDirection.push(1);
- }
- }
- else // recover previous settings
- {
- var msize = window.localStorage.getItem("montageArraySize");
- console.log ("MontageArrayString is=>"+msize);
- $scope.monitorSize= msize.split(":");
- var j;
-
- for ( j = 0; j<$scope.monitorSize.length; j++)
- {
- // convert to number other wise adding to it concatenates :-)
- $scope.monitorSize[j] = parseInt($scope.monitorSize[j]);
- $scope.scaleDirection.push(1);
- console.log ("Montage size for monitor " + j + " is " + $scope.monitorSize[j]);
-
- }
-
- }
- console.log ("******** SETTING VARS");
- // $scope.monitorSize = monitorSize;
- // $scope.scaleDirection = scaleDirection;
-
- $scope.LoginData = ZMDataModel.getLogin();
- $scope.monLimit = $scope.LoginData.maxMontage;
- console.log("********* Inside Montage Ctrl, MAX LIMIT=" + $scope.monLimit);
-
-
- var intervalHandle = $interval(function () {
- this.loadNotifications();
- // console.log ("Refreshing Image...");
- }.bind(this), 1000);
-
- this.loadNotifications();
}]);