summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rw-r--r--www/js/DataModel.js20
-rw-r--r--www/js/ModalCtrl.js5
2 files changed, 17 insertions, 8 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 5f769676..073f286d 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -643,14 +643,23 @@ angular.module('zmApp.controllers')
// FIXME: Currently a hack - does a screen parse - convert to API based support
//-----------------------------------------------------------------------------
-
- getAuthKey: function ()
+ // need a mid as restricted users won't be able to get
+ // auth with just &watch
+ getAuthKey: function (mid)
{
var d=$q.defer();
+
+ if (!mid)
+ {
+ zmLog ("Deferring auth key, as monitorId unknown");
+ d.resolve("");
+ return(d.promise);
+ }
+
// 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";
- zmDebug ("DataModel: Getting auth from " + myurl);
+ var myurl =loginData.url+"/index.php?view=watch&mid="+mid;
+ zmDebug ("DataModel: Getting auth from " + myurl + " with mid="+mid);
$http.get (myurl)
.then (function (success) {
// console.log ("**** RESULT IS " + JSON.stringify(success));
@@ -902,9 +911,10 @@ angular.module('zmApp.controllers')
zmLog ( (forceReload==1)? "getMonitors:Force reloading all monitors" : "getMonitors:Loading all monitors");
var apiurl = loginData.apiurl;
var myurl = apiurl + "/monitors.json";
+ console.log ("API:"+myurl);
$http.get(myurl /*,{timeout:15000}*/ )
.success(function (data) {
- //console.log("HTTP success got " + JSON.stringify(data.monitors));
+ console.log("HTTP success got " + JSON.stringify(data.monitors));
monitors = data.monitors;
console.log("promise resolved inside HTTP success");
monitorsLoaded = 1;
diff --git a/www/js/ModalCtrl.js b/www/js/ModalCtrl.js
index c39ccecf..e9365186 100644
--- a/www/js/ModalCtrl.js
+++ b/www/js/ModalCtrl.js
@@ -7,8 +7,6 @@
angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce',function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce) {
- console.log("**** INSIDE MODAL CTRL, recomputing rand *****");
-
// from parent scope
var currentEvent=$scope.currentEvent;
@@ -54,7 +52,8 @@ angular.module('zmApp.controllers').controller('ModalCtrl', ['$scope', '$rootSco
showDelay: 0
});
var ld = ZMDataModel.getLogin();
- ZMDataModel.getAuthKey()
+ $rootScope.validMonitorId = $scope.monitors[0].Monitor.Id;
+ ZMDataModel.getAuthKey($rootScope.validMonitorId)
.then(function (success) {
$ionicLoading.hide();
$rootScope.authSession = success;