summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@gmail.com>2018-04-30 10:55:59 -0400
committerPliable Pixels <pliablepixels@gmail.com>2018-04-30 10:55:59 -0400
commitf286615882223adf7bc309c75a142286b5044cc1 (patch)
tree5fa006dcdcde6a223543d5cad4102993741b00a0 /www/js
parentdee2ad4192126f82a7afbe1974b4470b0d0218af (diff)
#618 add token for basic auth as "fyi" for all images
Diffstat (limited to 'www/js')
-rwxr-xr-xwww/js/DataModel.js7
-rw-r--r--www/js/EventCtrl.js66
-rw-r--r--www/js/EventModalCtrl.js88
-rw-r--r--www/js/LoginCtrl.js4
-rw-r--r--www/js/MonitorModalCtrl.js16
-rw-r--r--www/js/MontageCtrl.js4
-rw-r--r--www/js/TimelineModalCtrl.js19
7 files changed, 193 insertions, 11 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 38fd95d5..455e4c0a 100755
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -882,6 +882,7 @@ angular.module('zmApp.controllers')
loginData.basicAuthUser = '';
loginData.basicAuthPassword = '';
$rootScope.basicAuthHeader='';
+ $rootScope.basicAuthToken='';
}
if (loginData.url.indexOf('@') != -1) {
@@ -905,7 +906,8 @@ angular.module('zmApp.controllers')
if (components.port) loginData.apiurl = loginData.apiurl + ":" + components.port;
if (components.path) loginData.apiurl = loginData.apiurl + components.path;
- $rootScope.basicAuthHeader = 'Basic ' + btoa(components.userinfo);
+ $rootScope.basicAuthToken = btoa(components.userinfo);
+ $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken;
//console.log (">>>> SET BASIC AUTH TO " + $rootScope.basicAuthHeader);
var up = components.userinfo.split(':');
@@ -916,7 +918,8 @@ angular.module('zmApp.controllers')
}
if (loginData.isUseBasicAuth) {
- $rootScope.basicAuthHeader = 'Basic ' + btoa(loginData.basicAuthUser+':'+loginData.basicAuthPassword);
+ $rootScope.basicAuthToken = btoa(loginData.basicAuthUser+':'+loginData.basicAuthPassword);
+ $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken;
debug ("Basic authentication detected, constructing Authorization Header");
// console.log ("BASIC AUTH SET TO:"+$rootScope.basicAuthHeader);
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js
index 5e228077..b158b915 100644
--- a/www/js/EventCtrl.js
+++ b/www/js/EventCtrl.js
@@ -960,6 +960,17 @@ angular.module('zmApp.controllers')
//$rootScope.zmPopup = $ionicPopup.alert({title: kFrame+':'+fid+'/'+kEvent+':'+e,template:img, cssClass:'popup80'});
+ if ($rootScope.authSession !='undefined'){
+ $scope.imgsrc +=$rootScope.authSession;
+ $scope.fallbackImgSrc +=$rootScope.authSession;
+ }
+
+ if ($rootScope.basicAuthToken) {
+ $scope.imgsrc +="&basicauth="+$rootScope.basicAuthToken;
+ $scope.fallbackImgSrc +="&basicauth="+$rootScope.basicAuthToken;
+ }
+
+
$rootScope.zmPopup = $ionicPopup.show(
{
template: '<center>' + $translate.instant('kFrame') + ':{{parray[ndx].frameid}}@{{prettifyTimeSec(parray[ndx].time)}}</center><br/><img ng-src="{{imgsrc}}" fallback-src="{{fallbackImgSrc}}" width="100%" />',
@@ -3139,6 +3150,61 @@ angular.module('zmApp.controllers')
};
+ $scope.constructThumbnail = function(event) {
+ var stream = "";
+ stream = event.Event.baseURL+
+ "/index.php?view=image&fid=" +event.Event.MaxScoreFrameId +
+ "&width="+event.Event.thumbWidth*2 +
+ "&height="+event.Event.thumbHeight*2;
+ if ($rootScope.authSession !='undefined') stream+=$rootScope.authSession;
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
+ return stream;
+
+ };
+
+ $scope.constructScrubFrame = function (event,slide) {
+
+ var stream = "";
+ if (event.Event.imageMode=='path') {
+ stream = event.Event.baseURL+"/index.php?view=image"+
+ "&path="+event.Event.relativePath+slide.img+"&height=380";
+
+ }
+ else if (event.Event.imageMode == 'fid') {
+ stream = event.Event.baseURL+"/index.php?view=image"+
+ "&fid="+slide.id;
+ }
+ if ($rootScope.authSession !='undefined') stream+=$rootScope.authSession;
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
+
+ return stream;
+ }
+
+ $scope.constructAlarmFrame = function(event, alarm, motion) {
+ var stream = "";
+
+ if (event.Event.imageMode=='fid') {
+ stream = event.Event.baseURL+
+ "/index.php?view=image&fid=" +alarm.id;
+ if (motion) stream+=$scope.outlineMotionParam;
+
+ }
+ else if (event.Event.imageMode=='path') {
+ st
+ ream = event.Event.baseURL+
+ "/index.php?view=image&path=" +event.Event.relativePath +
+ motion? alarm.aname:alarm.fname +
+ "&height=380";
+
+
+ }
+ if ($rootScope.authSession !='undefined') stream+=$rootScope.authSession;
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
+
+ return stream;
+
+ };
+
$scope.toggleMinAlarmFrameCount = function()
{
diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js
index 6d4444a2..41fb2727 100644
--- a/www/js/EventModalCtrl.js
+++ b/www/js/EventModalCtrl.js
@@ -732,7 +732,25 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
// for alarms only
if (onlyAlarms) $scope.mycarousel.index = 0;
- var url = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.mycarousel.index].img;
+ var url;
+
+ if ($scope.event.Event.imageMode == 'path') {
+ url = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.mycarousel.index].img;
+ }
+ else {
+ url = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand +
+ "&eid=" + $scope.eventId +
+ "&fid=" + $scope.slides[$scope.mycarousel.index].id;
+ }
+
+ if ($rootScope.authSession !='undefined'){
+ url +=$rootScope.authSession;
+
+ }
+ if ($rootScope.basicAuthToken) {
+ url +="&basicauth="+$rootScope.basicAuthToken;
+
+ }
$scope.selectEventUrl = url;
$scope.slideIndex = $scope.mycarousel.index;
@@ -756,7 +774,22 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
onTap: function(e)
{
if ($scope.slideIndex > 0) $scope.slideIndex--;
- $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+
+ if ($scope.event.Event.imageMode=='path') {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+ }
+ else {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&eid=" + $scope.eventId + "&fid=" + $scope.slides[$scope.slideIndex].id;
+ }
+ if ($rootScope.authSession !='undefined'){
+ $scope.selectEventUrl +=$rootScope.authSession;
+
+ }
+ if ($rootScope.basicAuthToken) {
+ $scope.selectEventUrl +="&basicauth="+$rootScope.basicAuthToken;
+
+ }
+
//NVRDataModel.log("selected frame is " + $scope.slideIndex);
//console.log("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img);
@@ -771,7 +804,22 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
onTap: function(e)
{
if ($scope.slideIndex < $scope.slideLastIndex) $scope.slideIndex++;
- $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+
+ if ($scope.event.Event.imageMode=='path') {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+ }
+ else {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&eid=" + $scope.eventId + "&fid=" + $scope.slides[$scope.slideIndex].id;
+ }
+ if ($rootScope.authSession !='undefined'){
+ $scope.selectEventUrl +=$rootScope.authSession;
+
+ }
+ if ($rootScope.basicAuthToken) {
+ $scope.selectEventUrl +="&basicauth="+$rootScope.basicAuthToken;
+
+ }
+
//NVRDataModel.log("selected frame is " + $scope.slideIndex);
//console.log("URL TO DISPLAY " + $scope.slides[$scope.slideIndex].img);
e.preventDefault();
@@ -787,8 +835,21 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
tempVar -= 10;
if (tempVar < 0) tempVar = 0;
$scope.slideIndex = tempVar;
-
- $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+
+ if ($scope.event.Event.imageMode=='path') {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+ }
+ else {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&eid=" + $scope.eventId + "&fid=" + $scope.slides[$scope.slideIndex].id;
+ }
+ if ($rootScope.authSession !='undefined'){
+ $scope.selectEventUrl +=$rootScope.authSession;
+
+ }
+ if ($rootScope.basicAuthToken) {
+ $scope.selectEventUrl +="&basicauth="+$rootScope.basicAuthToken;
+
+ }
//NVRDataModel.log("selected frame is " + $scope.slideIndex);
e.preventDefault();
@@ -805,7 +866,21 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
if (tempVar > $scope.slideLastIndex) tempVar = $scope.slideLastIndex;
$scope.slideIndex = tempVar;
if ($scope.slideIndex < $scope.slideLastIndex) $scope.slideIndex++;
- $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+
+ if ($scope.event.Event.imageMode=='path') {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.slideIndex].img;
+ }
+ else {
+ $scope.selectEventUrl = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&eid=" + $scope.eventId + "&fid=" + $scope.slides[$scope.slideIndex].id;
+ }
+ if ($rootScope.authSession !='undefined'){
+ $scope.selectEventUrl +=$rootScope.authSession;
+
+ }
+ if ($rootScope.basicAuthToken) {
+ $scope.selectEventUrl +="&basicauth="+$rootScope.basicAuthToken;
+
+ }
//NVRDataModel.log("selected frame is " + $scope.slideIndex);
e.preventDefault();
}
@@ -935,6 +1010,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
}
//console.log ("STREAM="+stream);
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
return stream;
};
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index a2fd1ff1..9a21f654 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -553,10 +553,12 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
if (!$scope.loginData.isUseBasicAuth) {
$rootScope.basicAuthHeader = '';
+ $rootScope.basicAuthToken = '';
// console.log ("CLEARING AUTH");
}
else {
- $rootScope.basicAuthHeader = 'Basic ' + btoa($scope.loginData.basicAuthUser+':'+$scope.loginData.basicAuthPassword);
+ $rootScope.basicAuthToken = btoa($scope.loginData.basicAuthUser+':'+$scope.loginData.basicAuthPassword);
+ $rootScope.basicAuthHeader = 'Basic ' + $rootScope.basicAuthToken ;
}
diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js
index b5bfdd92..ed81cd4e 100644
--- a/www/js/MonitorModalCtrl.js
+++ b/www/js/MonitorModalCtrl.js
@@ -225,6 +225,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
//----------------------------------
// toggles monitor cycling
//----------------------------------
+
$scope.toggleCycle = function () {
//console.log ("HERE");
$scope.isCycle = !$scope.isCycle;
@@ -1079,8 +1080,17 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
var canvas, context, imageDataUrl, imageData;
var loginData = NVRDataModel.getLogin();
var url = loginData.streamingurl +
- '/zms?mode=single&monitor=' + mid +
- $rootScope.authSession;
+ '/zms?mode=single&monitor=' + mid;
+
+ if ($rootScope.authSession !='undefined'){
+ url +=$rootScope.authSession;
+
+ }
+ if ($rootScope.basicAuthToken) {
+ url +="&basicauth="+$rootScope.basicAuthToken;
+
+ }
+
NVRDataModel.log("SavetoPhone:Trying to save image from " + url);
var img = new Image();
@@ -1143,6 +1153,8 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
//console.log ("STREAM="+stream);
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
+
return stream;
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index 40497af7..be20a340 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -1713,6 +1713,10 @@ angular.module('zmApp.controllers')
"&buffer=1000" +
$rootScope.authSession +
appendConnKey(monitor.Monitor.connKey);
+
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
+
+
//"&rand=" + randToAvoidCacheMem;
//"&rand="+$scope.randToAvoidCacheMem +
diff --git a/www/js/TimelineModalCtrl.js b/www/js/TimelineModalCtrl.js
index e7a7e2cd..d442b47d 100644
--- a/www/js/TimelineModalCtrl.js
+++ b/www/js/TimelineModalCtrl.js
@@ -49,6 +49,25 @@ angular.module('zmApp.controllers').controller('TimelineModalCtrl', ['$scope', '
}
};
+
+ $scope.constructFrames = function (event,alarm) {
+
+ var stream = "";
+ if (event.Event.imageMode=='path') {
+ stream = event.Event.baseURL + "/index.php?view=image" +
+ "&path="+event.Event.relativePath+alarm.fname +
+ "&height=380";
+ }
+ else if (event.Event.imageMode == 'fid') {
+ stream = event.Event.baseURL + "/index.php?view=image" +
+ "&fid="+alarm.id;
+
+ }
+ if ($rootScope.authSession !='undefined') stream+=$rootScope.authSession;
+ if ($rootScope.basicAuthToken) stream +="&basicauth="+$rootScope.basicAuthToken;
+ return stream;
+ };
+
//-------------------------------------------------------
// we use this to reload the connkey if authkey changed
//------------------------------------------------------