summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/ModalCtrl.js26
-rw-r--r--www/js/MonitorCtrl.js133
-rw-r--r--www/js/MontageCtrl.js26
-rw-r--r--www/js/app.js3
-rw-r--r--www/templates/help.html22
-rw-r--r--www/templates/monitors.html2
-rw-r--r--www/templates/montage.html2
7 files changed, 87 insertions, 127 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
diff --git a/www/templates/help.html b/www/templates/help.html
index e5f18bd8..011f577c 100644
--- a/www/templates/help.html
+++ b/www/templates/help.html
@@ -9,21 +9,20 @@
<div class="list">
<ion-item class="item-text-wrap">
- <h2><b> What is an API path?</b> </h2> The latest versions of ZoneMinder have an API that is supposed to replace the XML skin. It is only available starting Zoneminder 1.29. If you don't have the API installed the client WILL NOT WORK.
+ <h2><b> What do I enter for ZM Portal URL, Base path to cgi-bin and ZM API URL?</b> </h2>
+ <ul>
+ <li>ZM Portal URL: The URL using which you can access ZM (example http://myserver.ddns.net/zm)</li>
+ <li>CGI base path: The URL using which your cgi-bin directory is accessible (example http://myserver.ddns.net/). You don't have to enter cgi-bin explictly</li>
+ <li>API Url: The URL using which your API directory is accessible (example: http://myserver.ddns.net/zm/api)</li>
+ </ul>
</ion-item>
<ion-item class="item-text-wrap">
- <h2><b> What is ZM base URL, portal alias and API path</b> </h2> Okay, there are multiple ways you can install ZoneMinder. For example, let's say you access zoneminder via http://yourserver.com:8000/zm. Then, http://yoursever.com:8000 is the base portal URL and the alias is zm. It's important you get these right, otherwise the app won't be able to display the data.
- </ion-item>
-
-
+ <h2><b>Since when does ZM have an API?</b> </h2> The latest versions of ZoneMinder have an API that is supposed to replace the XML skin. It is only available starting Zoneminder 1.29. If you don't have the API installed the client WILL NOT WORK.
- <ion-item class="item-text-wrap">
- <h2> <b>What should I be entering in the Base URL and API URL?</b></h2> The base url is typically of the format "http://yourserver:port/" (don't specify zm) The API url is typically of the format "http://yourserver:port/zm/api" But it depends on how you've installed ZoneMinder
</ion-item>
-
<ion-item class="item-text-wrap">
<h2> <b>I do not have authentication enabled but the app keeps asking me to specify authentication</b></h2> If you don't use ZM authentication, just enter an "x" in both user name and password.
</ion-item>
@@ -50,6 +49,13 @@
</ion-item>
+
+ <ion-item class="item-text-wrap">
+ <h2> <b>I can't connect using SSL!</b></h2>
+ Configuring SSL requires additional steps. It's not as simple as flipping the switch on in the app. Please read the <a href="#" onclick="window.open('https://github.com/pliablepixels/zmNinja/blob/master/docs/SSL-Configuration.md', '_blank', 'location=yes'); return false;">instructions</a> for more details.
+ </ion-item>
+
+
<ion-item class="item-text-wrap">
<h2><b>I want to contribute!</b></h2> Awesome. <a href="#" onclick="window.open('http://github.com/pliablepixels/zmNinja', '_blank', 'location=yes'); return false;"> Grab</a> the source code!
</ion-item>
diff --git a/www/templates/monitors.html b/www/templates/monitors.html
index 1945fa22..13dcdb83 100644
--- a/www/templates/monitors.html
+++ b/www/templates/monitors.html
@@ -45,7 +45,7 @@
<div style="float:right;">
<a class="button button-small icon icon-left icon ion-gear-a" href="" ng-click="changeConfig(monitor.Monitor.Name, monitor.Monitor.Id,monitor.Monitor.Enabled,monitor.Monitor.Function);">Configuration</a>
<a class="button button-small icon icon-left ion-calendar" href="#/events/{{monitor.Monitor.Id}}">Events</a>
- <a class="button button-small icon icon-left ion-ios-eye" ng-click="openModal(monitor.Monitor.Id, monitor.Monitor.Controllable)">Live View</a>
+ <a class="button button-small icon icon-left ion-ios-eye" ng-click="openModal(monitor.Monitor.Id, monitor.Monitor.Controllable, monitor.Monitor.ControlId)">Live View</a>
</div>
</div>
diff --git a/www/templates/montage.html b/www/templates/montage.html
index 7fed7ff3..46129fd8 100644
--- a/www/templates/montage.html
+++ b/www/templates/montage.html
@@ -32,7 +32,7 @@
</span>
<article class="main">
<!-- FIXME: Scale is 50% hardcoded -->
- <img ng-src="{{LoginData.streamingurl}}/cgi-bin/zms?mode=single&monitor={{monitor.Monitor.Id}}&maxfps={{LoginData.maxFPS}}&scale=50&user={{LoginData.username}}&pass={{LoginData.password}}&rand={{randomval}}" width="{{((devWidth-30)/(7-monitorSize[$index]))}}px;" ng-click="openModal(monitor.Monitor.Id, monitor.Monitor.Controllable)" on-hold="onHold($index)" on-release="onRelease($index)" />
+ <img ng-src="{{LoginData.streamingurl}}/cgi-bin/zms?mode=single&monitor={{monitor.Monitor.Id}}&maxfps={{LoginData.maxFPS}}&scale=50&user={{LoginData.username}}&pass={{LoginData.password}}&rand={{randomval}}" width="{{((devWidth-30)/(7-monitorSize[$index]))}}px;" ng-click="openModal(monitor.Monitor.Id, monitor.Monitor.Controllable, monitor.Monitor.ControlId)" on-hold="onHold($index)" on-release="onRelease($index)" />
</article>
<span ng-show="!minimal">