Yuki Takei 6 лет назад
Родитель
Сommit
c81270f0b9

+ 11 - 4
resource/locales/en-US/translation.json

@@ -806,10 +806,17 @@
   },
   },
   "full_text_search_management": {
   "full_text_search_management": {
     "elasticsearch_management": "Elasticsearch Management",
     "elasticsearch_management": "Elasticsearch Management",
-    "build_button": "Rebuild Index",
-    "rebuild_description_1": "Force rebuild index.",
-    "rebuild_description_2": "Click 'Build Now' to delete and create mapping file and add all pages.",
-    "rebuild_description_3": "This may take a while."
+    "indices_status": "Indices Status",
+    "indices_status_label_normalized": "NORMALIZED",
+    "indices_status_label_unnormalized": "REBUILDING or BROKEN",
+    "indices_summary": "Indices Summary",
+    "normalize": "Normalize",
+    "normalize_button": "Normalize Indices",
+    "normalize_description": "Click the button to repair broken indices.",
+    "rebuild": "Rebuild",
+    "rebuild_button": "Rebuild Index",
+    "rebuild_description_1": "Click the button to rebuild index and add all page datas.",
+    "rebuild_description_2": "This may take a while."
   },
   },
   "export_management": {
   "export_management": {
     "exporting_collection_list": "Exporting Collection List",
     "exporting_collection_list": "Exporting Collection List",

+ 11 - 4
resource/locales/ja/translation.json

@@ -790,10 +790,17 @@
   },
   },
   "full_text_search_management": {
   "full_text_search_management": {
     "elasticsearch_management": "Elasticsearch 管理",
     "elasticsearch_management": "Elasticsearch 管理",
-    "build_button": "インデックスのリビルド",
-    "rebuild_description_1": "Build Now ボタンを押すと全てのページのインデックスを削除し、作り直します。",
-    "rebuild_description_2": "この作業には数秒かかります。",
-    "rebuild_description_3": ""
+    "indices_status": "インデックスの状態",
+    "indices_status_label_normalized": "正規化されています",
+    "indices_status_label_unnormalized": "リビルド中 または 破損しています",
+    "indices_summary": "インデックスのサマリ",
+    "normalize": "正規化",
+    "normalize_button": "インデックスの正規化",
+    "normalize_description": "破損したインデックスを修復します。",
+    "rebuild": "リビルド",
+    "rebuild_button": "インデックスのリビルド",
+    "rebuild_description_1": "全てのページのインデックスを削除し、作り直します。",
+    "rebuild_description_2": "この作業には数秒かかります。"
   },
   },
   "export_management": {
   "export_management": {
     "exporting_collection_list": "エクスポート中のコレクション",
     "exporting_collection_list": "エクスポート中のコレクション",

+ 79 - 24
src/client/js/components/Admin/FullTextSearchManagement/RebuildIndex.jsx

@@ -80,7 +80,7 @@ class RebuildIndex extends React.Component {
 
 
     try {
     try {
       await appContainer.apiv3Put('/search/indices', { operation: 'normalize' });
       await appContainer.apiv3Put('/search/indices', { operation: 'normalize' });
-  }
+    }
     catch (e) {
     catch (e) {
       toastError(e);
       toastError(e);
     }
     }
@@ -210,10 +210,67 @@ class RebuildIndex extends React.Component {
     );
     );
   }
   }
 
 
+  renderNormalizeControls() {
+    const { t } = this.props;
+
+    const isEnabled = !this.state.isNormalized && !this.state.isProcessing;
+
+    return (
+      <>
+        <button
+          type="submit"
+          className={`btn btn-outline ${isEnabled ? 'btn-info' : 'btn-default'}`}
+          onClick={this.normalizeIndices}
+          disabled={!isEnabled}
+        >
+          { t('full_text_search_management.normalize_button') }
+        </button>
+
+        <p className="help-block">
+          { t('full_text_search_management.normalize_description') }<br />
+        </p>
+      </>
+    );
+  }
+
+  renderRebuildControls() {
+    const { t } = this.props;
+
+    const isEnabled = this.state.isNormalized && !this.state.isProcessing;
+
+    return (
+      <>
+        { this.renderProgressBar() }
+
+        <button
+          type="submit"
+          className="btn btn-inverse"
+          onClick={this.rebuildIndices}
+          disabled={!isEnabled}
+        >
+          { t('full_text_search_management.rebuild_button') }
+        </button>
+
+        <p className="help-block">
+          { t('full_text_search_management.rebuild_description_1') }<br />
+          { t('full_text_search_management.rebuild_description_2') }<br />
+        </p>
+      </>
+    );
+  }
+
+
   render() {
   render() {
     const { t } = this.props;
     const { t } = this.props;
     const { isNormalized } = this.state;
     const { isNormalized } = this.state;
 
 
+    let statusLabel = <span className="label label-default">――</span>;
+    if (isNormalized != null) {
+      statusLabel = isNormalized
+        ? <span className="label label-info">{ t('full_text_search_management.indices_status_label_normalized') }</span>
+        : <span className="label label-warning">{ t('full_text_search_management.indices_status_label_unnormalized') }</span>;
+    }
+
     return (
     return (
       <>
       <>
         <div className="row">
         <div className="row">
@@ -221,41 +278,39 @@ class RebuildIndex extends React.Component {
             <table className="table table-bordered">
             <table className="table table-bordered">
               <tbody>
               <tbody>
                 <tr>
                 <tr>
-                  <th className="col-sm-4">Indices</th>
+                  <th>{ t('full_text_search_management.indices_status') }</th>
+                  <td>{statusLabel}</td>
+                </tr>
+                <tr>
+                  <th className="col-sm-4">{ t('full_text_search_management.indices_summary') }</th>
                   <td className="p-4">
                   <td className="p-4">
                     { this.renderIndexInfoPanels() }
                     { this.renderIndexInfoPanels() }
                   </td>
                   </td>
                 </tr>
                 </tr>
-                <tr>
-                  <th>Status</th>
-                  <td>{isNormalized}</td>
-                </tr>
               </tbody>
               </tbody>
             </table>
             </table>
           </div>
           </div>
         </div>
         </div>
 
 
+        <hr />
+
+        {/* Controls */}
+        <div className="row">
+          <label className="col-xs-3 control-label">{ t('full_text_search_management.normalize') }</label>
+          <div className="col-xs-6">
+            { this.renderNormalizeControls() }
+          </div>
+        </div>
+
+        <hr />
+
         <div className="row">
         <div className="row">
-          <div className="col-xs-3 control-label"></div>
-          <div className="col-xs-9">
-            { this.renderProgressBar() }
-
-            <button
-              type="submit"
-              className="btn btn-inverse"
-              onClick={this.rebuildIndices}
-              disabled={this.state.isProcessing}
-            >
-              { t('full_text_search_management.build_button') }
-            </button>
-
-            <p className="help-block">
-              { t('full_text_search_management.rebuild_description_1') }<br />
-              { t('full_text_search_management.rebuild_description_2') }<br />
-              { t('full_text_search_management.rebuild_description_3') }<br />
-            </p>
+          <label className="col-xs-3 control-label">{ t('full_text_search_management.rebuild') }</label>
+          <div className="col-xs-6">
+            { this.renderRebuildControls() }
           </div>
           </div>
         </div>
         </div>
+
       </>
       </>
     );
     );
   }
   }