summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorPliablePixels <pliablepixels@gmail.com>2015-08-28 11:52:59 -0400
committerPliablePixels <pliablepixels@gmail.com>2015-08-28 11:52:59 -0400
commitb9f387782bf9ea222d52eac954f1bddad8131391 (patch)
tree94e349c9e2ff709237e32adf0cc9f25632391874 /www
parent4332c99d924cd00b6a6e5f1b306db8da58b2ab59 (diff)
Implemented auth key into the app so each image refresh in Montage and Monitor view does not hit the ZM DB and generate a million records. Solves the log pings of https://github.com/pliablepixels/zmNinja/issues/26
Diffstat (limited to 'www')
-rw-r--r--www/js/DataModel.js52
-rw-r--r--www/js/ModalCtrl.js28
-rw-r--r--www/js/MontageCtrl.js32
-rw-r--r--www/js/app.js20
-rw-r--r--www/templates/monitors-modal.html15
-rw-r--r--www/templates/montage.html22
6 files changed, 157 insertions, 12 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 44992a3f..48a09b52 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -280,6 +280,56 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion
{
displayBanner (mytype, mytext, myinterval, mytimer);
},
+
+ //-----------------------------------------------------------------------------
+ // Grabs the computed auth key for streaming
+ // FIXME: Currently a hack - does a screen parse - convert to API based support
+ //-----------------------------------------------------------------------------
+
+ getAuthKey: function ()
+ {
+ var d=$q.defer();
+ // Skipping monitor number as I only need an auth key
+ // so no need to generate an image
+ var myurl =loginData.url+"/index.php?view=watch";
+ console.log ("Getting auth from " + myurl);
+ $http.get (myurl)
+ .then (function (success) {
+ // console.log ("**** RESULT IS " + JSON.stringify(success));
+ // Look for auth=
+ var auth = success.data.match ("auth=(.*?)&");
+ if (auth && (auth[1] != null))
+ {
+ zmLog ("DataModel: Extracted a stream authentication key of: " + auth[1]);
+ d.resolve("&auth="+auth[1]);
+ }
+ else
+ {
+ zmLog ("DataModel: Did not find a stream auth key, looking for user=");
+ auth = success.data.match ("user=(.*?)&");
+ if (auth && (auth[1] != null))
+ {
+ zmLog ("DataModel: Found simple stream auth mode (user=)");
+ d.resolve("&user="+loginData.username+"&pass="+loginData.password);
+ }
+ else
+ {
+ zmLog ("Data Model: Did not find any stream mode of auth");
+ d.resolve("");
+ }
+ return (d.promise);
+ }
+
+ },
+ function (error) {
+ zmLog ("DataModel: Error resolving auth key " + JSON.stringify(error));
+ d.resolve ("");
+ return (d.promise);
+ });
+ return (d.promise);
+
+ },
+
//-----------------------------------------------------------------------------
// This function returns the numdigits for padding capture images
//-----------------------------------------------------------------------------
@@ -298,6 +348,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion
zmLog ("ZM_EVENT_IMAGE_DIGITS is " + data.config.Value);
configParams.ZM_EVENT_IMAGE_DIGITS = data.config.Value;
d.resolve(configParams.ZM_EVENT_IMAGE_DIGITS);
+ return (d.promise);
})
.error (function(err) {
@@ -306,6 +357,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion
// FIXME: take a plunge and keep it at 5?
configParams.ZM_EVENT_IMAGE_DIGITS = 5;
d.resolve(configParams.ZM_EVENT_IMAGE_DIGITS);
+ return (d.promise);
});
}
else
diff --git a/www/js/ModalCtrl.js b/www/js/ModalCtrl.js
index 24926641..3cb2787d 100644
--- a/www/js/ModalCtrl.js
+++ b/www/js/ModalCtrl.js
@@ -34,6 +34,34 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco
document.addEventListener("pause", onPause, false);
document.addEventListener("resume", onResume, false);
+ $rootScope.authSession = "undefined";
+ $ionicLoading.show({
+ template: 'negotiating stream authentication...',
+ animation: 'fade-in',
+ showBackdrop: true,
+ duration: zm.loadingTimeout,
+ maxWidth: 300,
+ showDelay: 0
+ });
+ var ld = ZMDataModel.getLogin();
+ ZMDataModel.getAuthKey()
+ .then(function(success)
+ {
+ $ionicLoading.hide();
+ $rootScope.authSession = success;
+ ZMDataModel.zmLog ("Modal: Stream authentication construction: " + $rootScope.authSession);
+
+ },
+ function (error)
+ {
+
+ $ionicLoading.hide();
+ console.log (error);
+ //$rootScope.authSession="";
+ ZMDataModel.zmLog ("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession);
+ });
+
+
$scope.radialMenuOptions = {
content: '',
diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js
index e7941ccf..26e5af6b 100644
--- a/www/js/MontageCtrl.js
+++ b/www/js/MontageCtrl.js
@@ -158,6 +158,38 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', '
$scope.LoginData = ZMDataModel.getLogin();
$scope.monLimit = $scope.LoginData.maxMontage;
console.log("********* Inside Montage Ctrl, MAX LIMIT=" + $scope.monLimit);
+
+
+ $rootScope.authSession = "undefined";
+ $ionicLoading.show({
+ template: 'negotiating stream authentication...',
+ animation: 'fade-in',
+ showBackdrop: true,
+ duration: zm.loadingTimeout,
+ maxWidth: 300,
+ showDelay: 0
+ });
+
+
+ var ld = ZMDataModel.getLogin();
+ ZMDataModel.getAuthKey()
+ .then(function(success)
+ {
+ $ionicLoading.hide();
+ console.log (success);
+ $rootScope.authSession =success;
+ ZMDataModel.zmLog ("Stream authentication construction: " +
+ $rootScope.authSession);
+
+ },
+ function (error)
+ {
+
+ $ionicLoading.hide();
+ console.log (error);
+ //$rootScope.authSession="";
+ ZMDataModel.zmLog ("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession);
+ });
// I was facing a lot of problems with Chrome/crosswalk getting stuck with
diff --git a/www/js/app.js b/www/js/app.js
index bbcc50a8..20066d2d 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -370,6 +370,26 @@ angular.module('zmApp', [
d.reject("Login Error");
}
+
+ // Now go ahead and re-get auth key
+ $rootScope.authSession="undefined";
+ var ld = ZMDataModel.getLogin();
+ ZMDataModel.getAuthKey()
+ .then(function(success)
+ {
+
+ console.log (success);
+ $rootScope.authSession = success;
+ ZMDataModel.zmLog ("Stream authentication construction: " +
+ $rootScope.authSession);
+
+ },
+ function (error)
+ {
+ console.log (error);
+ //$rootScope.authSession="";
+ ZMDataModel.zmLog ("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession);
+ });
return (d.promise);
diff --git a/www/templates/monitors-modal.html b/www/templates/monitors-modal.html
index 06a4edc3..1fe642fb 100644
--- a/www/templates/monitors-modal.html
+++ b/www/templates/monitors-modal.html
@@ -11,13 +11,18 @@
<!-- android needs this 100vh - otherwise max- does not work -->
<div style="height: 100vh;" class="main">
-
- <img imageonload="finishedLoadingImage()"
- image-spinner-loader="lines"
- image-spinner-src="{{LoginData.streamingurl}}/cgi-bin/nph-zms?mode=single&monitor={{monitorId}}&maxfps={{LoginData.maxFPS}}&user={{LoginData.username}}&pass={{LoginData.password}}&rand={{$root.modalRand}}" ng-class="{'zm-image-fit':imageFit==true, 'zm-image-crop':imageFit==false}" on-swipe-left="onSwipeLeft(monitorId,-1)" on-swipe-right="onSwipeRight(monitorId,1)" />
+ <div ng-if="$root.authSession!='undefined'">
+ <img imageonload="finishedLoadingImage()"
+ image-spinner-loader="lines"
+ image-spinner-src="{{LoginData.streamingurl}}/cgi-bin/nph-zms?mode=single&monitor={{monitorId}}&maxfps={{LoginData.maxFPS}}{{$root.authSession}}&rand={{$root.modalRand}}" ng-class="{'zm-image-fit':imageFit==true, 'zm-image-crop':imageFit==false}" on-swipe-left="onSwipeLeft(monitorId,-1)" on-swipe-right="onSwipeRight(monitorId,1)" />
+ </div>
+ <div ng-if="$root.authSession=='undefined'">
+ <img id="img-$index" ng-src="img/pausevideo.png" style="display:block;"
+ width="{{((devWidth)/(7-monitorSize[$index]))}}px;"/>
+ </div>
</div>
</ion-scroll>
-
+ <!--url: {{LoginData.streamingurl}}/cgi-bin/nph-zms?mode=single&amp;monitor={{monitorId}}&amp;maxfps={{LoginData.maxFPS}}&amp;{{$root.authSession}}&amp;rand={{$root.modalRand}}-->
</ion-content>
diff --git a/www/templates/montage.html b/www/templates/montage.html
index 7a192c54..d0a9d624 100644
--- a/www/templates/montage.html
+++ b/www/templates/montage.html
@@ -47,15 +47,23 @@
<!-- moving to single so I can rely on rand for reloads -->
<div ng-if="!isModalActive">
- <img id="img-$index" image-spinner-src="{{LoginData.streamingurl}}/cgi-bin/nph-zms?mode=single&monitor={{monitor.Monitor.Id}}&maxfps={{LoginData.maxFPS}}&scale=50&user={{LoginData.username}}&pass={{LoginData.password}}&rand={{$root.rand}}" width="{{((devWidth)/(7-monitorSize[$index]))}}px;"
- ng-click="openModal(monitor.Monitor.Id, monitor.Monitor.Controllable, monitor.Monitor.ControlId)"
- on-hold="onHold($index)"
- on-release="onRelease($index)"
- style="display:block;" image-spinner-loader="lines"
-
- />
+
+ <div ng-if="$root.authSession!='undefined'">
+ <img id="img-$index" image-spinner-src="{{LoginData.streamingurl}}/cgi-bin/nph-zms?mode=single&monitor={{monitor.Monitor.Id}}&maxfps={{LoginData.maxFPS}}&scale=50{{$root.authSession}}&rand={{$root.rand}}" width="{{((devWidth)/(7-monitorSize[$index]))}}px;"
+ ng-click="openModal(monitor.Monitor.Id, monitor.Monitor.Controllable, monitor.Monitor.ControlId)"
+ on-hold="onHold($index)"
+ on-release="onRelease($index)"
+ style="display:block;" image-spinner-loader="lines"
+
+ />
+ </div>
+ <div ng-if="!$root.authSession=='undefined'">
+ <img id="img-$index" ng-src="img/pausevideo.png" style="display:block;"
+ width="{{((devWidth)/(7-monitorSize[$index]))}}px;"/>
</div>
+ </div>
+ <!--url: {{LoginData.streamingurl}}/cgi-bin/nph-zms?mode=single&amp;monitor={{monitor.Monitor.Id}}&amp;maxfps={{LoginData.maxFPS}}&amp;scale=50&amp;{{$root.authSession}}&amp;rand={{$root.rand}}-->
<div ng-if="isModalActive">
<img id="img-$index" ng-src="img/pausevideo.png" style="display:block;" width="{{((devWidth)/(7-monitorSize[$index]))}}px;"/>
</div>