Browse Source

fix #1105 add development mode icon

Shinsuke Sugaya 8 years ago
parent
commit
a49109a685

+ 4 - 0
src/main/java/org/codelibs/fess/es/client/FessEsClient.java

@@ -211,6 +211,10 @@ public class FessEsClient implements Client {
         this.runner = runner;
     }
 
+    public boolean isEmbedded() {
+        return this.runner != null;
+    }
+
     public void addTransportAddress(final String host, final int port) {
         try {
             transportAddressList.add(new InetSocketTransportAddress(InetAddress.getByName(host), port));

+ 7 - 1
src/main/java/org/codelibs/fess/helper/SystemHelper.java

@@ -179,6 +179,10 @@ public class SystemHelper {
 
     public String getHelpLink(final String name) {
         final String url = ComponentUtil.getFessConfig().getOnlineHelpBaseLink() + name + "-guide.html";
+        return getHelpUrl(url);
+    }
+
+    protected String getHelpUrl(final String url) {
         final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
         if (locale != null) {
             final String lang = locale.getLanguage();
@@ -278,7 +282,9 @@ public class SystemHelper {
     }
 
     public void setupAdminHtmlData(final TypicalAction action, final ActionRuntime runtime) {
-        // nothing
+        runtime.registerData("developmentMode", ComponentUtil.getFessEsClient().isEmbedded());
+        final String url = ComponentUtil.getFessConfig().getOnlineHelpInstallation();
+        runtime.registerData("installationLink", getHelpUrl(url));
     }
 
     public String getSearchRoleByUser(final String name) {

+ 3 - 0
src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java

@@ -2670,6 +2670,9 @@ public class FessLabels extends UserMessages {
     /** The key of the message: Score:  */
     public static final String LABELS_doc_score = "{labels.doc_score}";
 
+    /** The key of the message: Running as Development mode. For production use, please install a standalone elasticsearch server. */
+    public static final String LABELS_development_mode_warning = "{labels.development_mode_warning}";
+
     /**
      * Assert the property is not null.
      * @param property The value of the property. (NotNull)

+ 14 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -827,6 +827,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** The key of the configuration. e.g. http://fess.codelibs.org/{lang}/{version}/admin/ */
     String ONLINE_HELP_BASE_LINK = "online.help.base.link";
 
+    /** The key of the configuration. e.g. http://fess.codelibs.org/{lang}/{version}/install/install.html */
+    String ONLINE_HELP_INSTALLATION = "online.help.installation";
+
     /** The key of the configuration. e.g. failureurl */
     String ONLINE_HELP_NAME_FAILUREURL = "online.help.name.failureurl";
 
@@ -4006,6 +4009,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
     String getOnlineHelpBaseLink();
 
+    /**
+     * Get the value for the key 'online.help.installation'. <br>
+     * The value is, e.g. http://fess.codelibs.org/{lang}/{version}/install/install.html <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getOnlineHelpInstallation();
+
     /**
      * Get the value for the key 'online.help.name.failureurl'. <br>
      * The value is, e.g. failureurl <br>
@@ -6565,6 +6575,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return get(FessConfig.ONLINE_HELP_BASE_LINK);
         }
 
+        public String getOnlineHelpInstallation() {
+            return get(FessConfig.ONLINE_HELP_INSTALLATION);
+        }
+
         public String getOnlineHelpNameFailureurl() {
             return get(FessConfig.ONLINE_HELP_NAME_FAILUREURL);
         }

+ 1 - 0
src/main/resources/fess_config.properties

@@ -430,6 +430,7 @@ scheduler.monitor.interval=30
 #                                                 OnlineHelp
 #                                                     ------
 online.help.base.link=http://fess.codelibs.org/{lang}/{version}/admin/
+online.help.installation=http://fess.codelibs.org/{lang}/{version}/install/install.html
 online.help.name.failureurl=failureurl
 online.help.name.elevateword=elevateword
 online.help.name.reqheader=reqheader

+ 1 - 0
src/main/resources/fess_label.properties

@@ -880,3 +880,4 @@ labels.requestFile=Request File
 labels.esreq_button_upload=Send
 labels.facet_is_not_found=No match
 labels.doc_score=Score: 
+labels.development_mode_warning=Running as Development mode. For production use, please install a standalone elasticsearch server.

+ 1 - 0
src/main/resources/fess_label_en.properties

@@ -880,3 +880,4 @@ labels.requestFile=Request File
 labels.esreq_button_upload=Send
 labels.facet_is_not_found=No match.
 labels.doc_score=Score: 
+labels.development_mode_warning=Running as Development mode. For production use, please install a standalone elasticsearch server.

+ 1 - 0
src/main/resources/fess_label_ja.properties

@@ -882,3 +882,4 @@ labels.requestFile=\u30ea\u30af\u30a8\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb
 labels.esreq_button_upload=\u9001\u4fe1
 labels.facet_is_not_found=\u8a72\u5f53\u306a\u3057
 labels.doc_score=\u30b9\u30b3\u30a2: 
+labels.development_mode_warning=\u958b\u767a\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u3066\u3044\u307e\u3059\u3002\u672c\u904b\u7528\u74b0\u5883\u3067\u306fElasticsearch\u3092\u5225\u9014\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002

+ 5 - 0
src/main/webapp/WEB-INF/view/common/admin/header.jsp

@@ -17,6 +17,11 @@
 		<!-- Navbar Right Menu -->
 		<div class="navbar-custom-menu">
 			<ul class="nav navbar-nav">
+				<c:if test="${developmentMode}">
+				<li data-toggle="tooltip" data-placement="left" title="<la:message
+					key="labels.development_mode_warning" />">
+					<a href="${installationLink}" target="_olh"><i class="fa fa-exclamation-triangle"></i></a></li>
+				</c:if>
 				<li><a href="${contextPath}/"><i class="fa fa-list-alt"></i></a></li>
 				<li><a
 					href="${contextPath}/admin/scheduler/details/4/default_crawler"><i

+ 4 - 0
src/main/webapp/js/admin/admin.js

@@ -84,4 +84,8 @@ $(function() {
 		showInputs : false
 	});
 
+	// tooltips
+	$(function() {
+		$('[data-toggle="tooltip"]').tooltip()
+	})
 });