From 769a42183480e0ac3e7944816c89f7539660abd0 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Thu, 2 Aug 2012 13:28:44 -0400 Subject: [PATCH] Staff client initial hostname Add support for an initial staff client hostname. It can be specified during building the staff client or via configure. During making the staff client: make INITIAL_HOST=hostname build During configure: ./configure --with-initialhost=hostname Signed-off-by: Thomas Berezansky Signed-off-by: Ben Shum --- Open-ILS/xul/staff_client/Makefile.am | 2 ++ .../staff_client/chrome/content/auth/controller.js | 9 ++++-- .../xul/staff_client/chrome/content/main/main.js | 33 ++++++++++++++++++++-- .../defaults/preferences/initialhost.js | 3 ++ configure.ac | 8 ++++++ docs/RELEASE_NOTES_NEXT/initial_host.txt | 12 ++++++++ 6 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/xul/staff_client/defaults/preferences/initialhost.js create mode 100644 docs/RELEASE_NOTES_NEXT/initial_host.txt diff --git a/Open-ILS/xul/staff_client/Makefile.am b/Open-ILS/xul/staff_client/Makefile.am index 9556dfe3a5..2e165a689e 100644 --- a/Open-ILS/xul/staff_client/Makefile.am +++ b/Open-ILS/xul/staff_client/Makefile.am @@ -160,6 +160,8 @@ stamp: @if [ -n "${AUTOUPDATE_HOST}" ]; then echo "Applying automatic update host ${AUTOUPDATE_HOST}"; fi @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/defaults/preferences/autoupdate.js; fi @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/install.rdf; fi + @if [ -z "${INITIAL_HOST}" ]; then rm -f build/defaults/preferences/initialhost.js; fi + @if [ -n "${INITIAL_HOST}" ]; then sed -i -e "s/%INITIAL_HOST%/${INITIAL_HOST}/" build/defaults/preferences/initialhost.js; fi @cp build/STAMP_ID PREV_STAMP_ID @cp build/VERSION PREV_VERSION diff --git a/Open-ILS/xul/staff_client/chrome/content/auth/controller.js b/Open-ILS/xul/staff_client/chrome/content/auth/controller.js index d437a7a7c4..11b9e1a9c7 100644 --- a/Open-ILS/xul/staff_client/chrome/content/auth/controller.js +++ b/Open-ILS/xul/staff_client/chrome/content/auth/controller.js @@ -276,7 +276,6 @@ auth.controller.prototype = { obj.session = new auth.session(obj.controller.view); obj.controller.render(); - obj.test_server( obj.controller.view.server_prompt.value ); obj.controller.render('ws_deck'); if (typeof this.on_init == 'function') { @@ -320,9 +319,15 @@ auth.controller.prototype = { if (x.status == 200) { s.setAttribute('style','color: green;'); } else { + if(x.status == 0) { + s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_hostname')); + obj.controller.view.server_prompt.disabled = false; + obj.controller.view.server_prompt.focus(); + } s.setAttribute('style','color: red;'); } - obj.test_version(url); + if(x.status > 0) + obj.test_version(url); } catch(E) { obj.controller.view.server_prompt.disabled = false; obj.controller.view.server_prompt.focus(); diff --git a/Open-ILS/xul/staff_client/chrome/content/main/main.js b/Open-ILS/xul/staff_client/chrome/content/main/main.js index 139828a745..a86b64278b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/main.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/main.js @@ -724,13 +724,20 @@ function main_init() { document.getElementById('offline_import_btn').disabled = true; } + var should_test_server = true; // Attempt auto-login, if provided if("arguments" in window && window.arguments.length > 0 && window.arguments[0].wrappedJSObject != undefined && window.arguments[0].wrappedJSObject.loginInfo != undefined) { - auto_login(window.arguments[0].wrappedJSObject.loginInfo); + should_test_server = auto_login(window.arguments[0].wrappedJSObject.loginInfo); // Regardless of success, clear that variable now, so we don't possibly have passwords hanging around. window.arguments[0].wrappedJSObject.loginInfo = null; } + if (should_test_server) { + G.auth.test_server(G.auth.controller.view.server_prompt.value); + G.auth.controller.render('ws_deck'); + } + setTimeout(load_init_hostname, 500); + } catch(E) { var error = offlineStrings.getFormattedString('common.exception', [E, '']); try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); } @@ -739,6 +746,18 @@ function main_init() { dump('exiting main_init()\n'); } +function load_init_hostname() { + G.data.stash_retrieve(); + if(!G.auth.controller.view.server_prompt.value) { + try { + G.auth.controller.view.server_prompt.value = G.pref.getCharPref('open-ils.initial_hostname'); + G.auth.test_server(G.pref.getCharPref('open-ils.initial_hostname')); + G.auth.controller.render('ws_deck'); + } catch(E) { + } + } +} + function found_ws_info_in_Achrome() { JSAN.use('util.file'); var f = new util.file(); @@ -784,13 +803,21 @@ function handle_migration() { function auto_login(loginInfo) { G.data.stash_retrieve(); + var should_test_server = true; if(G.data.session) return; // We are logged in. No auto-logoff supported. - if(loginInfo.host) G.auth.controller.view.server_prompt.value = loginInfo.host; + if(loginInfo.host) { + G.auth.controller.view.server_prompt.value = loginInfo.host; + G.auth.test_server(loginInfo.host); + G.auth.controller.render('ws_deck'); + should_test_server = false; + } if(loginInfo.user) G.auth.controller.view.name_prompt.value = loginInfo.user; if(loginInfo.passwd) G.auth.controller.view.password_prompt.value = loginInfo.passwd; if(loginInfo.host && loginInfo.user && loginInfo.passwd && G.data.ws_info && G.data.ws_info[loginInfo.host]) { - G.auth.login(); + // Give test_server time to finish + setTimeout(function() { G.auth.login(); }, 1000); } + return should_test_server; } dump('exiting main/main.js\n'); diff --git a/Open-ILS/xul/staff_client/defaults/preferences/initialhost.js b/Open-ILS/xul/staff_client/defaults/preferences/initialhost.js new file mode 100644 index 0000000000..3b5ad2dfec --- /dev/null +++ b/Open-ILS/xul/staff_client/defaults/preferences/initialhost.js @@ -0,0 +1,3 @@ +// Initial hostname +// For clean installs +pref("open-ils.initial_hostname", "%INITIAL_HOST%"); diff --git a/configure.ac b/configure.ac index 1d99e190cb..89e64f6829 100644 --- a/configure.ac +++ b/configure.ac @@ -106,6 +106,14 @@ AC_ARG_WITH([updateshost], [AUTOUPDATE_HOST=]) AC_SUBST([AUTOUPDATE_HOST]) +# Default updates host? +AC_ARG_WITH([initialhost], +[ --with-initialhost=hostname default hostname for staff client (default is blank)], +[INITIAL_HOST=${withval}], +[INITIAL_HOST=]) +AC_SUBST([INITIAL_HOST]) + + # install Evergreen Apache modules? AC_ARG_ENABLE([apache-modules], [ --disable-apache-modules disables installation of the Evergreen Apache modules ], diff --git a/docs/RELEASE_NOTES_NEXT/initial_host.txt b/docs/RELEASE_NOTES_NEXT/initial_host.txt new file mode 100644 index 0000000000..76994801ff --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/initial_host.txt @@ -0,0 +1,12 @@ +Staff Client Initial Hostname +----------------------------- + +For fresh installs of the staff client a common issue is people remembering what hostname to specify. If you are building your own staff clients you can now fill this in automatically. + +You can specify this when configuring Evergreen with a new configure option: + +--with-initialhost=example.org + +It is also possible to specify when building the staff client itself using the INITIAL_HOST variable: + +make INITIAL_HOST=example.org build -- 2.11.0