You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2012/07/31 01:11:35 UTC

svn commit: r1367358 - in /lucene/dev/trunk/solr: CHANGES.txt webapp/web/js/scripts/app.js

Author: hossman
Date: Mon Jul 30 23:11:35 2012
New Revision: 1367358

URL: http://svn.apache.org/viewvc?rev=1367358&view=rev
Log:
SOLR-3677: Fixed missleading error message in web ui to distinguish between no SolrCores loaded vs. no /admin/ handler available.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/webapp/web/js/scripts/app.js

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1367358&r1=1367357&r2=1367358&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Jul 30 23:11:35 2012
@@ -166,6 +166,10 @@ Bug Fixes
   For the example configuration, this means /browse now works with SolrCloud.
   (janhoy, ehatcher)
 
+* SOLR-3677: Fixed missleading error message in web ui to distinguish between 
+  no SolrCores loaded vs. no /admin/ handler available.
+  (hossman, steffkes)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/app.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/app.js?rev=1367358&r1=1367357&r2=1367358&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/app.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/app.js Mon Jul 30 23:11:35 2012
@@ -152,6 +152,24 @@ var solr_admin = function( app_config )
 
   this.timeout = null;
 
+  show_global_error = function( error )
+  {
+    var main = $( '#main' );
+
+    $( 'div[id$="-wrapper"]', main )
+      .remove();
+
+    main
+      .addClass( 'error' )
+      .append( error );
+
+    var pre_tags = $( 'pre', main );
+    if( 0 !== pre_tags.size() )
+    {
+      hljs.highlightBlock( pre_tags.get(0) ); 
+    }
+  };
+
   this.run = function()
   {
     $.ajax
@@ -167,9 +185,11 @@ var solr_admin = function( app_config )
         success : function( response )
         {
           self.cores_data = response.status;
+          var core_count = 0;
 
           for( var core_name in response.status )
           {
+            core_count++;
             var core_path = config.solr_path + '/' + core_name;
             var schema =  response['status'][core_name]['schema'];
             var solrconfig =  response['status'][core_name]['config'];
@@ -211,10 +231,21 @@ var solr_admin = function( app_config )
               .append( core_tpl );
           }
 
+          if( 0 === core_count )
+          {
+            show_global_error
+            (
+              '<div class="message">There are no SolrCores running — for the currenct functionality ' +
+              'we require at least one SolrCore, sorry :)</div>'
+            );
+            return;
+          } // else: we have at least one core....
+
+          var system_url = environment_basepath + '/admin/system?wt=json';
           $.ajax
           (
             {
-              url : environment_basepath + '/admin/system?wt=json',
+              url : system_url,
               dataType : 'json',
               beforeSend : function( arr, form, options )
               {
@@ -280,23 +311,17 @@ var solr_admin = function( app_config )
               },
               error : function()
               {
-                var main = $( '#main' );
-
-                $( 'div[id$="-wrapper"]', main )
-                  .remove();
-
-                main
-                  .addClass( 'error' )
-                  .append
-                  (
-                    '<div class="message">This interface requires that you activate the admin request handlers, add the following configuration to your <code>solrconfig.xml:</code></div>' +
-                    '<div class="code"><pre class="syntax language-xml"><code>' +
-                    '<!-- Admin Handlers - This will register all the standard admin RequestHandlers. -->'.esc() + "\n" +
-                    '<requestHandler name="/admin/" class="solr.admin.AdminHandlers" />'.esc() +
-                    '</code></pre></div>'
-                  );
-
-                hljs.highlightBlock( $( 'pre', main ).get(0) );
+                show_global_error
+                (
+                  '<div class="message"><p>Unable to load environment info from <code>' + system_url.esc() + '</code>.</p>' +
+                  '<p>This interface requires that you activate the admin request handlers in all SolrCores by adding the ' +
+                  'following configuration to your <code>solrconfig.xml</code>:</p></div>' + "\n" +
+
+                  '<div class="code"><pre class="syntax language-xml"><code>' +
+                  '<!-- Admin Handlers - This will register all the standard admin RequestHandlers. -->'.esc() + "\n" +
+                  '<requestHandler name="/admin/" class="solr.admin.AdminHandlers" />'.esc() +
+                  '</code></pre></div>'
+                );
               },
               complete : function()
               {
@@ -317,4 +342,4 @@ var solr_admin = function( app_config )
 
 };
 
-var app = new solr_admin( app_config );
\ No newline at end of file
+var app = new solr_admin( app_config );