From: Mike Rylander Date: Fri, 7 Jul 2017 15:49:55 +0000 (-0400) Subject: offline: WebSockets + no network = chaos X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0bc44ce8cd7620d4517d402bd5bb00ecf0fbcc73;p=working%2FEvergreen.git offline: WebSockets + no network = chaos Check for specific network and UI conditions and avoid using WebSockets when they would freeze the offline interface. Also, correct a typo in file loading. Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/templates/staff/index.tt2 b/Open-ILS/src/templates/staff/index.tt2 index bcb7a14ed8..cd65d7acf7 100644 --- a/Open-ILS/src/templates/staff/index.tt2 +++ b/Open-ILS/src/templates/staff/index.tt2 @@ -6,7 +6,7 @@ [% BLOCK APP_JS %] - + [% END %] diff --git a/Open-ILS/web/js/ui/default/staff/offline.js b/Open-ILS/web/js/ui/default/staff/offline.js index a4eef877b2..dab4065b51 100644 --- a/Open-ILS/web/js/ui/default/staff/offline.js +++ b/Open-ILS/web/js/ui/default/staff/offline.js @@ -254,6 +254,14 @@ function($routeProvider , $locationProvider , $compileProvider) { function($q , $scope , $window , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog , egUnloadPrompt) { $scope.active_tab = $routeParams.tab || 'checkout'; + // Immediately redirect if we're really offline + if (!$window.navigator.onLine) { + if ($location.path().match(/session$/)) { + var path = $location.path(); + return $location.path(path.replace('session','checkout')); + } + } + var today = new Date(); today.setHours(0); today.setMinutes(0); diff --git a/Open-ILS/web/js/ui/default/staff/services/auth.js b/Open-ILS/web/js/ui/default/staff/services/auth.js index 4e9895642f..3ee2296923 100644 --- a/Open-ILS/web/js/ui/default/staff/services/auth.js +++ b/Open-ILS/web/js/ui/default/staff/services/auth.js @@ -61,23 +61,33 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch) { if (token) { - egNet.request( - 'open-ils.auth', - 'open-ils.auth.session.retrieve', token) - - .then(function(user) { - if (user && user.classname) { - // authtoken test succeeded - service.user(user); - service.poll(); - service.check_workstation(deferred); - - } else { - // authtoken test failed - egHatch.clearLoginSessionItems(); - deferred.reject(); - } - }); + if (lf.isOffline && !$location.path().match(/\/session/) ) { + // Just stop here if we're in the offline interface but not on the session tab + $timeout(function(){deferred.resolve()}); + } else if (lf.isOffline && $location.path().match(/\/session/) && !$window.navigator.onLine) { + // Likewise, if we're in the offline interface on the session tab and the network is down. + // The session tab itself will redirect appropriately due to no network. + $timeout(function(){deferred.resolve()}); + } else { + // Otherwise, check the token. This will freeze all other interfaces, which is what we want. + egNet.request( + 'open-ils.auth', + 'open-ils.auth.session.retrieve', token) + + .then(function(user) { + if (user && user.classname) { + // authtoken test succeeded + service.user(user); + service.poll(); + service.check_workstation(deferred); + + } else { + // authtoken test failed + egHatch.clearLoginSessionItems(); + deferred.reject(); + } + }); + } } else { // no authtoken to test