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
This commit is contained in:
Stefan Matheis 2013-06-19 20:34:16 +00:00
parent f5a79d5162
commit f38354e796
4 changed files with 111 additions and 0 deletions

View File

@ -177,6 +177,7 @@ Bug Fixes
* SOLR-4934: Fix handling of <mergePolicy> init arg "useCompoundFile" needed
after changes in LUCENE-5038 (hossman)
* SOLR-4456: Admin UI: Displays dashboard even if Solr is down (steffkes)
Optimizations
----------------------

View File

@ -138,6 +138,12 @@ limitations under the License.
</div>
</div>
<div id="connection_status">
<span>Connection lost …</span>
</div>
<script type="text/javascript"> var require = { urlArgs: '_=${version}' }; </script>
<script src="js/require.js?_=${version}" data-main="js/main"></script>

View File

@ -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;
}

View File

@ -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 - <a href="javascript:location.reload();">Reload the page</a>' );
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 );