From f38354e7964a9ddd2f9f1cba4343e1f8ac3313fb Mon Sep 17 00:00:00 2001 From: Stefan Matheis Date: Wed, 19 Jun 2013 20:34:16 +0000 Subject: [PATCH] SOLR-4456: Admin UI: Displays dashboard even if Solr is down git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1494765 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 1 + solr/webapp/web/admin.html | 6 +++ solr/webapp/web/css/styles/common.css | 35 ++++++++++++++ solr/webapp/web/js/scripts/app.js | 69 +++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index f78f725ce6b..899e31b970a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -177,6 +177,7 @@ Bug Fixes * SOLR-4934: Fix handling of init arg "useCompoundFile" needed after changes in LUCENE-5038 (hossman) +* SOLR-4456: Admin UI: Displays dashboard even if Solr is down (steffkes) Optimizations ---------------------- diff --git a/solr/webapp/web/admin.html b/solr/webapp/web/admin.html index 9f5a131b2a0..c99f7f9e0f0 100644 --- a/solr/webapp/web/admin.html +++ b/solr/webapp/web/admin.html @@ -138,6 +138,12 @@ limitations under the License. + +
+ + Connection lost … + +
diff --git a/solr/webapp/web/css/styles/common.css b/solr/webapp/web/css/styles/common.css index 960834e8912..94ef1a4aca9 100644 --- a/solr/webapp/web/css/styles/common.css +++ b/solr/webapp/web/css/styles/common.css @@ -605,4 +605,39 @@ pre.syntax .tex .formula #content .tree a.jstree-search { color:aqua; +} + +#connection_status +{ + display: none; + padding: 30px; +} + +#connection_status span +{ + background-image: url( ../../img/ico/network-status-busy.png ); + background-position: 0 50%; + color: #800; + padding-left: 26px; +} + +#connection_status.online span, +#connection_status.online span a +{ + color: #080; +} + +#connection_status.online span +{ + background-image: url( ../../img/ico/network-status.png ); +} + +#connection_status.online span a +{ + text-decoration: underline; +} + +#connection_status.online span a:hover +{ + text-decoration: none; } \ No newline at end of file diff --git a/solr/webapp/web/js/scripts/app.js b/solr/webapp/web/js/scripts/app.js index e7d51570429..b28494248fb 100644 --- a/solr/webapp/web/js/scripts/app.js +++ b/solr/webapp/web/js/scripts/app.js @@ -585,5 +585,74 @@ var solr_admin = function( app_config ) }; +var connection_check_delay = 1000; +var connection_working = true; + +var connection_check = function connection_check() +{ + $.ajax + ( + { + url : config.solr_path + config.core_admin_path + '?wt=json&indexInfo=false', + dataType : 'json', + context : $( '.blockUI #connection_status span' ), + beforeSend : function( arr, form, options ) + { + this + .addClass( 'loader' ); + }, + success : function( response ) + { + connection_working = true; + + this + .html( 'Instance is available - Reload the page' ); + + this.parents( '#connection_status' ) + .addClass( 'online' ); + + this.parents( '.blockUI' ) + .css( 'borderColor', '#080' ); + }, + error : function() + { + connection_check_delay += connection_check_delay; + window.setTimeout( connection_check, connection_check_delay ); + }, + complete : function() + { + this + .removeClass( 'loader' ); + } + } + ); +}; + +var connection_error = function connection_error() +{ + connection_working = false; + + $.blockUI + ( + { + message: $( '#connection_status' ), + css: { width: '450px', borderColor: '#f00' } + } + ); + + window.setTimeout( connection_check, connection_check_delay ); +} + +$( document ).ajaxError +( + function( event, xhr, settings, thrownError ) + { + if( connection_working && 0 === xhr.status ) + { + connection_error(); + } + } +); + $.ajaxSetup( { cache: false } ); var app = new solr_admin( app_config );