[open-ils-commits] r18763 - in trunk/Open-ILS/web/js: dojo/openils ui (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 16 18:33:34 EST 2010


Author: erickson
Date: 2010-11-16 18:33:27 -0500 (Tue, 16 Nov 2010)
New Revision: 18763

Modified:
   trunk/Open-ILS/web/js/dojo/openils/Util.js
   trunk/Open-ILS/web/js/ui/base.js
Log:
in the staff client, use the user object in the XUL stash instead of grabbing the user object on each page load for embedded staff web UIs (/eg/).  This is one less pre-onload XHR and another step in the avoidance of the cursed WSOD.  Added support for launching the xul login dialog after a timed out session event is returned.

Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js	2010-11-16 23:02:25 UTC (rev 18762)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js	2010-11-16 23:33:27 UTC (rev 18763)
@@ -143,7 +143,22 @@
         if(e = openils.Event.parse(testval)) {
             if(eventOk) return e;
             console.log(e.toString());
-            if(openils.Util.alertEvent)
+
+            // session timed out.  Stop propagation of requests queued by Util.onload 
+            // and launch the XUL login dialog if possible
+            var retryLogin = false;
+            if(e.textcode == 'NO_SESSION') {
+                openils.User.authtoken = null; 
+                if(openils.XUL.isXUL()) {
+                    retryLogin = true;
+                    openils.XUL.getNewSession( function() { location.href = location.href } );
+                } else {
+                    // TODO: make the oilsLoginDialog templated via dojo so it can be 
+                    // used as a standalone widget
+                }
+            }
+
+            if(openils.Util.alertEvent && !retryLogin)
                 alert(e);
             return null;
         }

Modified: trunk/Open-ILS/web/js/ui/base.js
===================================================================
--- trunk/Open-ILS/web/js/ui/base.js	2010-11-16 23:02:25 UTC (rev 18762)
+++ trunk/Open-ILS/web/js/ui/base.js	2010-11-16 23:33:27 UTC (rev 18763)
@@ -13,20 +13,26 @@
     var authtoken = cgi.param('ses') || dojo.cookie('ses');
     var workstation = cgi.param('ws') || dojo.cookie('ws');
     var user;
+    var ses_user;
 
     openils.User.user = null;
     openils.User.authtoken = null;
     openils.User.workstation = null;
 
-    if(!authtoken && openils.XUL.isXUL()) {
+    if(openils.XUL.isXUL()) {
 		stash = openils.XUL.getStash();
 		authtoken = stash.session.key
+        ses_user = stash.list.au[0];
 	}
 
     if(authtoken) {
         user = new openils.User();
         delete user.sessionCache[authtoken];
         user.authtoken = authtoken;
+        if(ses_user) {
+            user.user = ses_user;
+            user.sessionCache[authtoken] = ses_user;
+        }
         user.user = user.getBySession();
     }
 



More information about the open-ils-commits mailing list