diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2018-08-17 09:47:59 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2018-08-17 09:47:59 -0400 |
| commit | 43df6a5c001540690df76a888f42c64fc3310115 (patch) | |
| tree | 4b7cff6689485002ffafcfeb70454d287a2543c9 | |
| parent | 548c4cf8662e0c7b64cb84ff038a7fc548144cd2 (diff) | |
#681 make sure falllback happens in reasonable time, also improve progress messages to keep user updated
| -rwxr-xr-x | www/js/DataModel.js | 13 | ||||
| -rwxr-xr-x | www/js/app.js | 40 | ||||
| -rw-r--r-- | www/lang/locale-en.json | 2 |
3 files changed, 45 insertions, 10 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 49fb2460..26c3cd3b 100755 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -2644,6 +2644,13 @@ angular.module('zmApp.controllers') logout: function () { // always resolves + + $ionicLoading.show({ + template: $translate.instant('kCleaningUp'), + noBackdrop: true, + + }); + var d = $q.defer(); log(loginData.url + "=>Logging out of any existing ZM sessions..."); $rootScope.authSession = "undefined"; @@ -2654,14 +2661,16 @@ angular.module('zmApp.controllers') if (loginData.currentServerVersion && (versionCompare(loginData.currentServerVersion, zm.versionWithLoginAPI) != -1 || loginData.loginAPISupported)) { debug ("Logging out using API method"); - $http.get(loginData.apiurl+'/host/logout.json') + $http.get(loginData.apiurl+'/host/logout.json',{timeout: 7000}) .then (function(s) { debug ("Logout returned... "); d.resolve(true); + $ionicLoading.hide(); return d.promise; }, function (e) { debug ("Logout errored but really don't worry, your ZM version may not support it"); + $ionicLoading.hide(); d.resolve(true); return d.promise; } @@ -2674,7 +2683,7 @@ angular.module('zmApp.controllers') debug ("Logging out using Web method"); $http({ method: 'POST', - timeout: 10000, + timeout: 7000, //withCredentials: true, url: loginData.url + '/index.php', headers: { diff --git a/www/js/app.js b/www/js/app.js index 2b3c9990..0d776437 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -48,8 +48,8 @@ angular.module('zmApp', [ castAppId: 'BA30FB4C', alarmFlashTimer: 20000, // time to flash alarm gcmSenderId: '710936220256', - httpTimeout: 15000, - largeHttpTimeout: 60000, + httpTimeout: 10000, + largeHttpTimeout: 30000, logFile: 'zmNinjaLog.txt', authoremail: 'pliablepixels+zmNinja@gmail.com', logFileMaxSize: 30000, // after this limit log gets reset @@ -947,6 +947,7 @@ angular.module('zmApp', [ var ld = NVRDataModel.getLogin(); var statename = $ionicHistory.currentStateName(); + if (statename == "montage-history") { NVRDataModel.log("Skipping login process as we are in montage history. Re-logging will mess up the stream"); @@ -978,21 +979,29 @@ angular.module('zmApp', [ function (error) // login to main failed, so try others { + $ionicLoading.show({ + template: $translate.instant('kReachabilityFailed'), + noBackdrop: true, + + }); NVRDataModel.debug(">>>>>>>>>>>> Failed first login, trying reachability"); NVRDataModel.getReachableConfig(true) .then(function (data) { proceedWithLogin() .then(function (success) { d.resolve(success); + $ionicLoading.hide(); return d.promise; }, function (error) { + $ionicLoading.hide(); d.reject(error); return d.promise; }); }, function (error) { + $ionicLoading.hide(); d.reject(error); return d.promise; }); @@ -1014,7 +1023,7 @@ angular.module('zmApp', [ var d = $q.defer(); var ld = NVRDataModel.getLogin(); NVRDataModel.log("zmAutologin called"); - + var httpDelay = NVRDataModel.getLogin().enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout; // This is a good time to check if auth is used :-p if (!ld.isUseAuth) { @@ -1028,11 +1037,13 @@ angular.module('zmApp', [ } + if (!str) str = $translate.instant ('kAuthenticating'); + if (str) { $ionicLoading.show({ template: str, noBackdrop: true, - duration: zm.httpTimeout + duration: httpDelay }); } @@ -1044,11 +1055,14 @@ angular.module('zmApp', [ //first login using new API var loginAPI = loginData.apiurl + '/host/login.json'; + $http({ method:'POST', url: loginAPI, + timeout:httpDelay, headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + transformRequest: function(obj) { var str = []; for(var p in obj) @@ -1060,7 +1074,7 @@ angular.module('zmApp', [ //$http.get(loginAPI) .then(function (succ) { - + $ionicLoading.hide(); if (!succ.data.version) { NVRDataModel.debug ("API login returned fake success, going back to webscrape"); @@ -1074,6 +1088,7 @@ angular.module('zmApp', [ return d.promise; }, function (err) { + $ionicLoading.hide(); d.reject("Login Error"); return (d.promise); }); @@ -1161,11 +1176,20 @@ angular.module('zmApp', [ var loginData = NVRDataModel.getLogin(); var d = $q.defer(); NVRDataModel.debug("Logging in using old web-scrape method"); + + $ionicLoading.show({ + template: $translate.instant('kAuthenticatingWebScrape'), + noBackdrop: true, + duration: httpDelay + }); + + NVRDataModel.isReCaptcha() .then(function (result) { if (result == true) { $ionicLoading.hide(); NVRDataModel.displayBanner('error', ['reCaptcha must be disabled', ], "", 8000); + $ionicLoading.hide(); var alertPopup = $ionicPopup.alert({ title: 'reCaptcha enabled', template: $translate.instant('kRecaptcha'), @@ -1185,12 +1209,12 @@ angular.module('zmApp', [ }); - var hDelay = loginData.enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout; + var httpDelay = NVRDataModel.getLogin().enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout; //NVRDataModel.debug ("*** AUTH LOGIN URL IS " + loginData.url); $http({ method: 'POST', - timeout: hDelay, + timeout: httpDelay, //withCredentials: true, url: loginData.url + '/index.php', headers: { @@ -2078,7 +2102,7 @@ angular.module('zmApp', [ //--------------------------------------------------------------------------- // background handler //---------------------------------------------------------------------------- - document.addEventListener("pause", function () { + document.addEventListener("pause", function (mtask) { NVRDataModel.setBackground(true); NVRDataModel.setJustResumed(false); // NVRDataModel.setJustResumed(true); // used for window stop diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index cb776682..76b42f72 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -17,6 +17,7 @@ "kAt" :"at", "kAuthSuccess" :"authentication success", "kAuthenticating" :"authenticating", + "kAuthenticatingWebScrape" : "authenticating via web scrape", "kAutoSwitchBW" :"auto switch bandwidth", "kAwake1" :"Keep display on", "kAwake2" :"(when viewing footage)", @@ -294,6 +295,7 @@ "kProfileChangeNotification" :"You have changed from {{oldName}} to {{newName}}. Please save this profile first", "kProtect" :"protect", "kPullToReload" :"pull to reload data", + "kReachabilityFailed" : "primary login failed, trying fallbacks", "kReAuthenticating" :"re-authenticating", "kRecaptcha" :"Looks like you have enabled reCaptcha. It needs to be turned off for the app to work", "kReconfirmPin" :"Reconfirm PIN", |
