From e1801d0997023bd504f5ee40343042c84919b7b5 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 26 May 2016 12:11:55 -0700 Subject: Adding reload and recycle buttons to system console (#3102) --- .../admin_console/configuration_settings.jsx | 2 + .../components/admin_console/database_settings.jsx | 2 + webapp/components/admin_console/recycle_db.jsx | 96 ++++++++++++++++++++++ webapp/components/admin_console/reload_config.jsx | 96 ++++++++++++++++++++++ webapp/i18n/en.json | 6 ++ webapp/sass/routes/_admin-console.scss | 8 ++ 6 files changed, 210 insertions(+) create mode 100644 webapp/components/admin_console/recycle_db.jsx create mode 100644 webapp/components/admin_console/reload_config.jsx (limited to 'webapp') diff --git a/webapp/components/admin_console/configuration_settings.jsx b/webapp/components/admin_console/configuration_settings.jsx index 2f80f0be3..9521ed22c 100644 --- a/webapp/components/admin_console/configuration_settings.jsx +++ b/webapp/components/admin_console/configuration_settings.jsx @@ -9,6 +9,7 @@ import AdminSettings from './admin_settings.jsx'; import {FormattedMessage} from 'react-intl'; import SettingsGroup from './settings_group.jsx'; import TextSetting from './text_setting.jsx'; +import ReloadConfigButton from './reload_config.jsx'; export default class ConfigurationSettings extends AdminSettings { constructor(props) { @@ -50,6 +51,7 @@ export default class ConfigurationSettings extends AdminSettings { /> } > + + ); } diff --git a/webapp/components/admin_console/recycle_db.jsx b/webapp/components/admin_console/recycle_db.jsx new file mode 100644 index 000000000..47ef2b0bf --- /dev/null +++ b/webapp/components/admin_console/recycle_db.jsx @@ -0,0 +1,96 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import Client from 'utils/web_client.jsx'; +import * as Utils from 'utils/utils.jsx'; + +import {FormattedMessage} from 'react-intl'; + +export default class RecycleDbButton extends React.Component { + constructor(props) { + super(props); + + this.handleRecycle = this.handleRecycle.bind(this); + + this.state = { + loading: false, + fail: null + }; + } + + handleRecycle(e) { + e.preventDefault(); + + this.setState({ + loading: true, + fail: null + }); + + Client.recycleDatabaseConnection( + () => { + this.setState({ + loading: false + }); + }, + (err) => { + this.setState({ + loading: false, + fail: err.message + ' - ' + err.detailed_error + }); + } + ); + } + + render() { + let testMessage = null; + if (this.state.fail) { + testMessage = ( +
+ + +
+ ); + } + + let contents = null; + if (this.state.loading) { + contents = ( + + + {Utils.localizeMessage('admin.recycle.loading', ' Recycling...')} + + ); + } else { + contents = ( + + ); + } + + return ( +
+
+
+ + {testMessage} +
+
+
+ ); + } +} \ No newline at end of file diff --git a/webapp/components/admin_console/reload_config.jsx b/webapp/components/admin_console/reload_config.jsx new file mode 100644 index 000000000..c137afaf9 --- /dev/null +++ b/webapp/components/admin_console/reload_config.jsx @@ -0,0 +1,96 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import Client from 'utils/web_client.jsx'; +import * as Utils from 'utils/utils.jsx'; + +import {FormattedMessage} from 'react-intl'; + +export default class ReloadConfigButton extends React.Component { + constructor(props) { + super(props); + + this.handleReloadConfig = this.handleReloadConfig.bind(this); + + this.state = { + loading: false, + fail: null + }; + } + + handleReloadConfig(e) { + e.preventDefault(); + + this.setState({ + loading: true, + fail: null + }); + + Client.reloadConfig( + () => { + this.setState({ + loading: false + }); + }, + (err) => { + this.setState({ + loading: false, + fail: err.message + ' - ' + err.detailed_error + }); + } + ); + } + + render() { + let testMessage = null; + if (this.state.fail) { + testMessage = ( +
+ + +
+ ); + } + + let contents = null; + if (this.state.loading) { + contents = ( + + + {Utils.localizeMessage('admin.reload.loading', ' Loading...')} + + ); + } else { + contents = ( + + ); + } + + return ( +
+
+
+ + {testMessage} +
+
+
+ ); + } +} \ No newline at end of file diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index ecabc3d5a..1bb3d5f87 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -123,6 +123,12 @@ "admin.connectionSecurityTitle": "Connection Security:", "admin.connectionSecurityTls": "TLS", "admin.connectionSecurityTlsDescription": "Encrypts the communication between Mattermost and your server.", + "admin.reload.reloadFail": "Reloading unsuccessful: {error}", + "admin.reload.loading": " Loading...", + "admin.reload.button": "Reload Configuration From Disk", + "admin.recycle.reloadFail": "Recycling unsuccessful: {error}", + "admin.recycle.loading": " Recycling...", + "admin.recycle.button": "Recycle Database Connections", "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": "Allow Sign In With Email: ", diff --git a/webapp/sass/routes/_admin-console.scss b/webapp/sass/routes/_admin-console.scss index 815ac9761..c8af72472 100644 --- a/webapp/sass/routes/_admin-console.scss +++ b/webapp/sass/routes/_admin-console.scss @@ -366,4 +366,12 @@ .email-connection-test { margin-top: -15px; +} + +.reload-config { + margin-bottom: 50px !important; +} + +.recycle-db { + margin-top: 50px !important; } \ No newline at end of file -- cgit v1.2.3-1-g7c22