From f15074e704a85ff8f2475e757199d28eaadcc5c3 Mon Sep 17 00:00:00 2001 From: Stefan Matheis Date: Tue, 16 Jul 2013 19:54:52 +0000 Subject: [PATCH] SOLR-3633 - web UI reports an error if CoreAdminHandler says there are no SolrCores git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1503853 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 6 + solr/webapp/web/admin.html | 8 +- solr/webapp/web/css/styles/cores.css | 8 +- solr/webapp/web/css/styles/dashboard.css | 27 ++- solr/webapp/web/css/styles/index.css | 2 - solr/webapp/web/css/styles/menu.css | 16 ++ solr/webapp/web/img/ico/database--plus.png | Bin 0 -> 664 bytes solr/webapp/web/js/scripts/app.js | 91 +++++----- solr/webapp/web/js/scripts/cores.js | 168 +++++++++++++++++- solr/webapp/web/js/scripts/dashboard.js | 21 ++- solr/webapp/web/js/scripts/index.js | 9 - solr/webapp/web/js/scripts/java-properties.js | 3 +- solr/webapp/web/js/scripts/logging.js | 6 +- solr/webapp/web/js/scripts/threads.js | 3 +- solr/webapp/web/tpl/cores.html | 16 +- solr/webapp/web/tpl/dashboard.html | 54 ++++-- 16 files changed, 324 insertions(+), 114 deletions(-) create mode 100755 solr/webapp/web/img/ico/database--plus.png diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index fdf534c75bc..8ca140b8f02 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -64,6 +64,12 @@ Upgrading from Solr 4.4.0 Detailed Change List ---------------------- +Bug Fixes +---------------------- + +* SOLR-3633 - web UI reports an error if CoreAdminHandler says there are no + SolrCores (steffkes) + Other Changes ---------------------- diff --git a/solr/webapp/web/admin.html b/solr/webapp/web/admin.html index 2db54e958a3..ca24f410232 100644 --- a/solr/webapp/web/admin.html +++ b/solr/webapp/web/admin.html @@ -113,7 +113,13 @@ limitations under the License.
- +
+ +
+

+ No cores available + Go and create one +

diff --git a/solr/webapp/web/css/styles/cores.css b/solr/webapp/web/css/styles/cores.css index a93ad554b92..f1f921719fb 100644 --- a/solr/webapp/web/css/styles/cores.css +++ b/solr/webapp/web/css/styles/cores.css @@ -33,6 +33,11 @@ limitations under the License. width: 500px; } +#content #cores.empty .requires-core +{ + display: none; +} + #content #cores #frame { float: right; @@ -53,6 +58,7 @@ limitations under the License. #content #cores #frame .actions { margin-bottom: 20px; + min-height: 30px; } #content #cores .actions div.action @@ -170,7 +176,7 @@ limitations under the License. display: none; position: absolute; left: -50px; - top: 40; + top: 40px; padding: 10px; } diff --git a/solr/webapp/web/css/styles/dashboard.css b/solr/webapp/web/css/styles/dashboard.css index f116624cebc..8d8fd972124 100644 --- a/solr/webapp/web/css/styles/dashboard.css +++ b/solr/webapp/web/css/styles/dashboard.css @@ -113,24 +113,25 @@ limitations under the License. display: none; } -#content #dashboard #dataimport +#content #dashboard #instance { float: right; } +#content #dashboard #instance .dir_impl +{ + margin-top: 10px; +} #content #dashboard #admin-extra { - float: right; + float: left; } -#content #dashboard #system h2 { background-image: url( ../../img/ico/server.png ); } -#content #dashboard #statistics h2 { background-image: url( ../../img/ico/chart.png ); } -#content #dashboard #replication h2 { background-image: url( ../../img/ico/node.png ); } -#content #dashboard #replication.master h2 { background-image: url( ../../img/ico/node-master.png ); } -#content #dashboard #replication.slave h2 { background-image: url( ../../img/ico/node-slave.png ); } -#content #dashboard #dataimport h2 { background-image: url( ../../img/ico/document-import.png ); } -#content #dashboard #admin-extra h2 { background-image: url( ../../img/ico/plus-button.png ); } +#content #dashboard #healthcheck +{ + float: right; +} #content #dashboard #healthcheck .ico { @@ -144,3 +145,11 @@ limitations under the License. { background-image: url( ../../img/ico/tick.png ); } + +#content #dashboard #system h2 { background-image: url( ../../img/ico/server.png ); } +#content #dashboard #statistics h2 { background-image: url( ../../img/ico/chart.png ); } +#content #dashboard #replication h2 { background-image: url( ../../img/ico/node.png ); } +#content #dashboard #replication.master h2 { background-image: url( ../../img/ico/node-master.png ); } +#content #dashboard #replication.slave h2 { background-image: url( ../../img/ico/node-slave.png ); } +#content #dashboard #instance h2 { background-image: url( ../../img/ico/server.png ); } +#content #dashboard #admin-extra h2 { background-image: url( ../../img/ico/plus-button.png ); } \ No newline at end of file diff --git a/solr/webapp/web/css/styles/index.css b/solr/webapp/web/css/styles/index.css index 4977cf57df0..288e040a2ab 100644 --- a/solr/webapp/web/css/styles/index.css +++ b/solr/webapp/web/css/styles/index.css @@ -147,8 +147,6 @@ limitations under the License. #content #index #instance h2 { background-image: url( ../../img/ico/server.png ); } #content #index #instance .start_time dt span { background-image: url( ../../img/ico/clock-select.png ); } -#content #index #instance .host dt span { background-image: url( ../../img/ico/globe.png ); } -#content #index #instance .dir dt span { background-image: url( ../../img/ico/folder.png ); } #content #index #versions h2 { background-image: url( ../../img/ico/property.png ); } #content #index #versions .solr span { background-image: url( ../../img/solr-ico.png ); } diff --git a/solr/webapp/web/css/styles/menu.css b/solr/webapp/web/css/styles/menu.css index 23e39fc1d39..5e8057024c9 100644 --- a/solr/webapp/web/css/styles/menu.css +++ b/solr/webapp/web/css/styles/menu.css @@ -54,6 +54,22 @@ limitations under the License. width: 100%; } +#core-selector #has-no-cores +{ + display: none; +} + +#core-selector #has-no-cores a +{ + background-image: url( ../../img/ico/database--plus.png ); +} + +#core-selector #has-no-cores span +{ + color: #c0c0c0; + display: block; +} + #menu-wrapper .active p { background-color: #fafafa; diff --git a/solr/webapp/web/img/ico/database--plus.png b/solr/webapp/web/img/ico/database--plus.png new file mode 100755 index 0000000000000000000000000000000000000000..2558a7d6a62da8bafaa7944255bb9e8959e1463c GIT binary patch literal 664 zcmV;J0%!e+P)VN(zgBm6d{USll0=#aRe~Ru&g7O$dTH5kn;2 zZ8q8LN4jK|}pjg5`x zj^kiB9D)!J?e-z{eMBM(G)+T19!DY(N1<@zwjc;tD8Pge0^7FH>2$&ZhSA4p>?0c0 zKs*9o;Gss9g;w}~Hp&43H38>O6;nNV0UAC{3}(q*sPi&ELZwtHz0PK{tG@4JFc{26 zA(TM`u~>}GpFq7{e?wz;jw*1mSS+s2Lp00-I3pL5EFq>vk)RN-t*kHKE!<)oC?5-P z-?ZVlE))uG;wLFYKvCuYf%toNpYx7oaP$^_ZNS50;|ad(HDKl1H&2`KXT&EEGMP*m z>vS`gb$g- z#HIDiI(7B;FW*5dm&-_}(~xCZ{M#|jv&Yi)X@R%%XbisDY&=&09~&O|B!Ha*uPG5`(Xj9XD!QebzOhNU;sThere are no SolrCores running.
Using the Solr Admin UI currently requires at least one SolrCore.
' - ); - } // else: we have at least one core.... }; this.run = function() @@ -352,26 +359,24 @@ var solr_admin = function( app_config ) var core_name = $( 'option:selected', this ).text(); that.core_menu - .html - (//Keep this in alphabetical order after the overview - '
  • Overview
  • ' + "\n" + - '
  • Analysis
  • ' + "\n" + - '
  • Config
  • ' + "\n" + - '
  • Dataimport
  • ' + "\n" + - '
  • Documents
  • ' + "\n" + - '
  • Ping
  • ' + "\n" + - '
  • Plugins / Stats
  • ' + "\n" + - '
  • Query
  • ' + "\n" + - '
  • Replication
  • ' + "\n" + - '
  • Schema
  • ' + "\n" + - '
  • Schema Browser
  • ' + "\n" + .html + ( + //Keep this in alphabetical order after the overview + '
  • Overview
  • ' + "\n" + + '
  • Analysis
  • ' + "\n" + + '
  • Config
  • ' + "\n" + + '
  • Dataimport
  • ' + "\n" + + '
  • Documents
  • ' + "\n" + + '
  • Ping
  • ' + "\n" + + '
  • Plugins / Stats
  • ' + "\n" + + '
  • Query
  • ' + "\n" + + '
  • Replication
  • ' + "\n" + + '
  • Schema
  • ' + "\n" + + '
  • Schema Browser
  • ' + ) + .show(); - ) - .show(); - if( core_name ) - { - } - else + if( !core_name ) { that.core_menu .hide() @@ -380,16 +385,7 @@ var solr_admin = function( app_config ) } ); - 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 = config.solr_path + '/admin/info/system?wt=json'; $.ajax ( { @@ -416,11 +412,6 @@ var solr_admin = function( app_config ) { cloud_args = response.mode.match( /solrcloud/i ); } - - // title - - $( 'title', document ) - .append( ' (' + response.core.host + ')' ); // environment diff --git a/solr/webapp/web/js/scripts/cores.js b/solr/webapp/web/js/scripts/cores.js index 0ee5cc88e3e..18973988378 100644 --- a/solr/webapp/web/js/scripts/cores.js +++ b/solr/webapp/web/js/scripts/cores.js @@ -30,8 +30,22 @@ sammy.bind }, success : function( response, text_status, xhr ) { + var has_cores = false; + for( core in response.status ) + { + has_cores = true; break; + } + app.set_cores_data( response ); - params.callback( app.cores_data ); + + if( has_cores ) + { + params.success( app.cores_data ); + } + else + { + params.error(); + } }, error : function( xhr, text_status, error_thrown) { @@ -102,12 +116,13 @@ sammy.get function( context ) { delete app.cores_template; + var content_element = $( '#content' ); sammy.trigger ( 'cores_load_data', { - callback : function( cores ) + success : function( cores ) { var first_core = null; for( var key in cores ) @@ -119,6 +134,146 @@ sammy.get continue; } context.redirect( context.path + '/' + first_core ); + }, + error : function() + { + sammy.trigger + ( + 'cores_load_template', + { + content_element : content_element, + callback : function() + { + var cores_element = $( '#cores', content_element ); + var navigation_element = $( '#navigation', cores_element ); + var data_element = $( '#data', cores_element ); + var core_data_element = $( '#core-data', data_element ); + var index_data_element = $( '#index-data', data_element ); + + // layout + + var ui_block = $( '#ui-block' ); + var actions_element = $( '.actions', cores_element ); + var div_action = $( 'div.action', actions_element ); + + ui_block + .css( 'opacity', 0.7 ) + .width( cores_element.width() + 10 ) + .height( cores_element.height() ); + + if( $( '#cloud.global' ).is( ':visible' ) ) + { + $( '.cloud', div_action ) + .show(); + } + + $( 'button.action', actions_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + var self = $( this ); + + self + .toggleClass( 'open' ); + + $( '.action.' + self.attr( 'id' ), actions_element ) + .trigger( 'open' ); + + return false; + } + ); + + div_action + .die( 'close' ) + .live + ( + 'close', + function( event ) + { + div_action.hide(); + ui_block.hide(); + } + ) + .die( 'open' ) + .live + ( + 'open', + function( event ) + { + var self = $( this ); + var rel = $( '#' + self.data( 'rel' ) ); + + self + .trigger( 'close' ) + .show() + .css( 'left', rel.position().left ); + + ui_block + .show(); + } + ); + + $( 'form button.reset', actions_element ) + .die( 'click' ) + .live + ( + 'click', + function( event ) + { + $( this ).closest( 'div.action' ) + .trigger( 'close' ); + } + ); + + $( 'form', div_action ) + .ajaxForm + ( + { + url : app.config.solr_path + app.config.core_admin_path + '?wt=json&indexInfo=false', + dataType : 'json', + beforeSubmit : function( array, form, options ) + { + $( 'button[type="submit"] span', form ) + .addClass( 'loader' ); + }, + success : function( response, status_text, xhr, form ) + { + delete app.cores_data; + sammy.refresh(); + + $( 'button.reset', form ) + .trigger( 'click' ); + }, + error : function( xhr, text_status, error_thrown ) + { + var response = null; + eval( 'response = ' + xhr.responseText + ';' ); + + var error_elem = $( '.error', div_action.filter( ':visible' ) ); + error_elem.show(); + $( 'span', error_elem ).text( response.error.msg ); + }, + complete : function() + { + $( 'button span.loader', actions_element ) + .removeClass( 'loader' ); + } + } + ); + + // -- + + $( '#add', content_element ) + .trigger( 'click' ); + + $( '[data-rel="add"] input[type="text"]:first', content_element ) + .focus(); + } + } + ); } } ); @@ -140,7 +295,11 @@ sammy.get ( 'cores_load_data', { - callback : function( cores ) + error : function() + { + context.redirect( '#/' + context.params.splat[0] ); + }, + success : function( cores ) { sammy.trigger ( @@ -155,6 +314,9 @@ sammy.get var core_data_element = $( '#core-data', data_element ); var index_data_element = $( '#index-data', data_element ); + cores_element + .removeClass( 'empty' ); + sammy.trigger ( 'cores_build_navigation', diff --git a/solr/webapp/web/js/scripts/dashboard.js b/solr/webapp/web/js/scripts/dashboard.js index 4b4bcda9cdf..263d67e933e 100644 --- a/solr/webapp/web/js/scripts/dashboard.js +++ b/solr/webapp/web/js/scripts/dashboard.js @@ -98,7 +98,7 @@ sammy.get .show() .html( 'Loading ...' ); - $( '.content' ) + $( '.content', this ) .hide(); }, success : function( response, text_status, xhr ) @@ -347,9 +347,9 @@ sammy.get $.ajax ( { - url : core_basepath + '/dataimport?command=details&wt=json', + url : core_basepath + '/admin/system?wt=json', dataType : 'json', - context : $( '#dataimport', dashboard_element ), + context : $( '#instance', dashboard_element ), beforeSend : function( xhr, settings ) { $( 'h2', this ) @@ -358,19 +358,28 @@ sammy.get $( '.message', this ) .show() .html( 'Loading' ); + + $( '.content', this ) + .hide(); }, success : function( response, text_status, xhr ) { $( '.message', this ) .empty() .hide(); + + $( '.content', this ) + .show(); $( 'dl', this ) .show(); var data = { - 'status' : response['status'], - 'info' : response['statusMessages'][''] + 'dir_cwd' : response.core.directory.cwd, + 'dir_instance' : response.core.directory.instance, + 'dir_data' : response.core.directory.data, + 'dir_index' : response.core.directory.index, + 'dir_impl' : response.core.directory.dirimpl }; for( var key in data ) @@ -389,7 +398,7 @@ sammy.get $( '.message', this ) .show() - .html( 'Dataimport is not configured' ); + .html( '/admin/system Handler is not configured' ); }, complete : function( xhr, text_status ) { diff --git a/solr/webapp/web/js/scripts/index.js b/solr/webapp/web/js/scripts/index.js index 3cc2de5f75b..f4983eb262a 100644 --- a/solr/webapp/web/js/scripts/index.js +++ b/solr/webapp/web/js/scripts/index.js @@ -238,10 +238,6 @@ sammy.get var data = { 'start_time' : app.dashboard_values['jvm']['jmx']['startTime'], - 'host' : app.dashboard_values['core']['host'] || '-', - 'dir_instance' : app.dashboard_values['core']['directory']['instance'], - 'dir_data' : app.dashboard_values['core']['directory']['data'], - 'dir_index' : app.dashboard_values['core']['directory']['index'], 'jvm_version' : app.dashboard_values['jvm']['name'] + ' (' + app.dashboard_values['jvm']['version'] + ')', 'processors' : app.dashboard_values['jvm']['processors'], 'solr_spec_version' : app.dashboard_values['lucene']['solr-spec-version'] || '-', @@ -249,11 +245,6 @@ sammy.get 'lucene_spec_version' : app.dashboard_values['lucene']['lucene-spec-version'] || '-', 'lucene_impl_version' : app.dashboard_values['lucene']['lucene-impl-version'] || '-' }; - - if( app.dashboard_values['core']['directory']['cwd'] ) - { - data['dir_cwd'] = app.dashboard_values['core']['directory']['cwd']; - } for( var key in data ) { diff --git a/solr/webapp/web/js/scripts/java-properties.js b/solr/webapp/web/js/scripts/java-properties.js index 2bef821b593..a37ddd97ac8 100644 --- a/solr/webapp/web/js/scripts/java-properties.js +++ b/solr/webapp/web/js/scripts/java-properties.js @@ -21,7 +21,6 @@ sammy.get /^#\/(~java-properties)$/, function( context ) { - var core_basepath = $( '[data-basepath]', app.menu_element ).attr( 'data-basepath' ); var content_element = $( '#content' ); content_element @@ -30,7 +29,7 @@ sammy.get $.ajax ( { - url : core_basepath + '/admin/properties?wt=json', + url : app.config.solr_path + '/admin/info/properties?wt=json', dataType : 'json', context : $( '#java-properties', content_element ), beforeSend : function( xhr, settings ) diff --git a/solr/webapp/web/js/scripts/logging.js b/solr/webapp/web/js/scripts/logging.js index 7dd09982e72..7403ff9a600 100644 --- a/solr/webapp/web/js/scripts/logging.js +++ b/solr/webapp/web/js/scripts/logging.js @@ -15,7 +15,7 @@ limitations under the License. */ -var loglevel_path = null; +var loglevel_path = app.config.solr_path + '/admin/info/logging'; var frame_element = null; var logging_handler = function( response, text_status, xhr ) @@ -409,8 +409,6 @@ sammy.get /^#\/(~logging)$/, function( context ) { - var core_basepath = $( '[data-basepath]', app.menu_element ).attr( 'data-basepath' ); - loglevel_path = core_basepath + '/admin/logging'; var content_element = $( '#content' ); $.get @@ -495,8 +493,6 @@ sammy.get /^#\/(~logging)\/level$/, function( context ) { - var core_basepath = $( '[data-basepath]', app.menu_element ).attr( 'data-basepath' ); - loglevel_path = core_basepath + '/admin/logging'; var content_element = $( '#content' ); $.get diff --git a/solr/webapp/web/js/scripts/threads.js b/solr/webapp/web/js/scripts/threads.js index 16992de8efc..099dd97cede 100644 --- a/solr/webapp/web/js/scripts/threads.js +++ b/solr/webapp/web/js/scripts/threads.js @@ -21,7 +21,6 @@ sammy.get /^#\/(~threads)$/, function( context ) { - var core_basepath = $( '[data-basepath]', app.menu_element ).attr( 'data-basepath' ); var content_element = $( '#content' ); $.get @@ -35,7 +34,7 @@ sammy.get $.ajax ( { - url : core_basepath + '/admin/threads?wt=json', + url : app.config.solr_path + '/admin/info/threads?wt=json', dataType : 'json', context : $( '#threads', content_element ), beforeSend : function( xhr, settings ) diff --git a/solr/webapp/web/tpl/cores.html b/solr/webapp/web/tpl/cores.html index 45243c607c1..a817c6e07de 100644 --- a/solr/webapp/web/tpl/cores.html +++ b/solr/webapp/web/tpl/cores.html @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -
    +
     
    @@ -23,11 +23,11 @@ limitations under the License.
    - - - - - + + + + +
    @@ -118,7 +118,7 @@ limitations under the License.
    -
    +
    @@ -213,7 +213,7 @@ limitations under the License.
    -
    -
    +
    -

    Admin Extra

    +

    Instance

    + +
    + +
    CWD:
    +
    + +
    Instance:
    +
    + +
    Data:
    +
    + +
    Index:
    +
    + +
    Impl:
    +
    + +
    -
    @@ -136,19 +154,6 @@ limitations under the License.
    - -
    - -

    Dataimport

    - -
    -
    -
    - -
    -
    - -
    @@ -171,6 +176,23 @@ limitations under the License.
    +
    + +
    + +

    Admin Extra

    + +
    +
    +
    + +
    + +
    + +
    + +