prompt for server at startup
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Dec 2005 12:07:54 +0000 (12:07 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Dec 2005 12:07:54 +0000 (12:07 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2531 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index b47c4c2..b916adf 100644 (file)
@@ -38,6 +38,10 @@ auth.controller.prototype = {
                                                        obj.close()
                                                }
                                        ],
+                                       'server_prompt' : [
+                                               ['keypress'],
+                                               handle_keypress
+                                       ],
                                        'name_prompt' : [
                                                ['keypress'],
                                                handle_keypress
@@ -62,6 +66,10 @@ auth.controller.prototype = {
                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();
@@ -92,11 +100,14 @@ auth.controller.prototype = {
 
                this.error.sdump('D_AUTH','login with ' 
                        + this.controller.view.name_prompt.value + ' and ' 
-                       + this.controller.view.password_prompt.value + '\n'
+                       + this.controller.view.password_prompt.value + ' at ' 
+                       + this.controller.view.server_prompt.value + '\n'
                ); 
+               this.controller.view.server_prompt.disabled = true;
                this.controller.view.name_prompt.disabled = true;
                this.controller.view.password_prompt.disabled = true;
                this.controller.view.submit_button.disabled = true;
+               XML_HTTP_SERVER = this.controller.view.server_prompt.value;
 
                try {
 
@@ -114,6 +125,10 @@ auth.controller.prototype = {
                        this.error.sdump('D_ERROR',error); 
                        alert(error);
                        this.logoff();
+                       if (E == 'open-ils.auth.authenticate.init returned false\n') {
+                               this.controller.view.server_prompt.focus();
+                               this.controller.view.server_prompt.select();
+                       }
 
                        if (typeof this.on_login_error == 'function') {
                                this.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
@@ -133,6 +148,7 @@ auth.controller.prototype = {
                this.controller.view.name_prompt.disabled = false;
                this.controller.view.name_prompt.focus(); 
                this.controller.view.name_prompt.select();
+               this.controller.view.server_prompt.disabled = false;
 
                this.session.close();
 
index 37b5031..c54083c 100644 (file)
@@ -1,15 +1,18 @@
 dump('entering main/main.js\n');
 
+function grant_perms(url) {
+       var pref = Components.classes["@mozilla.org/preferences-service;1"]
+               .getService(Components.interfaces.nsIPrefBranch);
+       if (pref) {
+               pref.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
+               pref.setCharPref("capability.principal.codebase.p0.id", url);
+       }
+
+}
+
 function main_init() {
        dump('entering main_init()\n');
        try {
-               var pref = Components.classes["@mozilla.org/preferences-service;1"]
-                       .getService(Components.interfaces.nsIPrefBranch);
-               if (pref) {
-                       pref.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
-                       pref.setCharPref("capability.principal.codebase.p0.id", urls.remote);
-               }
-
                if (typeof JSAN == 'undefined') {
                        throw(
                                "The JSAN library object is missing."
@@ -49,11 +52,15 @@ function main_init() {
 
                        G.OpenILS.data.session = G.auth.session.key;
                        G.OpenILS.data.on_complete = function () {
+
+                               var url = G.auth.controller.view.server_prompt.value || urls.remote;
+                               if (! url.match( '^http://' ) ) url = 'http://' + url;
+                               grant_perms(url);
                                
                                G.OpenILS.data.stash('list','hash','temp');
                                G.OpenILS.data._debug_stash();
 
-                               G.window.open(urls.remote + urls.remote_menu_frame 
+                               G.window.open(url + urls.remote_menu_frame 
                                        + '?session='+mw.escape(G.auth.session.key)
                                        + '&authtime='+mw.escape(G.auth.session.authtime),
                                        'test','chrome,resizable');
@@ -62,6 +69,7 @@ function main_init() {
                }
 
                G.auth.init();
+               // XML_HTTP_SERVER will get reset to G.auth.controller.view.server_prompt.value
 
                /////////////////////////////////////////////////////////////////////////////
 
index e4f7199..71d9cfa 100644 (file)
@@ -28,7 +28,9 @@
        <scripts id="openils_util_scripts"/>
 
        <script type="text/javascript" src="chrome://evergreen/content/main/lang.js"/>
+       <!--
        <script type="text/javascript" src="http://dev.gapines.org/xul/server/main/lang.js"/>
+       -->
        <script type="text/javascript" src="chrome://evergreen/content/main/JSAN.js"/>
        <script type="text/javascript" src="chrome://evergreen/content/main/main.js"/>
        <script>
                        </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>
@@ -88,7 +94,6 @@
                </grid>
                <progressmeter id="progress_bar" mode="normal" value="0"/>
        </groupbox>
-       <iframe src="doesnotexist.xxx"/>
        </deck>
 
 </window>