summaryrefslogtreecommitdiff
path: root/www/js/MonitorCtrl.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/MonitorCtrl.js')
-rw-r--r--www/js/MonitorCtrl.js280
1 files changed, 275 insertions, 5 deletions
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js
index b7469a9d..63d27ea2 100644
--- a/www/js/MonitorCtrl.js
+++ b/www/js/MonitorCtrl.js
@@ -5,7 +5,7 @@
// controller for Monitor View
// refer to comments in EventCtrl for the modal stuff. They are almost the same
-angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopup', '$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', function ($ionicPopup, $scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope) {
+angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopup', '$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', function ($ionicPopup, $scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout) {
$scope.monitors = [];
@@ -26,8 +26,121 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu
});
};
-// This function takes care of changing function parameters
-// For now, I've only limited it to enable/disable and change monitor mode
+ $scope.radialMenuOptions = {
+ content: '',
+
+ background: '#2F4F4F',
+ isOpen: false,
+ toggleOnClick: false,
+ button: {
+ cssClass: "fa fa-arrows-alt",
+ },
+ items: [
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'Down');
+ }
+ },
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'DownLeft');
+ }
+ },
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'Left');
+ }
+ },
+ {
+ content: 'D',
+ empty: true,
+
+ onclick: function () {
+ console.log('About');
+ }
+ },
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'UpLeft');
+ }
+ },
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'Up');
+ }
+ },
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'UpRight');
+ }
+ },
+
+ {
+ content: 'H',
+ empty: true,
+ onclick: function () {
+ console.log('About');
+ }
+ },
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'Right');
+ }
+ },
+
+
+ {
+ content: '',
+ cssClass: 'fa fa-chevron-circle-up',
+ empty: false,
+ onclick: function () {
+ controlPTZ($scope.monitorId, 'DownRight');
+ }
+ },
+
+ {
+ content: 'K',
+ empty: true,
+ onclick: function () {
+ console.log('About');
+ }
+ },
+
+
+ ]
+ };
+
+
+ // This function takes care of changing function parameters
+ // For now, I've only limited it to enable/disable and change monitor mode
$scope.changeConfig = function (monitorName, monitorId, enabled, func) {
var checked = "false";
@@ -194,14 +307,15 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu
console.log("**VIEW ** Monitor Ctrl Unloaded");
});
- $scope.openModal = function (mid) {
- console.log("Open Monitor Modal");
+ $scope.openModal = function (mid, controllable) {
+ console.log("Open Monitor Modal with monitod Id=" + mid + " and Controllable:" + controllable);
$scope.monitorId = mid;
$scope.LoginData = ZMDataModel.getLogin();
$scope.rand = Math.floor(Math.random() * (999999 - 111111 + 1)) + 111111;
// This is a modal to show the monitor footage
+
$ionicModal.fromTemplateUrl('templates/monitors-modal.html', {
scope: $scope,
animation: 'slide-in-up'
@@ -214,9 +328,48 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu
noBackdrop: true,
duration: 15000
});
+ $scope.isControllable = controllable;
+ $scope.showPTZ = false;
$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 () {
@@ -230,6 +383,123 @@ angular.module('zmApp.controllers').controller('zmApp.MonitorCtrl', ['$ionicPopu
$scope.modal.remove();
});
+ $scope.togglePTZ = function () {
+ $scope.showPTZ = !$scope.showPTZ;
+ };
+
+ function controlPTZ(monitorId, cmd) {
+ // curl -X POST "http://arjunrc.ddns.net:9898/zm/index.php" -d "view=request&request=control&user=admin&passwd=indiglo&id=4&control=moveConLeft"
+
+
+ //curl -X POST "http://server.com/zm/index.php?view=request" -d "request=control&user=admin&passwd=xx&id=4&control=moveConLeft"
+
+ console.log("Command value " + cmd + " with MID=" + monitorId);
+
+ if (ZMDataModel.isSimulated()) {
+ var str = "simulation mode. no action taken";
+ $ionicLoading.show({
+ template: str,
+ noBackdrop: true,
+ duration: 3000
+ });
+ return;
+ }
+
+ $ionicLoading.hide();
+ $ionicLoading.show({
+ template: "please wait...",
+ noBackdrop: true,
+ duration: 15000,
+ });
+
+ var loginData = ZMDataModel.getLogin();
+
+ /* $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,status,header,config)
+ {*/
+ $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;
+ },
+
+ 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));
+ });
+
+ //});
+ }
+
+
console.log("***EVENTS: Waiting for Monitors to load before I proceed");