diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-06-26 13:43:17 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-06-26 13:43:17 -0400 |
| commit | 544413f2d6de83e085d4489a1b9ccbaac3fa192d (patch) | |
| tree | cd6a3d0ae439109adbe09de2fa524aaaa76c77e2 /www/js | |
| parent | 0e83a778b541591ef468d7ebda1493a000a545e5 (diff) | |
I am now reading the PTZ DB to figure out the right "move" command for the cameras
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/ModalCtrl.js | 26 | ||||
| -rw-r--r-- | www/js/MonitorCtrl.js | 133 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 26 | ||||
| -rw-r--r-- | www/js/app.js | 3 |
4 files changed, 71 insertions, 117 deletions
diff --git a/www/js/ModalCtrl.js b/www/js/ModalCtrl.js index 102bc46a..d8f61b03 100644 --- a/www/js/ModalCtrl.js +++ b/www/js/ModalCtrl.js @@ -123,15 +123,24 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco //------------------------------------------------------------- // Send PTZ command to ZM - // FIXME: moveCon is hardcoded - won't work with - // cams that don't use moveCon. - // Need to grab control ID and then control API + // Note: PTZ fails on desktop, don't bother about it //------------------------------------------------------------- function controlPTZ(monitorId, cmd) { //curl -X POST "http://server.com/zm/index.php?view=request" -d //"request=control&user=admin&passwd=xx&id=4&control=moveConLeft" + if (!$scope.ptzMoveCommand) + { + $ionicLoading.show({ + template: "Not Ready for PTZ", + noBackdrop: true, + duration: 2000, + }); + return; + } + + console.log("Command value " + cmd + " with MID=" + monitorId); $ionicLoading.hide(); $ionicLoading.show({ @@ -166,14 +175,19 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco console.log("****RETURNING " + foo); return foo; }, + //FIXME: Refer to + // zoneminder/skins/mobile/includes/control_functions.php + // for move commands + // logic - /zm/api/monitors/X.json, read ControlId = Y + // then zm/api/controls/Y.json data: { view: "request", request: "control", id: monitorId, - control: "moveCon" + cmd, - xge: "30", - yge: "30", + control: $scope.ptzMoveCommand + cmd, + xge: "30", //wtf + yge: "30", //wtf } }); diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 7548624c..2ae91b69 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -208,17 +208,36 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu console.log("**VIEW ** Monitor Ctrl Unloaded"); }); - $scope.openModal = function (mid, controllable) { - console.log("Open Monitor Modal with monitor Id=" + mid + " and Controllable:" + controllable); + $scope.openModal = function (mid, controllable, controlid) { + console.log("Open Monitor Modal with monitor Id=" + mid + " and Controllable:" + controllable + " with control ID:"+controlid); $scope.monitorId = mid; $scope.LoginData = ZMDataModel.getLogin(); $scope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; + $scope.ptzMoveCommand = ""; // This is a modal to show the monitor footage - // We need to switch to always awake so the feed doesn't get interrupted + // We need to switch to always awake if set so the feed doesn't get interrupted ZMDataModel.setAwake(ZMDataModel.getKeepAwake()); + // if its controllable, lets get the control command + if (controllable == '1') + { + var apiurl = $scope.LoginData.apiurl; + var myurl = apiurl+"/controls/"+controlid+".json"; + console.log ("getting control details:"+myurl); + + $http.get(myurl) + .success(function(data) { + $scope.ptzMoveCommand = (data.control.Control.CanMoveCon == '1')? 'moveCon':'move'; + console.log("***moveCommand: " +$scope.ptzMoveCommand ); + }) + .error(function(data) { + console.log ("** Error retrieving move PTZ command"); + }); + } + + $ionicModal.fromTemplateUrl('templates/monitors-modal.html', { scope: $scope, animation: 'slide-in-up' @@ -236,40 +255,6 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu $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 () { @@ -289,78 +274,10 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu $scope.showPTZ = !$scope.showPTZ; }; - function controlPTZ(monitorId, cmd) { - - console.log("Command value " + cmd + " with MID=" + monitorId); - $ionicLoading.hide(); - $ionicLoading.show({ - template: "please wait...", - noBackdrop: true, - duration: 15000, - }); - - var loginData = ZMDataModel.getLogin(); - $ionicLoading.hide(); - $ionicLoading.show({ - template: "Sending PTZ..", - noBackdrop: true, - duration: 15000, - }); - // console.log ("ANGULAR VERSION: "+JSON.stringify(angular.version)); - // console.log('Set-Cookie'+ header('Set-Cookie')); // - - var req = $http({ - method: 'POST', - /*timeout: 15000,*/ - 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; - }, - - // FIXME: Refer to - // zoneminder/skins/mobile/includes/control_functions.php - // for move commands - // logic - /zm/api/monitors/X.json, read ControlId = Y - // then zm/api/controls/Y.json - - data: { - view: "request", - request: "control", - id: monitorId, - //connkey: $scope.connKey, - control: "moveCon" + cmd, - xge: "30", - yge: "30", - //user: loginData.username, - //pass: loginData.password - } - - }); - - req.success(function (resp) { - $ionicLoading.hide(); - console.log("SUCCESS: " + JSON.stringify(resp)); - // $ionicLoading.hide(); - - }); - - req.error(function (resp) { - $ionicLoading.hide(); - console.log("ERROR: " + JSON.stringify(resp)); - }); - - } + //----------------------------------------------------------------------- + // Controller Main + //----------------------------------------------------------------------- function monitorStateCheck() { diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 2a8dce2f..bd2ab1ef 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -121,14 +121,36 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', ' //--------------------------------------------------------------------- // main monitor modal open //--------------------------------------------------------------------- - $scope.openModal = function (mid, controllable) { - console.log("Open Monitor Modal"); + $scope.openModal = function (mid, controllable, controlid) { + console.log("Open Monitor Modal with monitor Id=" + mid + " and Controllable:" + controllable + " with control ID:"+controlid); // Note: no need to setAwake(true) as its already awake // in montage view $scope.monitorId = mid; $scope.LoginData = ZMDataModel.getLogin(); $scope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; + $scope.ptzMoveCommand = ""; + + // This is a modal to show the monitor footage + // We need to switch to always awake if set so the feed doesn't get interrupted + ZMDataModel.setAwake(ZMDataModel.getKeepAwake()); + + // if its controllable, lets get the control command + if (controllable == '1') + { + var apiurl = $scope.LoginData.apiurl; + var myurl = apiurl+"/controls/"+controlid+".json"; + console.log ("getting control details:"+myurl); + + $http.get(myurl) + .success(function(data) { + $scope.ptzMoveCommand = (data.control.Control.CanMoveCon == '1')? 'moveCon':'move'; + console.log("***moveCommand: " +$scope.ptzMoveCommand ); + }) + .error(function(data) { + console.log ("** Error retrieving move PTZ command"); + }); + } // This is a modal to show the monitor footage $ionicModal.fromTemplateUrl('templates/monitors-modal.html', { diff --git a/www/js/app.js b/www/js/app.js index d17d16c1..4c157eda 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -240,6 +240,7 @@ angular.module('zmApp', [ $state.go($state.current, {}, { reload: true }); + zmAutoLogin.stop(); //safety zmAutoLogin.start(); }, false); @@ -265,7 +266,7 @@ angular.module('zmApp', [ // lets POST so we get a session ID right hre - console.log ("Setting up POST LOGIN timer"); + //console.log ("Setting up POST LOGIN timer"); zmAutoLogin.start(); }) //run |
