From a1f17c1f8482f3c38e17cabe2365c76a1a2f32d4 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 13 Jul 2017 21:00:59 +0100 Subject: PLT-6474 Basic Elasticsearch System Console Page (#6825) * PLT-6474: Basic System Console Elasticsearch Config. * Fix review comments. * More review fixes. * Review comments. --- webapp/actions/admin_actions.jsx | 13 + webapp/components/admin_console/admin_sidebar.jsx | 16 ++ .../admin_console/elasticsearch_settings.jsx | 280 +++++++++++++++++++++ webapp/i18n/en.json | 21 ++ webapp/routes/route_admin_console.jsx | 5 + webapp/yarn.lock | 2 +- 6 files changed, 336 insertions(+), 1 deletion(-) create mode 100644 webapp/components/admin_console/elasticsearch_settings.jsx (limited to 'webapp') diff --git a/webapp/actions/admin_actions.jsx b/webapp/actions/admin_actions.jsx index fdaeb8732..ac02ac058 100644 --- a/webapp/actions/admin_actions.jsx +++ b/webapp/actions/admin_actions.jsx @@ -383,3 +383,16 @@ export function getPostsPerDayAnalytics(teamId) { export function getUsersPerDayAnalytics(teamId) { AdminActions.getUsersPerDayAnalytics(teamId)(dispatch, getState); } + +export function elasticsearchTest(config, success, error) { + AdminActions.testElasticsearch(config)(dispatch, getState).then( + (data) => { + if (data && success) { + success(data); + } else if (data == null && error) { + const serverError = getState().requests.admin.testElasticsearch.error; + error({id: serverError.server_error_id, ...serverError}); + } + } + ); +} diff --git a/webapp/components/admin_console/admin_sidebar.jsx b/webapp/components/admin_console/admin_sidebar.jsx index 1dbbff2f2..9b27ab81e 100644 --- a/webapp/components/admin_console/admin_sidebar.jsx +++ b/webapp/components/admin_console/admin_sidebar.jsx @@ -258,6 +258,21 @@ export default class AdminSidebar extends React.Component { /> ); + let elasticSearchSettings = null; + if (window.mm_license.IsLicensed === 'true') { + elasticSearchSettings = ( + + } + /> + ); + } + return (
@@ -618,6 +633,7 @@ export default class AdminSidebar extends React.Component { /> } /> + {elasticSearchSettings} { + this.setState({ + configTested: true, + canSave: true + }); + success(); + }, + (err) => { + this.setState({ + configTested: false, + canSave: false + }); + error(err); + } + ); + } + + renderTitle() { + return ( + + ); + } + + renderSettings() { + return ( + +
+
+ +
+
+ + } + helpText={ + + + + ) + }} + /> + } + value={this.state.enableIndexing} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.elasticsearch.connectionUrlExample', 'E.g.: "https://elasticsearch.example.org:9200"')} + helpText={ + + + + ) + }} + /> + } + value={this.state.connectionUrl} + disabled={!this.state.enableIndexing} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.elasticsearch.usernameExample', 'E.g.: "elastic"')} + helpText={ + + } + value={this.state.username} + disabled={!this.state.enableIndexing} + onChange={this.handleChange} + /> + + } + placeholder={Utils.localizeMessage('admin.elasticsearch.password', 'E.g.: "yourpassword"')} + helpText={ + + } + value={this.state.password} + disabled={!this.state.enableIndexing} + onChange={this.handleChange} + /> + + } + helpText={ + + } + value={this.state.sniff} + disabled={!this.state.enableIndexing} + onChange={this.handleChange} + /> + + } + buttonText={ + + } + disabled={!this.state.enableIndexing} + /> + + } + helpText={ + + } + value={this.state.enableSearching} + disabled={!this.state.enableIndexing || !this.state.configTested} + onChange={this.handleChange} + /> +
+ ); + } +} diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index c4c0951f4..684fe7329 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -235,6 +235,27 @@ "admin.customization.support": "Legal and Support", "admin.database.title": "Database Settings", "admin.developer.title": "Developer Settings", + "admin.elasticsearch.title": "Elasticsearch Settings", + "admin.elasticsearch.noteDescription": "Changing properties in this section will require a server restart before taking effect.", + "admin.elasticsearch.enableIndexingTitle": "Enable Elasticsearch Indexing:", + "admin.elasticsearch.enableIndexingDescription": "When true, indexing of new posts occurs automatically. Search queries will use database search until \"Enable Elasticsearch for search queries\" is enabled. {documentationLink}", + "admin.elasticsearch.enableIndexingDescription.documentationLinkText": "Learn more about Elasticsearch in our documentation.", + "admin.elasticsearch.connectionUrlTitle": "Server Connection Address:", + "admin.elasticsearch.connectionUrlDescription": "The address of the Elasticsearch server. {documentationLink}", + "admin.elasticsearch.connectionUrlExample.documentationLinkText": "Please see documentation with server setup instructions.", + "admin.elasticsearch.usernameTitle": "Server Username:", + "admin.elasticsearch.usernameDescription": "(Optional) The username to authenticate to the Elasticsearch server.", + "admin.elasticsearch.passwordTitle": "Server Password:", + "admin.elasticsearch.passwordDescription": "(Optional) The password to authenticate to the Elasticsearch server.", + "admin.elasticsearch.sniffTitle": "Enable Cluster Sniffing:", + "admin.elasticsearch.sniffDescription": "When true, sniffing finds and connects to all data nodes in your cluster automatically.", + "admin.elasticsearch.enableSearchingTitle": "Enable Elasticsearch for search queries:", + "admin.elasticsearch.enableSearchingDescription": "Requires a successful connection to the Elasticsearch server. When true, Elasticsearch will be used for all search queries using the latest index. Search results may be incomplete until a bulk index of the existing post database is finished. When false, database search is used.", + "admin.elasticsearch.connectionUrlExample": "E.g.: \"https://elasticsearch.example.org:9200\"", + "admin.elasticsearch.usernameExample": "E.g.: \"elastic\"", + "admin.elasticsearch.password": "E.g.: \"yourpassword\"", + "admin.elasticsearch.testHelpText": "Tests if the Mattermost server can connect to the Elasticsearch server specified. Testing the connection does not save the configuration. See log file for more detailed error messages.", + "admin.elasticsearch.elasticsearch_test_button": "Test Connection", "admin.email.agreeHPNS": " I understand and accept the Mattermost Hosted Push Notification Service Terms of Service and Privacy Policy.", "admin.email.allowEmailSignInDescription": "When true, Mattermost allows users to sign in using their email and password.", "admin.email.allowEmailSignInTitle": "Enable sign-in with email: ", diff --git a/webapp/routes/route_admin_console.jsx b/webapp/routes/route_admin_console.jsx index b0b6ebf62..17e0290c2 100644 --- a/webapp/routes/route_admin_console.jsx +++ b/webapp/routes/route_admin_console.jsx @@ -45,6 +45,7 @@ import TeamAnalytics from 'components/analytics/team_analytics'; import LicenseSettings from 'components/admin_console/license_settings.jsx'; import Audits from 'components/admin_console/audits'; import Logs from 'components/admin_console/server_logs'; +import ElasticsearchSettings from 'components/admin_console/elasticsearch_settings.jsx'; export default ( @@ -199,6 +200,10 @@ export default ( path='database' component={DatabaseSettings} /> +