SOLR-3851: create a new core/delete an existing core should also update the main/left list of cores on the admin UI

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1429286 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stefan Matheis 2013-01-05 14:21:28 +00:00
parent f51a29707f
commit 348f84c32f
3 changed files with 111 additions and 72 deletions

View File

@ -222,6 +222,9 @@ Optimizations
* SOLR-4261: Percentage Infos on Dashboard have a fixed width (steffkes) * SOLR-4261: Percentage Infos on Dashboard have a fixed width (steffkes)
* SOLR-3851: create a new core/delete an existing core should also update
the main/left list of cores on the admin UI (steffkes)
Bug Fixes Bug Fixes
---------------------- ----------------------

View File

@ -172,29 +172,40 @@ var solr_admin = function( app_config )
} }
}; };
this.run = function() sort_cores_data = function sort_cores_data( cores_status )
{ {
$.ajax // build array of core-names for sorting
( var core_names = [];
for( var core_name in cores_status )
{ {
url : config.solr_path + config.core_admin_path + '?wt=json', core_names.push( core_name );
dataType : 'json', }
beforeSend : function( arr, form, options ) core_names.sort();
{
$( '#content' )
.html( '<div id="index"><div class="loader">Loading ...</div></div>' );
},
success : function( response )
{
self.cores_data = response.status;
var core_count = 0;
for( var core_name in response.status ) var core_count = core_names.length;
var cores = {};
for( var i = 0; i < core_count; i++ )
{
var core_name = core_names[i];
cores[core_name] = cores_status[core_name];
}
return cores;
};
this.set_cores_data = function set_cores_data( cores )
{
self.cores_data = sort_cores_data( cores.status );
self.menu_element
.empty();
var core_count = 0;
for( var core_name in self.cores_data )
{ {
core_count++; core_count++;
var core_path = config.solr_path + '/' + core_name; var core_path = config.solr_path + '/' + core_name;
var schema = response['status'][core_name]['schema'];
var solrconfig = response['status'][core_name]['config'];
var classes = []; var classes = [];
if( !environment_basepath ) if( !environment_basepath )
@ -202,7 +213,7 @@ var solr_admin = function( app_config )
environment_basepath = core_path; environment_basepath = core_path;
} }
if( response['status'][core_name]['isDefaultCore'] ) if( cores.status[core_name]['isDefaultCore'] )
{ {
classes.push( 'default' ); classes.push( 'default' );
} }
@ -210,8 +221,8 @@ var solr_admin = function( app_config )
var core_tpl = '<li id="' + core_name.replace( /\./g, '__' ) + '" ' var core_tpl = '<li id="' + core_name.replace( /\./g, '__' ) + '" '
+ ' class="' + classes.join( ' ' ) + '"' + ' class="' + classes.join( ' ' ) + '"'
+ ' data-basepath="' + core_path + '"' + ' data-basepath="' + core_path + '"'
+ ' schema="' + schema + '"' + ' schema="' + cores.status[core_name]['schema'] + '"'
+ ' config="' + solrconfig + '"' + ' config="' + cores.status[core_name]['config'] + '"'
+ '>' + "\n" + '>' + "\n"
+ ' <p><a href="#/' + core_name + '">' + core_name + '</a></p>' + "\n" + ' <p><a href="#/' + core_name + '">' + core_name + '</a></p>' + "\n"
+ ' <ul>' + "\n" + ' <ul>' + "\n"
@ -233,16 +244,16 @@ var solr_admin = function( app_config )
.append( core_tpl ); .append( core_tpl );
} }
if( response.initFailures ) if( cores.initFailures )
{ {
var failures = []; var failures = [];
for( var core_name in response.initFailures ) for( var core_name in cores.initFailures )
{ {
failures.push failures.push
( (
'<li>' + '<li>' +
'<strong>' + core_name.esc() + ':</strong>' + "\n" + '<strong>' + core_name.esc() + ':</strong>' + "\n" +
response.initFailures[core_name].esc() + "\n" + cores.initFailures[core_name].esc() + "\n" +
'</li>' '</li>'
); );
} }
@ -262,8 +273,33 @@ var solr_admin = function( app_config )
( (
'<div class="message">There are no SolrCores running. <br/> Using the Solr Admin UI currently requires at least one SolrCore.</div>' '<div class="message">There are no SolrCores running. <br/> Using the Solr Admin UI currently requires at least one SolrCore.</div>'
); );
return;
} // else: we have at least one core.... } // else: we have at least one core....
};
this.run = function()
{
$.ajax
(
{
url : config.solr_path + config.core_admin_path + '?wt=json',
dataType : 'json',
beforeSend : function( arr, form, options )
{
$( '#content' )
.html( '<div id="index"><div class="loader">Loading ...</div></div>' );
},
success : function( response )
{
self.set_cores_data( response );
for( var core_name in response.status )
{
var core_path = config.solr_path + '/' + core_name;
if( !environment_basepath )
{
environment_basepath = core_path;
}
}
var system_url = environment_basepath + '/admin/system?wt=json'; var system_url = environment_basepath + '/admin/system?wt=json';
$.ajax $.ajax

View File

@ -36,7 +36,7 @@ sammy.bind
}, },
success : function( response, text_status, xhr ) success : function( response, text_status, xhr )
{ {
app.cores_data = response.status; app.set_cores_data( response );
params.callback( app.cores_data ); params.callback( app.cores_data );
}, },
error : function( xhr, text_status, error_thrown) error : function( xhr, text_status, error_thrown)
@ -189,7 +189,7 @@ sammy.get
// index-data // index-data
$( '.lastModified dd', index_data_element ) $( '.lastModified dd', index_data_element )
.html( core_data.index.lastModified ); .html( core_data.index.lastModified || '-' );
$( '.version dd', index_data_element ) $( '.version dd', index_data_element )
.html( core_data.index.version ); .html( core_data.index.version );
@ -201,7 +201,7 @@ sammy.get
.html( core_data.index.maxDoc ); .html( core_data.index.maxDoc );
$( '.deletedDocs dd', index_data_element ) $( '.deletedDocs dd', index_data_element )
.html( core_data.index.deletedDocs ); .html( core_data.index.deletedDocs || '-' );
$( '.optimized dd', index_data_element ) $( '.optimized dd', index_data_element )
.addClass( !core_data.index.hasDeletions ? 'ico-1' : 'ico-0' ); .addClass( !core_data.index.hasDeletions ? 'ico-1' : 'ico-0' );