summaryrefslogtreecommitdiffstats
path: root/webapp/components/admin_console/log_settings.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-05-17 07:21:39 -0400
committerChristopher Speller <crspeller@gmail.com>2016-05-17 07:21:39 -0400
commitfd53e3b7868234af328cd73150318fc8e7a26b89 (patch)
tree48c49af0d6b25bf978430efc61aa5b3b63b3414a /webapp/components/admin_console/log_settings.jsx
parent5f5f813387a914d6e34945490c438755adfa8505 (diff)
downloadchat-fd53e3b7868234af328cd73150318fc8e7a26b89.tar.gz
chat-fd53e3b7868234af328cd73150318fc8e7a26b89.tar.bz2
chat-fd53e3b7868234af328cd73150318fc8e7a26b89.zip
PLT-2257 Reorganized System Console (#3003)
* Reorganized system console * Fixed the names of some components * Fixed timestamp for BrandImageSetting * Fixed merge issues * Updated push notification settings to match master branch * Removed top level setting pages and moved enable Gitlab/LDAP settings onto their respective pages * Re-added restrictDirectMessage setting to system console * Re-added email connection test and fixed some margins * Fixed ESLint errors * Renamed Authentication > Onboarding to Authentication > Email in the system console * Renamed Customization > Whitelabeling to Customization > Custom Branding in System Console * Re-added EnableOpenServer to system console
Diffstat (limited to 'webapp/components/admin_console/log_settings.jsx')
-rw-r--r--webapp/components/admin_console/log_settings.jsx586
1 files changed, 207 insertions, 379 deletions
diff --git a/webapp/components/admin_console/log_settings.jsx b/webapp/components/admin_console/log_settings.jsx
index 9229c62bc..fa29074d8 100644
--- a/webapp/components/admin_console/log_settings.jsx
+++ b/webapp/components/admin_console/log_settings.jsx
@@ -1,418 +1,246 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import $ from 'jquery';
-import ReactDOM from 'react-dom';
-import Client from 'utils/web_client.jsx';
-import * as AsyncClient from 'utils/async_client.jsx';
+import React from 'react';
-import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'react-intl';
+import * as Utils from 'utils/utils.jsx';
-const holders = defineMessages({
- locationPlaceholder: {
- id: 'admin.log.locationPlaceholder',
- defaultMessage: 'Enter your file location'
- },
- formatPlaceholder: {
- id: 'admin.log.formatPlaceholder',
- defaultMessage: 'Enter your file format'
- },
- saving: {
- id: 'admin.log.saving',
- defaultMessage: 'Saving Config...'
- }
-});
+import AdminSettings from './admin_settings.jsx';
+import BooleanSetting from './boolean_setting.jsx';
+import DropdownSetting from './dropdown_setting.jsx';
+import {FormattedMessage} from 'react-intl';
+import SettingsGroup from './settings_group.jsx';
+import TextSetting from './text_setting.jsx';
-import React from 'react';
-
-class LogSettings extends React.Component {
+export default class LogSettings extends AdminSettings {
constructor(props) {
super(props);
- this.handleChange = this.handleChange.bind(this);
- this.handleSubmit = this.handleSubmit.bind(this);
-
- this.state = {
- consoleEnable: this.props.config.LogSettings.EnableConsole,
- fileEnable: this.props.config.LogSettings.EnableFile,
- saveNeeded: false,
- serverError: null
- };
- }
-
- handleChange(action) {
- var s = {saveNeeded: true, serverError: this.state.serverError};
-
- if (action === 'console_true') {
- s.consoleEnable = true;
- }
-
- if (action === 'console_false') {
- s.consoleEnable = false;
- }
-
- if (action === 'file_true') {
- s.fileEnable = true;
- }
+ this.getConfigFromState = this.getConfigFromState.bind(this);
- if (action === 'file_false') {
- s.fileEnable = false;
- }
+ this.renderSettings = this.renderSettings.bind(this);
- this.setState(s);
+ this.state = Object.assign(this.state, {
+ enableConsole: props.config.LogSettings.EnableConsole,
+ consoleLevel: props.config.LogSettings.ConsoleLevel,
+ enableFile: props.config.LogSettings.EnableFile,
+ fileLevel: props.config.LogSettings.FileLevel,
+ fileLocation: props.config.LogSettings.FileLocation,
+ fileFormat: props.config.LogSettings.FileFormat
+ });
}
- handleSubmit(e) {
- e.preventDefault();
- $('#save-button').button('loading');
+ getConfigFromState(config) {
+ config.LogSettings.EnableConsole = this.state.enableConsole;
+ config.LogSettings.ConsoleLevel = this.state.consoleLevel;
+ config.LogSettings.EnableFile = this.state.enableFile;
+ config.LogSettings.FileLevel = this.state.fileLevel;
+ config.LogSettings.FileLocation = this.state.fileLocation;
+ config.LogSettings.FileFormat = this.state.fileFormat;
- var config = this.props.config;
- config.LogSettings.EnableConsole = ReactDOM.findDOMNode(this.refs.consoleEnable).checked;
- config.LogSettings.ConsoleLevel = ReactDOM.findDOMNode(this.refs.consoleLevel).value;
- config.LogSettings.EnableFile = ReactDOM.findDOMNode(this.refs.fileEnable).checked;
- config.LogSettings.FileLevel = ReactDOM.findDOMNode(this.refs.fileLevel).value;
- config.LogSettings.FileLocation = ReactDOM.findDOMNode(this.refs.fileLocation).value.trim();
- config.LogSettings.FileFormat = ReactDOM.findDOMNode(this.refs.fileFormat).value.trim();
+ return config;
+ }
- Client.saveConfig(
- config,
- () => {
- AsyncClient.getConfig();
- this.setState({
- consoleEnable: config.LogSettings.EnableConsole,
- fileEnable: config.LogSettings.EnableFile,
- serverError: null,
- saveNeeded: false
- });
- $('#save-button').button('reset');
- },
- (err) => {
- this.setState({
- consoleEnable: config.LogSettings.EnableConsole,
- fileEnable: config.LogSettings.EnableFile,
- serverError: err.message,
- saveNeeded: true
- });
- $('#save-button').button('reset');
- }
+ renderTitle() {
+ return (
+ <h3>
+ <FormattedMessage
+ id='admin.general.title'
+ defaultMessage='General Settings'
+ />
+ </h3>
);
}
- render() {
- const {formatMessage} = this.props.intl;
- var serverError = '';
- if (this.state.serverError) {
- serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
- }
-
- var saveClass = 'btn';
- if (this.state.saveNeeded) {
- saveClass = 'btn btn-primary';
- }
+ renderSettings() {
+ const logLevels = [
+ {value: 'DEBUG', text: 'DEBUG'},
+ {value: 'INFO', text: 'INFO'},
+ {value: 'ERROR', text: 'ERROR'}
+ ];
return (
- <div className='wrapper--fixed'>
- <h3>
+ <SettingsGroup
+ header={
<FormattedMessage
- id='admin.log.logSettings'
- defaultMessage='Log Settings'
+ id='admin.general.log'
+ defaultMessage='Logging'
/>
- </h3>
- <form
- className='form-horizontal'
- role='form'
- >
-
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='consoleEnable'
- >
- <FormattedMessage
- id='admin.log.consoleTitle'
- defaultMessage='Log To The Console: '
- />
- </label>
- <div className='col-sm-8'>
- <label className='radio-inline'>
- <input
- type='radio'
- name='consoleEnable'
- value='true'
- ref='consoleEnable'
- defaultChecked={this.props.config.LogSettings.EnableConsole}
- onChange={this.handleChange.bind(this, 'console_true')}
- />
- <FormattedMessage
- id='admin.log.true'
- defaultMessage='true'
- />
- </label>
- <label className='radio-inline'>
- <input
- type='radio'
- name='consoleEnable'
- value='false'
- defaultChecked={!this.props.config.LogSettings.EnableConsole}
- onChange={this.handleChange.bind(this, 'console_false')}
- />
- <FormattedMessage
- id='admin.log.false'
- defaultMessage='false'
- />
- </label>
- <p className='help-text'>
- <FormattedMessage
- id='admin.log.consoleDescription'
- defaultMessage='Typically set to false in production. Developers may set this field to true to output log messages to console based on the console level option. If true, server writes messages to the standard output stream (stdout).'
- />
- </p>
- </div>
- </div>
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='consoleLevel'
- >
- <FormattedMessage
- id='admin.log.levelTitle'
- defaultMessage='Console Log Level:'
- />
- </label>
- <div className='col-sm-8'>
- <select
- className='form-control'
- id='consoleLevel'
- ref='consoleLevel'
- defaultValue={this.props.config.LogSettings.consoleLevel}
- onChange={this.handleChange}
- disabled={!this.state.consoleEnable}
- >
- <option value='DEBUG'>{'DEBUG'}</option>
- <option value='INFO'>{'INFO'}</option>
- <option value='ERROR'>{'ERROR'}</option>
- </select>
- <p className='help-text'>
- <FormattedMessage
- id='admin.log.levelDescription'
- defaultMessage='This setting determines the level of detail at which log events are written to the console. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers working on debugging issues.'
- />
- </p>
- </div>
- </div>
+ }
+ >
+ <BooleanSetting
+ id='enableConsole'
+ label={
+ <FormattedMessage
+ id='admin.log.consoleTitle'
+ defaultMessage='Log To The Console: '
+ />
+ }
+ helpText={
+ <FormattedMessage
+ id='admin.log.consoleDescription'
+ defaultMessage='Typically set to false in production. Developers may set this field to true to output log messages to console based on the console level option. If true, server writes messages to the standard output stream (stdout).'
+ />
+ }
+ value={this.state.enableConsole}
+ onChange={this.handleChange}
+ />
+ <DropdownSetting
+ id='consoleLevel'
+ values={logLevels}
+ label={
+ <FormattedMessage
+ id='admin.log.levelTitle'
+ defaultMessage='Console Log Level:'
+ />
+ }
+ value={this.state.consoleLevel}
+ onChange={this.handleChange}
+ disabled={!this.state.enableConsole}
+ helpText={
+ <FormattedMessage
+ id='admin.log.levelDescription'
+ defaultMessage='This setting determines the level of detail at which log events are written to the console. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers working on debugging issues.'
+ />
+ }
+ />
+ <BooleanSetting
+ id='enableFile'
+ label={
+ <FormattedMessage
+ id='admin.log.fileTitle'
+ defaultMessage='Log To File: '
+ />
+ }
+ helpText={
+ <FormattedMessage
+ id='admin.log.fileDescription'
+ defaultMessage='Typically set to true in production. When true, log files are written to the log file specified in file location field below.'
+ />
+ }
+ value={this.state.enableFile}
+ onChange={this.handleChange}
+ />
+ <DropdownSetting
+ id='fileLevel'
+ values={logLevels}
+ label={
+ <FormattedMessage
+ id='admin.log.fileLevelTitle'
+ defaultMessage='File Log Level:'
+ />
+ }
+ value={this.state.fileLevel}
+ onChange={this.handleChange}
+ disabled={!this.state.enableFile}
+ helpText={
+ <FormattedMessage
+ id='admin.log.fileLevelDescription'
+ defaultMessage='This setting determines the level of detail at which log events are written to the log file. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers working on debugging issues.'
+ />
+ }
+ />
+ <TextSetting
+ id='fileLocation'
+ label={
+ <FormattedMessage
+ id='admin.log.locationTitle'
+ defaultMessage='File Location:'
+ />
+ }
+ placeholder={Utils.localizeMessage('admin.log.locationPlaceholder', 'Enter your file location')}
+ helpText={
+ <FormattedMessage
+ id='admin.log.locationDescription'
+ defaultMessage='File to which log files are written. If blank, will be set to ./logs/mattermost, which writes logs to mattermost.log. Log rotation is enabled and every 10,000 lines of log information is written to new files stored in the same directory, for example mattermost.2015-09-23.001, mattermost.2015-09-23.002, and so forth.'
+ />
+ }
+ value={this.state.fileLocation}
+ onChange={this.handleChange}
+ disabled={!this.state.enableFile}
+ />
+ <TextSetting
+ id='fileFormat'
+ label={
+ <FormattedMessage
+ id='admin.log.formatTitle'
+ defaultMessage='File Format:'
+ />
+ }
+ placeholder={Utils.localizeMessage('admin.log.formatPlaceholder', 'Enter your file format')}
+ helpText={this.renderFileFormatHelpText()}
+ value={this.state.fileFormat}
+ onChange={this.handleChange}
+ disabled={!this.state.enableFile}
+ />
+ </SettingsGroup>
+ );
+ }
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- >
- <FormattedMessage
- id='admin.log.fileTitle'
- defaultMessage='Log To File: '
- />
- </label>
- <div className='col-sm-8'>
- <label className='radio-inline'>
- <input
- type='radio'
- name='fileEnable'
- ref='fileEnable'
- value='true'
- defaultChecked={this.props.config.LogSettings.EnableFile}
- onChange={this.handleChange.bind(this, 'file_true')}
- />
- <FormattedMessage
- id='admin.log.true'
- defaultMessage='true'
- />
- </label>
- <label className='radio-inline'>
- <input
- type='radio'
- name='fileEnable'
- value='false'
- defaultChecked={!this.props.config.LogSettings.EnableFile}
- onChange={this.handleChange.bind(this, 'file_false')}
- />
+ renderFileFormatHelpText() {
+ return (
+ <div>
+ <FormattedMessage
+ id='admin.log.formatDescription'
+ defaultMessage='Format of log message output. If blank will be set to "[%D %T] [%L] %M", where:'
+ />
+ <table
+ className='table table-bordered'
+ cellPadding='5'
+ >
+ <tbody>
+ <tr>
+ <td className='help-text'>{'%T'}</td><td className='help-text'>
<FormattedMessage
- id='admin.log.false'
- defaultMessage='false'
+ id='admin.log.formatTime'
+ defaultMessage='Time (15:04:05 MST)'
/>
- </label>
- <p className='help-text'>
+ </td>
+ </tr>
+ <tr>
+ <td className='help-text'>{'%D'}</td><td className='help-text'>
<FormattedMessage
- id='admin.log.fileDescription'
- defaultMessage='Typically set to true in production. When true, log files are written to the log file specified in file location field below.'
+ id='admin.log.formatDateLong'
+ defaultMessage='Date (2006/01/02)'
/>
- </p>
- </div>
- </div>
-
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='fileLevel'
- >
- <FormattedMessage
- id='admin.log.fileLevelTitle'
- defaultMessage='File Log Level:'
- />
- </label>
- <div className='col-sm-8'>
- <select
- className='form-control'
- id='fileLevel'
- ref='fileLevel'
- defaultValue={this.props.config.LogSettings.FileLevel}
- onChange={this.handleChange}
- disabled={!this.state.fileEnable}
- >
- <option value='DEBUG'>{'DEBUG'}</option>
- <option value='INFO'>{'INFO'}</option>
- <option value='ERROR'>{'ERROR'}</option>
- </select>
- <p className='help-text'>
+ </td>
+ </tr>
+ <tr>
+ <td className='help-text'>{'%d'}</td><td className='help-text'>
<FormattedMessage
- id='admin.log.fileLevelDescription'
- defaultMessage='This setting determines the level of detail at which log events are written to the log file. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers working on debugging issues.'
+ id='admin.log.formatDateShort'
+ defaultMessage='Date (01/02/06)'
/>
- </p>
- </div>
- </div>
-
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='fileLocation'
- >
- <FormattedMessage
- id='admin.log.locationTitle'
- defaultMessage='File Location:'
- />
- </label>
- <div className='col-sm-8'>
- <input
- type='text'
- className='form-control'
- id='fileLocation'
- ref='fileLocation'
- placeholder={formatMessage(holders.locationPlaceholder)}
- defaultValue={this.props.config.LogSettings.FileLocation}
- onChange={this.handleChange}
- disabled={!this.state.fileEnable}
- />
- <p className='help-text'>
+ </td>
+ </tr>
+ <tr>
+ <td className='help-text'>{'%L'}</td><td className='help-text'>
<FormattedMessage
- id='admin.log.locationDescription'
- defaultMessage='File to which log files are written. If blank, will be set to ./logs/mattermost, which writes logs to mattermost.log. Log rotation is enabled and every 10,000 lines of log information is written to new files stored in the same directory, for example mattermost.2015-09-23.001, mattermost.2015-09-23.002, and so forth.'
+ id='admin.log.formatLevel'
+ defaultMessage='Level (DEBG, INFO, EROR)'
/>
- </p>
- </div>
- </div>
-
- <div className='form-group'>
- <label
- className='control-label col-sm-4'
- htmlFor='fileFormat'
- >
- <FormattedMessage
- id='admin.log.formatTitle'
- defaultMessage='File Format:'
- />
- </label>
- <div className='col-sm-8'>
- <input
- type='text'
- className='form-control'
- id='fileFormat'
- ref='fileFormat'
- placeholder={formatMessage(holders.formatPlaceholder)}
- defaultValue={this.props.config.LogSettings.FileFormat}
- onChange={this.handleChange}
- disabled={!this.state.fileEnable}
- />
- <div className='help-text'>
+ </td>
+ </tr>
+ <tr>
+ <td className='help-text'>{'%S'}</td><td className='help-text'>
<FormattedMessage
- id='admin.log.formatDescription'
- defaultMessage='Format of log message output. If blank will be set to "[%D %T] [%L] %M", where:'
+ id='admin.log.formatSource'
+ defaultMessage='Source'
/>
- <div className='help-text'>
- <table
- className='table table-bordered'
- cellPadding='5'
- >
- <tbody>
- <tr><td className='help-text'>{'%T'}</td><td className='help-text'>
- <FormattedMessage
- id='admin.log.formatTime'
- defaultMessage='Time (15:04:05 MST)'
- />
- </td></tr>
- <tr><td className='help-text'>{'%D'}</td><td className='help-text'>
- <FormattedMessage
- id='admin.log.formatDateLong'
- defaultMessage='Date (2006/01/02)'
- />
- </td></tr>
- <tr><td className='help-text'>{'%d'}</td><td className='help-text'>
- <FormattedMessage
- id='admin.log.formatDateShort'
- defaultMessage='Date (01/02/06)'
- />
- </td></tr>
- <tr><td className='help-text'>{'%L'}</td><td className='help-text'>
- <FormattedMessage
- id='admin.log.formatLevel'
- defaultMessage='Level (DEBG, INFO, EROR)'
- />
- </td></tr>
- <tr><td className='help-text'>{'%S'}</td><td className='help-text'>
- <FormattedMessage
- id='admin.log.formatSource'
- defaultMessage='Source'
- />
- </td></tr>
- <tr><td className='help-text'>{'%M'}</td><td className='help-text'>
- <FormattedMessage
- id='admin.log.formatMessage'
- defaultMessage='Message'
- />
- </td></tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
-
- <div className='form-group'>
- <div className='col-sm-12'>
- {serverError}
- <button
- disabled={!this.state.saveNeeded}
- type='submit'
- className={saveClass}
- onClick={this.handleSubmit}
- id='save-button'
- data-loading-text={'<span class=\'glyphicon glyphicon-refresh glyphicon-refresh-animate\'></span> ' + formatMessage(holders.saving)}
- >
+ </td>
+ </tr>
+ <tr>
+ <td className='help-text'>{'%M'}</td><td className='help-text'>
<FormattedMessage
- id='admin.log.save'
- defaultMessage='Save'
+ id='admin.log.formatMessage'
+ defaultMessage='Message'
/>
- </button>
- </div>
- </div>
-
- </form>
+ </td>
+ </tr>
+ </tbody>
+ </table>
</div>
);
}
-}
-
-LogSettings.propTypes = {
- intl: intlShape.isRequired,
- config: React.PropTypes.object
-};
-
-export default injectIntl(LogSettings);
+} \ No newline at end of file