toward workstation id
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Mar 2006 15:25:42 +0000 (15:25 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 7 Mar 2006 15:25:42 +0000 (15:25 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3278 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/auth/controller.js
Open-ILS/xul/staff_client/chrome/content/auth/session.js
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/main/main.js
Open-ILS/xul/staff_client/chrome/content/main/main.xul

index c2140f7..5d776e4 100644 (file)
@@ -26,6 +26,19 @@ auth.controller.prototype = {
                                                        obj.login();
                                                }
                                        ],
+                                       'cmd_override' : [
+                                               ['command'],
+                                               function() {
+                                                       obj.override();
+                                               }
+                                       ],
+                                       'cmd_register' : [
+                                               ['command'],
+                                               function() {
+                                                       dump('cmd_register handler\n');
+                                                       obj.register();
+                                               }
+                                       ],
                                        'cmd_logoff' : [
                                                ['command'],
                                                function() {
@@ -38,6 +51,7 @@ auth.controller.prototype = {
                                                        obj.close()
                                                }
                                        ],
+
                                        'server_prompt' : [
                                                ['keypress'],
                                                handle_keypress
@@ -50,37 +64,71 @@ auth.controller.prototype = {
                                                ['keypress'],
                                                handle_keypress
                                        ],
+                                       'wsid_prompt' : [
+                                               ['keypress'],
+                                               handle_keypress
+                                       ],
+
                                        'submit_button' : [
                                                ['render'],
                                                function(e) { return function() {} }
                                        ],
+                                       'register_button' : [
+                                               ['render'],
+                                               function(e) { return function() {} }
+                                       ],
                                        'progress_bar' : [
                                                ['render'],
                                                function(e) { return function() {} }
-                                       ]
+                                       ],
+                                       'status' : [
+                                               ['render'],
+                                               function(e) { return function() {
+                                               } }
+                                       ],
+                                       'ws_deck' : [
+                                               ['render'],
+                                               function(e) { return function() {
+                                               } }
+                                       ],
+                                       'menu_spot' : [
+                                               ['render'],
+                                               function(e) { return function() {
+                                               } }
+                                       ],
+
                                }
                        }
                );
                obj.controller.view.name_prompt.focus();
 
                function handle_keypress(ev) {
-                       if (ev.keyCode && ev.keyCode == 13) {
-                               switch(this) {
-                                       case obj.controller.view.server_prompt:
-                                               ev.preventDefault();
-                                               obj.controller.view.name_prompt.focus(); obj.controller.view.name_prompt.select();
-                                       break;
-                                       case obj.controller.view.name_prompt:
-                                               ev.preventDefault();
-                                               obj.controller.view.password_prompt.focus(); obj.controller.view.password_prompt.select();
-                                       break;
-                                       case obj.controller.view.password_prompt:
-                                               ev.preventDefault();
-                                               obj.controller.view.submit_button.focus(); 
-                                               obj.login();
-                                       break;
-                                       default: break;
+                       try {
+                               if (ev.keyCode && ev.keyCode == 13) {
+                                       switch(this) {
+                                               case obj.controller.view.server_prompt:
+                                                       ev.preventDefault();
+                                                       obj.controller.view.name_prompt.focus(); obj.controller.view.name_prompt.select();
+                                               break;
+                                               case obj.controller.view.name_prompt:
+                                                       ev.preventDefault();
+                                                       obj.controller.view.password_prompt.focus(); obj.controller.view.password_prompt.select();
+                                               break;
+                                               case obj.controller.view.password_prompt:
+                                                       ev.preventDefault();
+                                                       obj.controller.view.submit_button.focus(); 
+                                                       obj.login();
+                                               break;
+                                               case obj.controller.view.wsid_prompt:
+                                                       ev.preventDefault();
+                                                       obj.controller.view.register_button.focus();
+                                                       obj.register();
+                                               break;
+                                               default: break;
+                                       }
                                }
+                       } catch(E) {
+                               alert(E);
                        }
                }
 
@@ -88,6 +136,8 @@ auth.controller.prototype = {
                JSAN.use('auth.session');
                obj.session = new auth.session(obj.controller.view);
 
+               obj.controller.render();
+
                if (typeof this.on_init == 'function') {
                        this.error.sdump('D_AUTH','auth.controller.on_init()\n');
                        this.on_init();
@@ -137,6 +187,43 @@ auth.controller.prototype = {
                }
 
        },
+
+       'register' : function() { 
+               try {
+               dump('register code\n');
+               var obj = this;
+
+               var orgid = obj.controller.view.menu_spot.firstChild.value;
+               var wsname = obj.controller.view.wsid_prompt.value;
+
+               obj.error.sdump('D_AUTH','register workstation with ' + orgid + ' and ' + wsname + '\n'); 
+
+               obj.controller.view.menu_spot.firstChild.disabled = true;
+               obj.controller.view.wsid_prompt.disabled = true;
+
+               try {
+
+                       var server = obj.controller.view.server_prompt.value;
+
+                       if (typeof obj.on_register == 'function') {
+                               dump('calling on_register\n');
+                               obj.on_register(obj.session.key,server,orgid,wsname);
+                       }
+                       
+
+               } catch(E) {
+                       var error = '!! ' + E + '\n';
+                       this.error.sdump('D_ERROR',error); 
+                       alert(error);
+                       this.controller.view.menu_spot.firstChild.disabled = false;
+                       this.controller.view.wsid_prompt.disabled = false;
+               }
+               } catch(E) {
+                       alert(E);
+               }
+
+       },
+
        'logoff' : function() { 
        
                this.error.sdump('D_AUTH','logoff' + this.w + '\n'); 
index 3206adc..2ec6590 100644 (file)
@@ -22,20 +22,30 @@ auth.session.prototype = {
                        );
 
                        if (init) {
+                               JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+
+                               var login_type = data.tmp_login_type || 'staff';
+
+                               var params = [ 
+                                       this.view.name_prompt.value,
+                                       hex_md5(
+                                               init +
+                                               hex_md5(
+                                                       this.view.password_prompt.value
+                                               )
+                                       ),
+                                       login_type,
+                               ];
+
+                               if (data.ws_id) {
+                                       params[3] = null; // org_id
+                                       params[4] = data.ws_id;
+                               }
 
                                var robj = this.network.request(
                                        api.AUTH_COMPLETE.app,
                                        api.AUTH_COMPLETE.method,
-                                       [ 
-                                               this.view.name_prompt.value,
-                                               hex_md5(
-                                                       init +
-                                                       hex_md5(
-                                                               this.view.password_prompt.value
-                                                       )
-                                               ),
-                                               'staff'
-                                       ]
+                                       params
                                );
 
                                if (robj.ilsevent == 0) {
index a8d5449..8d2925a 100644 (file)
@@ -3,6 +3,7 @@ var api = {
        'AUTH_INIT' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.init' },
        'AUTH_COMPLETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.complete' },
        'AUTH_DELETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.session.delete' },
+       'AUTH_WORKSTATION' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.workstation.register' },
        'BILL_PAY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment' },
        'BLOB_CHECKOUTS_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.actor.user.checked_out' },
        'BLOB_MARC_CALLNUMBERS_RETRIEVE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc_cn.retrieve' },
index 6848cf6..28de091 100644 (file)
@@ -48,31 +48,79 @@ function main_init() {
                G.data.entities = entities;
                G.data.stash('entities');
 
+               JSAN.use('util.file');
+               G.file = new util.file();
+               try {
+                       G.file.get('ws_info');
+                       G.ws_info = G.file.get_object();
+                       // { server_name : { 'id' : ..., 'name' : ..., 'owning_lib' : ... }, ... : ... }
+                       alert('retrieved ws_info from filesystem: ' + js2JSON(ws_info) );
+               } catch(E) {
+                       G.ws_info = {};
+                       alert('could not retrieve ws_info from filesystem');
+               }
+               G.data.ws_info = G.ws_info; G.data.stash('ws_info');
+
                G.auth.on_login = function() {
 
                        var url = G.auth.controller.view.server_prompt.value || urls.remote;
                        if (! url.match( '^http://' ) ) url = 'http://' + url;
 
-                       G.data.server = url; G.data.stash('server');
+                       G.data.server = url; G.data.stash('server'); G.data.stash_retrieve();
 
                        grant_perms(url);
 
-                       var deck = document.getElementById('main_deck');
-                       var iframe = document.createElement('iframe'); deck.appendChild(iframe);
-                       iframe.setAttribute( 'src', url + '/xul/server/main/data.xul' );
-                       var xulG = {
-                               'auth' : G.auth,
-                               'url' : url,
-                               'window' : G.window,
+                       if (G.data.ws_info && G.data.ws_info[G.auth.controller.view.server_prompt.value]) {
+                               var deck = document.getElementById('main_deck');
+                               var iframe = document.createElement('iframe'); deck.appendChild(iframe);
+                               iframe.setAttribute( 'src', url + '/xul/server/main/data.xul' );
+                               var xulG = {
+                                       'auth' : G.auth,
+                                       'url' : url,
+                                       'window' : G.window,
+                               }
+                               iframe.contentWindow.xulG = xulG;
+                       } else {
+                               G.auth.controller.view.ws_deck.selectedIndex = 1;
+                               JSAN.use('util.widgets');
+                               var spot = document.getElementById('menu_spot');
+                               util.widgets.remove_children(spot);
+                               var ml = util.widgets.make_menulist( [ ['PINES','1'], ['ARL-ATH','18'] ] );
+                               ml.setAttribute('id','menu');
+                               spot.appendChild(ml);
                        }
-                       iframe.contentWindow.xulG = xulG;
+               }
+
+               G.auth.on_register = function(ses,server,orgid,wsname) {
+                       try {
+                               alert('register happens here: ses = ' + ses + ' server = ' + server + ' orgid = ' + orgid + ' wsname = ' + wsname );
+
+                               var deck = document.getElementById('main_deck');
+                               var iframe = document.createElement('iframe'); deck.appendChild(iframe);
+                               iframe.setAttribute( 'src', G.data.server + '/xul/server/main/register.xul');
+                               var xulG = {
+                                       'auth' : G.auth,
+                                       'url' : G.data.server,
+                                       'window' : G.window,
+                                       'ses' : ses,
+                                       'ws_server' : server,
+                                       'ws_orgid' : orgid,
+                                       'ws_name' : wsname,
+                                       'file' : G.file,
+                               }
+                               iframe.contentWindow.xulG = xulG;
+
+                       } catch(E) {
+                               G.error.sdump('D_ERROR',E);
+                               alert(E);
+                       }
+
                }
 
                G.auth.init();
                // XML_HTTP_SERVER will get reset to G.auth.controller.view.server_prompt.value
 
                /////////////////////////////////////////////////////////////////////////////
-
        } catch(E) {
                var error = "!! This software has encountered an error.  Please tell your friendly " +
                        "system administrator or software developer the following:\n" + E + '\n';
index df65ff5..5aea503 100644 (file)
        </script>
 
        <commandset id="auth_cmds">
-               <command id="cmd_login"/>
+               <command id="cmd_login" />
                <command id="cmd_logoff"/>
+               <command id="cmd_override" />
+               <command id="cmd_register" />
                <command id="cmd_close_window"/>
        </commandset>
 
        <!-- CONTENT -->
        <deck id="main_deck">
        <groupbox id="main_groupbox" flex="1">
-               <caption id="main_caption" label="&staff.auth.login_header;"/>
+               <caption id="main_caption" label="Startup"/>
                <label value="&staff.auth.version;"/>
                <label value="Development Version 123"/>
                <label value=" "/>
                <grid>
-                       <columns>
-                               <column />
-                               <column />
-                       </columns>
-                       <rows>
-                               <row>
-                                       <label value="Server" control="server_prompt" accesskey="r"/>
-                                       <textbox id="server_prompt" value="dev.gapines.org"/>
-                               </row>
-                               <row>
-                                       <label value="&staff.auth.name_prompt;" control="name_prompt" accesskey="&staff.auth.name_prompt.key;"/>
-                                       <textbox id="name_prompt" value=""/>
-                               </row>
-                               <row>
-                                       <label value="&staff.auth.password_prompt;" control="password_prompt" accesskey="&staff.auth.password_prompt.key;"/>
-                                       <textbox id="password_prompt" value="" type="password"/>
-                               </row>
-                               <row>
-                                       <label/>
-                                       <hbox>
-                                       <button id="submit_button" label="&staff.auth.submit_prompt;" accesskey="&staff.auth.submit_prompt.key;" command="cmd_login"/>
-                                       <button label="&staff.auth.logoff_prompt;" accesskey="&staff.auth.logoff_prompt.key;" command="cmd_logoff"/>
-                                       </hbox>
-                               </row>
-                               <row>
-                                       <label/>
-                                       <label/>
-                               </row>
-                               <row>
-                                       <label/>
-                                       <button label="&staff.auth.quit_prompt;" accesskey="&staff.auth.quit_prompt.key;" command="cmd_close_window"/>
-                               </row>
-                       </rows>
+               <columns><column/><column/></columns>
+               <rows>
+               <row>
+                       <groupbox>
+                               <caption label="Server"/>
+                               <grid>
+                                       <columns><column /><column /></columns>
+                                       <rows>
+                                               <row>
+                                                       <label value="Hostname" control="server_prompt" accesskey="H"/>
+                                                       <textbox id="server_prompt" value="dev.gapines.org"/>
+                                               </row>
+                                               <row>
+                                                       <label value="Status"/>
+                                                       <label id="status" value="Online" style="color: green; text-color: green;"/>
+                                               </row>
+                                       </rows>
+                               </grid>
+                       </groupbox>
+                       <groupbox>
+                               <caption label="Workstation"/>
+                               <deck id="ws_deck">
+                                       <description>
+                                               Not yet configured.
+                                       </description>
+                                       <grid>
+                                               <columns><column /><column /></columns>
+                                               <rows>
+                                                       <row>
+                                                               <label value="Library" control="menu_spot"/>
+                                                               <hbox id="menu_spot" />
+                                                       </row>
+                                                       <row>
+                                                               <label value="ID" control="wsid_prompt" />
+                                                               <textbox id="wsid_prompt" />
+                                                       </row>
+                                               </rows>
+                                       </grid>
+                               </deck>
+                       </groupbox>
+               </row>
+               <row>
+                       <groupbox>
+                               <caption label="Authentication"/>
+                               <grid>
+                                       <columns> <column /> <column /> </columns>
+                                       <rows>
+                                               <row>
+                                                       <label value="Username" control="name_prompt" accesskey="U"/>
+                                                       <textbox id="name_prompt" value=""/>
+                                               </row>
+                                               <row>
+                                                       <label value="Password" control="password_prompt" accesskey="P"/>
+                                                       <textbox id="password_prompt" value="" type="password"/>
+                                               </row>
+                                       </rows>
+                               </grid>
+                       </groupbox>
+                       <groupbox>
+                               <caption label="Actions"/>
+                               <grid>
+                                       <columns><column flex="1"/><column /></columns>
+                                       <rows>
+                                               <row>
+                                                       <button id="submit_button" label="Login" accesskey="L" command="cmd_login" />
+                                                       <button id="register_button" label="Register" accesskey="R" command="cmd_register" />
+                                               </row>
+                                               <row>
+                                                       <button label="&staff.auth.logoff_prompt;" accesskey="f" command="cmd_logoff" />
+                                                       <button label="&staff.auth.quit_prompt;" accesskey="&staff.auth.quit_prompt.key;" command="cmd_close_window"/>
+                                               </row>
+                                       </rows>
+                               </grid>
+                       </groupbox>
+               </row>
+               </rows>
                </grid>
                <progressmeter id="progress_bar" mode="normal" value="0"/>
        </groupbox>