diff options
| author | pliablepixels <pliablepixels@gmail.com> | 2016-04-15 15:50:03 -0400 |
|---|---|---|
| committer | pliablepixels <pliablepixels@gmail.com> | 2016-04-15 15:50:03 -0400 |
| commit | a1bae88bb0b7f75d28e300c5f4935aa1ab88a0b6 (patch) | |
| tree | de85a48f42b41898d1043aba204fb485efa0f54c /www/js | |
| parent | 8fccabcec0f0d0d13ae1bc6b9032f15cfe621914 (diff) | |
#223 and #224 - fixes ptz/noptz when you swipe, working Zoom In/Zoom Out support/ cleaned up modal PTZ code to be common between Montage and ModalCtrl
Former-commit-id: 4dcc73573b1bfa4581203b5c3ec4a714f5b37ab9
Diffstat (limited to 'www/js')
| -rw-r--r-- | www/js/MonitorCtrl.js | 115 | ||||
| -rw-r--r-- | www/js/MonitorModalCtrl.js | 141 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 99 |
3 files changed, 161 insertions, 194 deletions
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 2c918fb7..7b637b1c 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -297,119 +297,35 @@ angular.module('zmApp.controllers') $scope.LoginData = ZMDataModel.getLogin(); $scope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; $rootScope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; - $scope.connKey = connKey; + + + $scope.showPTZ = false; + $scope.monitorId = mid; + $scope.monitorName = ZMDataModel.getMonitorName(mid); + $scope.controlid = controlid; + $scope.LoginData = ZMDataModel.getLogin(); + $rootScope.modalRand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; $scope.ptzMoveCommand = ""; - $scope.presetOn = false; + $scope.ptzStopCommand = ""; $scope.zoomInCommand = ""; $scope.zoomOutCommand = ""; $scope.zoomStopCommand = "zoomStop"; $scope.canZoom = false; + $scope.presetOn = false; + + $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + $scope.isControllable = controllable; + // 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 = "move"; // start with as move; - $scope.ptzStopCommand = ""; - - if (data.control.Control.CanZoom=='1') - { - $scope.canZoom = true; - if (data.control.Control.CanZoomCon == '1') - { - $scope.zoomInCommand = "zoomConTele"; - $scope.zoomOutCommand = "zoomConWide"; - - } - else if (data.control.Control.CanZoomRel == '1') - { - $scope.zoomInCommand = "zoomRelTele"; - $scope.zoomOutCommand = "zoomRelWide"; - } - - else if (data.control.Control.CanZoomAbs == '1') - { - $scope.zoomInCommand = "zoomRelAbs"; - $scope.zoomOutCommand = "zoomRelAbs"; - } - } - - ZMDataModel.zmDebug ("control PTZ details are " + JSON.stringify(data)); - - - if (data.control.Control.CanMoveRel == '1') - { - - $scope.ptzMoveCommand = "moveRel"; - $scope.ptzStopCommand = "moveStop"; - } - - // Prefer con over rel if both enabled - // I've tested con - - if (data.control.Control.CanMoveCon == '1') - { - - $scope.ptzMoveCommand = "moveCon"; - $scope.ptzStopCommand = "moveStop"; - } - - // presets - ZMDataModel.zmDebug ("Preset value is " +data.control.Control.HasPresets); - - if (data.control.Control.HasPresets == '1') - { - $scope.ptzPresetCount = parseInt(data.control.Control.NumPresets); - //$scope.ptzPresetCount = 33; - ZMDataModel.zmDebug ("Number of presets is " + $scope.ptzPresetCount); - - $scope.ptzPresets = []; - for (var p=0; p<$scope.ptzPresetCount; p++) - { - $scope.ptzPresets.push ({name:(p+1).toString(), icon:'', cmd:"presetGoto"+(p+1).toString()}); - // $scope.ptzPresets[p].name = "Arjun " + p; - // console.log ("Name to " + $scope.ptzPresets[p].name); - } - - if (data.control.Control.HasHomePreset == '1') - { - $scope.ptzPresets.unshift({name:'', icon:"ion-ios-home", cmd:'presetHome'}); - - $scope.ptzPresetCount++; - } - - } - - - // console.log("***moveCommand: " + $scope.ptzMoveCommand); - ZMDataModel.zmLog("ControlDB reports PTZ command to be " + $scope.ptzMoveCommand + " and " + $scope.ptzStopCommand); - }) - .error(function (data) { - // console.log("** Error retrieving move PTZ command"); - ZMDataModel.zmLog("Error retrieving PTZ command " + JSON.stringify(data), "error"); - ZMDataModel.displayBanner('error', ['did not get a valid PTZ response', 'Please try again']); - $scope.isControllable = '0'; - - }); - - } - - $ionicModal.fromTemplateUrl('templates/monitors-modal.html', { scope: $scope, animation: 'slide-in-up' @@ -422,8 +338,7 @@ angular.module('zmApp.controllers') noBackdrop: true, duration: zm.loadingTimeout }); - $scope.isControllable = controllable; - $scope.showPTZ = false; + $scope.isModalActive = true; $scope.modal.show(); }); diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js index 31b2f0f6..187e5f9e 100644 --- a/www/js/MonitorModalCtrl.js +++ b/www/js/MonitorModalCtrl.js @@ -689,7 +689,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ var mid; mid = ZMDataModel.getNextMonitor(m, d); - + $scope.showPTZ = false; // FIXME: clean this up - in a situation where // no monitors are enabled, will it loop for ever? @@ -753,6 +753,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); $scope.monitorId = mid; $scope.monitorName = ZMDataModel.getMonitorName(mid); + configurePTZ($scope.monitorId); }, 200); } @@ -1632,6 +1633,140 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ //console.log ("PADTON: returning " + number); return number; } + + // make sure following are correct: + // $scope.isControllable + // $scope.controlid + // + function configurePTZ(mid) + { + $scope.ptzMoveCommand = ""; + $scope.ptzStopCommand = ""; + + $scope.zoomInCommand = ""; + $scope.zoomOutCommand = ""; + $scope.zoomStopCommand = "zoomStop"; + $scope.canZoom = false; + + $scope.presetOn = false; + + ZMDataModel.zmDebug ("configurePTZ: called with mid="+mid); + var ld = ZMDataModel.getLogin(); + var url = ld.apiurl+"/monitors/"+mid+".json"; + $http.get (url) + .success (function (data) + { + $scope.isControllable = data.monitor.Monitor.Controllable; + $scope.controlid = data.monitor.Monitor.ControlId; + if ($scope.isControllable=='1') + { + var apiurl = ZMDataModel.getLogin().apiurl; + var myurl = apiurl + "/controls/" + $scope.controlid + ".json"; + ZMDataModel.zmDebug("configurePTZ : getting controllable data " + myurl); + + $http.get(myurl) + .success(function (data) { + + $scope.ptzMoveCommand = "move"; // start with as move; + $scope.ptzStopCommand = ""; + + if (data.control.Control.CanZoom=='1') + { + $scope.canZoom = true; + if (data.control.Control.CanZoomCon == '1') + { + $scope.zoomInCommand = "zoomConTele"; + $scope.zoomOutCommand = "zoomConWide"; + + } + else if (data.control.Control.CanZoomRel == '1') + { + $scope.zoomInCommand = "zoomRelTele"; + $scope.zoomOutCommand = "zoomRelWide"; + } + + else if (data.control.Control.CanZoomAbs == '1') + { + $scope.zoomInCommand = "zoomRelAbs"; + $scope.zoomOutCommand = "zoomRelAbs"; + } + } + + + ZMDataModel.zmDebug("configurePTZ: control data returned " + JSON.stringify(data)); + + if (data.control.Control.CanMoveRel == '1') + { + + $scope.ptzMoveCommand = "moveRel"; + $scope.ptzStopCommand = "moveStop"; + } + + // Prefer con over rel if both enabled + // I've tested con + + if (data.control.Control.CanMoveCon == '1') + { + + $scope.ptzMoveCommand = "moveCon"; + $scope.ptzStopCommand = "moveStop"; + } + + + + // presets + ZMDataModel.zmDebug ("ConfigurePTZ Preset value is " +data.control.Control.HasPresets); + + if (data.control.Control.HasPresets == '1') + { + $scope.ptzPresetCount = parseInt(data.control.Control.NumPresets); + + ZMDataModel.zmDebug ("ConfigurePTZ Number of presets is " + $scope.ptzPresetCount); + + $scope.ptzPresets = []; + for (var p=0; p<$scope.ptzPresetCount; p++) + { + $scope.ptzPresets.push ({name:(p+1).toString(), icon:'', cmd:"presetGoto"+(p+1).toString()}); + // $scope.ptzPresets[p].name = "Arjun " + p; + // console.log ("Name to " + $scope.ptzPresets[p].name); + } + + if (data.control.Control.HasHomePreset == '1') + { + $scope.ptzPresets.unshift({name:'', icon:"ion-ios-home", cmd:'presetHome'}); + + $scope.ptzPresetCount++; + } + + } + + + ZMDataModel.zmLog("ConfigurePTZ Modal: ControlDB reports PTZ command to be " + $scope.ptzMoveCommand); + }) + .error(function (data) { + // console.log("** Error retrieving move PTZ command"); + ZMDataModel.zmLog("ConfigurePTZ : Error retrieving PTZ command " + JSON.stringify(data), "error"); + }); + + } + else + { + ZMDataModel.zmLog ("configurePTZ " + mid+" is not PTZ controllable"); + } + }) + .error(function (data) { + // console.log("** Error retrieving move PTZ command"); + ZMDataModel.zmLog("configurePTZ : Error retrieving PTZ command " + JSON.stringify(data), "error"); + }); + + + // if its controllable, lets get the control command + if ($scope.isControllable == '1') { + + + } + + } $scope.$on('modal.shown', function () { @@ -1656,6 +1791,10 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ // console.log ("Refreshing Image..."); }.bind(this),zm.eventPlaybackQuery); } + + configurePTZ($scope.monitorId); + + // monitor.Monitor.Id, monitor.Monitor.Controllable, monitor.Monitor.ControlId diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 7563da8e..ae7d27bb 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -644,8 +644,10 @@ function initPackery() // console.log ("Refreshing Image..."); // }.bind(this), 1000); + $scope.showPTZ = false; $scope.monitorId = mid; $scope.monitorName = ZMDataModel.getMonitorName(mid); + $scope.controlid = controlid; $scope.LoginData = ZMDataModel.getLogin(); $rootScope.modalRand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111; @@ -660,102 +662,13 @@ function initPackery() $scope.presetOn = false; $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + $scope.isControllable = controllable; // 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') { - ZMDataModel.zmDebug("MontageCtrl: getting controllable data " + myurl); - var apiurl = $scope.LoginData.apiurl; - var myurl = apiurl + "/controls/" + controlid + ".json"; - ZMDataModel.zmDebug("MontageCtrl: getting controllable data " + myurl); - - $http.get(myurl) - .success(function (data) { - - $scope.ptzMoveCommand = "move"; // start with as move; - $scope.ptzStopCommand = ""; - - if (data.control.Control.CanZoom=='1') - { - $scope.canZoom = true; - if (data.control.Control.CanZoomCon == '1') - { - $scope.zoomInCommand = "zoomConTele"; - $scope.zoomOutCommand = "zoomConWide"; - - } - else if (data.control.Control.CanZoomRel == '1') - { - $scope.zoomInCommand = "zoomRelTele"; - $scope.zoomOutCommand = "zoomRelWide"; - } - - else if (data.control.Control.CanZoomAbs == '1') - { - $scope.zoomInCommand = "zoomRelAbs"; - $scope.zoomOutCommand = "zoomRelAbs"; - } - } - - - ZMDataModel.zmDebug("MontageCtrl: control data returned " + JSON.stringify(data)); - - if (data.control.Control.CanMoveRel == '1') - { - - $scope.ptzMoveCommand = "moveRel"; - $scope.ptzStopCommand = "moveStop"; - } - - // Prefer con over rel if both enabled - // I've tested con - - if (data.control.Control.CanMoveCon == '1') - { - - $scope.ptzMoveCommand = "moveCon"; - $scope.ptzStopCommand = "moveStop"; - } - - - - // presets - ZMDataModel.zmDebug ("Preset value is " +data.control.Control.HasPresets); - - if (data.control.Control.HasPresets == '1') - { - $scope.ptzPresetCount = parseInt(data.control.Control.NumPresets); - - ZMDataModel.zmDebug ("Number of presets is " + $scope.ptzPresetCount); - - $scope.ptzPresets = []; - for (var p=0; p<$scope.ptzPresetCount; p++) - { - $scope.ptzPresets.push ({name:(p+1).toString(), icon:'', cmd:"presetGoto"+(p+1).toString()}); - // $scope.ptzPresets[p].name = "Arjun " + p; - // console.log ("Name to " + $scope.ptzPresets[p].name); - } - - if (data.control.Control.HasHomePreset == '1') - { - $scope.ptzPresets.unshift({name:'', icon:"ion-ios-home", cmd:'presetHome'}); - - $scope.ptzPresetCount++; - } - - } - - - ZMDataModel.zmLog("ControlDB reports PTZ command to be " + $scope.ptzMoveCommand); - }) - .error(function (data) { - // console.log("** Error retrieving move PTZ command"); - ZMDataModel.zmLog("Error retrieving PTZ command " + JSON.stringify(data), "error"); - }); - } + // This is a modal to show the monitor footage $ionicModal.fromTemplateUrl('templates/monitors-modal.html', { @@ -771,8 +684,8 @@ function initPackery() noBackdrop: true, duration: zm.loadingTimeout }); - $scope.isControllable = controllable; - $scope.showPTZ = false; + + $scope.isModalActive = true; |
