From d99c6ffb8ed5b05101dd1d89585cd4bd622262d9 Mon Sep 17 00:00:00 2001 From: pliablepixels Date: Thu, 21 Apr 2016 09:09:22 -0400 Subject: #228 initial code Former-commit-id: a3de04e4b05eecb335611d1ba720548c25c6e8ef --- www/js/DataModel.js | 2 +- www/js/DevOptionsCtrl.js | 2 +- www/js/LoginCtrl.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 3 deletions(-) (limited to 'www/js') diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 9e6188aa..6fb94989 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -821,7 +821,7 @@ angular.module('zmApp.controllers') }) .error (function(error) { zmLog("Error retrieving ZM_PATH_ZMS: " + JSON.stringify(error)); - d.resolve(""); + d.reject(""); return (d.promise); }); return (d.promise); diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js index 3196acbc..a85322cd 100644 --- a/www/js/DevOptionsCtrl.js +++ b/www/js/DevOptionsCtrl.js @@ -21,7 +21,7 @@ angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope' { $rootScope.alarmCount="0"; $ionicHistory.nextViewOptions({disableBack: true}); - ZMDataModel.$state.("events", {"id": 0}, { reload: true }); + $state.go("events", {"id": 0}, { reload: true }); } }; diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index e91c12d8..157a2546 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -1,6 +1,6 @@ /* jshint -W041 */ /* jslint browser: true*/ -/* global cordova,StatusBar,angular,console */ +/* global cordova,StatusBar,angular,console,alert,URI */ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', 'zmAutoLogin', '$cordovaPinDialog', 'EventServer', '$ionicHistory', '$state', '$ionicActionSheet', 'SecuredPopups', '$localstorage', function ($scope, $rootScope, zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, zmAutoLogin, $cordovaPinDialog, EventServer, $ionicHistory, $state, $ionicActionSheet, SecuredPopups, $localstorage) { $scope.openMenu = function () { @@ -245,7 +245,62 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r $scope.ignoreDirty = false; }); + // Make a noble attempt at deciphering + $scope.detectCgi = function() + { + var text = "Typical values:
ubuntu: http://server/zm/cgi-bin
centos/fedora: http://server/zm/cgi-bin-zm/"; + + if ($scope.loginData.url.slice(-1) == '/') { + $scope.loginData.url = $scope.loginData.url.slice(0, -1); + + } + + ZMDataModel.getPathZms() + .then (function (data) + { + var c=URI.parse($scope.loginData.url); + var p1,p2,p3; + p1 =""; + p2 =""; + + if (c.userinfo) + p1 = c.userinfo+"@"; + if (c.port) + p2 = ":"+c.port; + + var baseUri = c.scheme+"://"+p1+c.host+p2; + var dtext = baseUri + data.toLowerCase().trim(); + dtext = dtext.substr(0, dtext.lastIndexOf("/")); + + text = "Your cgi-bin path may be " + dtext + "

" + text; + + $rootScope.zmPopup = SecuredPopups.show('show',{ + title: 'cgi-bin settings', + cssClass: 'popup90', + template: text, + buttons: [{text: 'Ok'},{text:'Use suggestion', onTap:function(e) {$scope.loginData.streamingurl=dtext;}}] + + }); + + + }, + function (error) + { + ZMDataModel.zmDebug ("Could not get PATH_ZMS:"+JSON.stringify(error)); + text = "(could not detect cgi-path, try coming back here after setting up your portal url and credentials correctly)

"+text; + $rootScope.zmPopup = SecuredPopups.show('alert',{ + title: 'cgi-bin settings', + cssClass: 'popup90', + + template: text + }); + + }); + + + + }; //-------------------------------------------------------------------------- // When PIN is enabled, this is called to specify a PIN -- cgit v1.2.3