summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2019-12-17 11:01:53 -0500
committerPliable Pixels <pliablepixels@gmail.com>2019-12-17 11:01:53 -0500
commitfb215ba18d415bb00980530eba0a48c3e5216b7e (patch)
tree02031b4ab6d7fed5e3a8f79d3d9006e266fbeb9e /www
parent0ce2be5cb921c979c79091b773f6c80612779bc2 (diff)
#876 custom header
Diffstat (limited to 'www')
-rw-r--r--www/js/DevOptionsCtrl.js8
-rw-r--r--www/js/NVR.js18
-rwxr-xr-xwww/js/app.js28
-rw-r--r--www/lang/locale-en.json1
-rw-r--r--www/templates/devoptions.html13
5 files changed, 52 insertions, 16 deletions
diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js
index 55aa0e5b..57e7e2fa 100644
--- a/www/js/DevOptionsCtrl.js
+++ b/www/js/DevOptionsCtrl.js
@@ -141,6 +141,14 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope'
}
+ $scope.useDefaultCustom = function() {
+ if ($scope.loginData.zmNinjaHeader=='') {
+ $scope.loginData.zmNinjaHeader = 'zmNinja version:'+NVR.getAppVersion();
+ }
+
+
+ };
+
$scope.saveDevOptions = function () {
saveDevOptions();
diff --git a/www/js/NVR.js b/www/js/NVR.js
index 36ddf880..37a6c816 100644
--- a/www/js/NVR.js
+++ b/www/js/NVR.js
@@ -22,7 +22,7 @@ angular.module('zmApp.controllers')
It is changed by sync_version.sh
*/
var zmAppVersion = "1.3.085";
- var zmAPIVersion = null;
+
var isBackground = false;
var justResumed = false;
var timeSinceResumed = -1;
@@ -210,6 +210,7 @@ angular.module('zmApp.controllers')
'useAPICaching': true,
'pauseStreams': false,
'liveStreamBuffer': 100,
+ 'zmNinjaHeader':undefined, // filled in init. custom header
};
@@ -233,6 +234,10 @@ angular.module('zmApp.controllers')
cordova.plugin.http.useBasicAuth(loginData.basicAuthUser, loginData.basicAuthPassword);
}
+ // setup custom header
+ cordova.plugin.http.setHeader('*', 'X-ZmNinja', loginData.zmNinjaHeader);
+
+
if (!loginData.enableStrictSSL) {
//alert("Enabling insecure SSL");
@@ -1602,6 +1607,10 @@ angular.module('zmApp.controllers')
loginData.liveStreamBuffer = 100;
}
+ if ((typeof loginData.zmNinjaHeader == undefined) || (loginData.zmNinjaHeader == '')) {
+ loginData.zmNinjaHeader = 'zmNinja version:'+zmAppVersion;
+ }
+
loginData.canSwipeMonitors = true;
loginData.forceImageModePath = false;
loginData.enableBlog = true;
@@ -2283,6 +2292,13 @@ angular.module('zmApp.controllers')
setAppVersion: function (ver) {
zmAppVersion = ver;
+ $rootScope.appVersion = ver; // for custom header
+
+ //console.log ('****** VER:'+$rootScope.appVersion);
+ },
+
+ getCustomHeader: function () {
+ return loginData.zmNinjaHeader;
},
getAppVersion: function () {
diff --git a/www/js/app.js b/www/js/app.js
index b5c2c6f4..3eb7210f 100755
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -2,14 +2,7 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console,alert,PushNotification, moment ,ionic, URI,Packery, ConnectSDK, CryptoJS, ContactFindOptions, localforage,$, Connection, MobileAccessibility, hello */
-// For desktop versions, this is replaced
-// with actual app version from config.xml by the
-// ./make_desktop.sh script
-// For mobile versions, I use cordova app version plugin
-// to get it at run time
-
-var appVersion = "0.0.0";
// core app start stuff
angular.module('zmApp', [
@@ -662,12 +655,18 @@ angular.module('zmApp', [
request: function (config) {
if (!config) return config;
if (!config.url) return config;
-
+ nvr = $injector.get('NVR');
if ($rootScope.basicAuthHeader) {
config.headers.Authorization = $rootScope.basicAuthHeader;
}
+ var chdr = nvr.getCustomHeader();
+ if (chdr) {
+ config.headers['X-ZmNinja'] = chdr;
+ }
+
+
return config || $q.when(config);
},
@@ -1131,7 +1130,7 @@ angular.module('zmApp', [
-
+
$rootScope.dpadId = 0;
$rootScope.textScaleFactor = 1.0;
$rootScope.isLoggedIn = false;
@@ -1765,11 +1764,16 @@ angular.module('zmApp', [
// console.log("app version");
cordova.getAppVersion.getVersionNumber().then(function (version) {
- appVersion = version;
- NVR.log("App Version: " + appVersion);
- NVR.setAppVersion(appVersion);
+
+ NVR.log("App Version: " + version);
+ NVR.setAppVersion(version);
});
}
+ else {
+ // custom header
+ $rootScope.appVersion = NVR.getAppVersion();
+ }
+
// At this stage, NVR.init is not called yet
diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json
index 53649c3f..f05b4ec0 100644
--- a/www/lang/locale-en.json
+++ b/www/lang/locale-en.json
@@ -49,6 +49,7 @@
"kCredentialsBody" :"Please provide your ZoneMinder credentials",
"kCredentialsTitle" :"Credentials Required",
"kCurrentState" :"current state",
+ "kCustomHeader" : "Custom HTTP header",
"kCustomRange" :"Custom Range",
"kCycleMonitors" :"cycle monitors",
"kCycleMonitorsInterval" :"monitor cycle interval",
diff --git a/www/templates/devoptions.html b/www/templates/devoptions.html
index b89cd7f7..f1a7ae29 100644
--- a/www/templates/devoptions.html
+++ b/www/templates/devoptions.html
@@ -22,7 +22,7 @@
</div>
<div class="item item-input-inset item-text-wrap">
- {{'kMontageLiveViewFPS'|translate}} ({{'kSec'|translate}}.)
+ {{'kMontageLiveViewFPS'|translate}} ({{'kSec'|translate}}.)&nbsp;
<label class="item-input-wrapper">
<input type="tel" placeholder="leave empty for auto" ng-model="loginData.montageliveFPS">
@@ -31,7 +31,7 @@
</div>
<div class="item item-input-inset item-text-wrap">
- {{'kSingleLiveViewFPS'|translate}} ({{'kSec'|translate}}.)
+ {{'kSingleLiveViewFPS'|translate}} ({{'kSec'|translate}}.)&nbsp;
<label class="item-input-wrapper">
<input id="devoptions-move-3_1" type="tel" placeholder="leave empty for auto" ng-model="loginData.singleliveFPS">
@@ -40,7 +40,7 @@
</div>
<div class="item item-input-inset item-text-wrap">
- {{'kLiveStreamBuffer'|translate}}
+ {{'kLiveStreamBuffer'|translate}}&nbsp;
<label class="item-input-wrapper">
<input id="devoptions-move-3_1" type="tel" ng-model="loginData.liveStreamBuffer">
</label>
@@ -268,6 +268,13 @@
</label>
</div>
+ <div class="item item-text-wrap item-input-inset">
+ {{'kCustomHeader'|translate}}&nbsp;
+ <label class="item-input-wrapper">
+ <input type="tel" placeholder="" ng-model="loginData.zmNinjaHeader" ng-change="useDefaultCustom()">
+ </label>
+ </div>
+
</div>
</ion-content>
</ion-view>