From 44714dfcb18b9a393dc34be3c182b0c092eec28a Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 17 Sep 2015 21:00:59 -0700 Subject: PLT-11 Adding ability to save config file --- .../components/admin_console/log_settings.jsx | 261 +++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 web/react/components/admin_console/log_settings.jsx (limited to 'web/react/components/admin_console/log_settings.jsx') diff --git a/web/react/components/admin_console/log_settings.jsx b/web/react/components/admin_console/log_settings.jsx new file mode 100644 index 000000000..4e3db8f68 --- /dev/null +++ b/web/react/components/admin_console/log_settings.jsx @@ -0,0 +1,261 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var Client = require('../../utils/client.jsx'); +var AsyncClient = require('../../utils/async_client.jsx'); + +export default class LogSettings extends React.Component { + constructor(props) { + super(props); + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + + this.state = { + saveNeeded: false, + serverError: null + }; + } + + handleChange() { + this.setState({saveNeeded: true, serverError: this.state.serverError}); + } + + handleSubmit(e) { + e.preventDefault(); + $('#save-button').button('loading'); + + var config = this.props.config; + config.LogSettings.ConsoleEnable = React.findDOMNode(this.refs.consoleEnable).checked; + config.LogSettings.ConsoleLevel = React.findDOMNode(this.refs.consoleLevel).value; + config.LogSettings.FileEnable = React.findDOMNode(this.refs.fileEnable).checked; + config.LogSettings.FileLevel = React.findDOMNode(this.refs.fileLevel).value; + config.LogSettings.FileLocation = React.findDOMNode(this.refs.fileLocation).value.trim(); + config.LogSettings.FileFormat = React.findDOMNode(this.refs.fileFormat).value.trim(); + + Client.saveConfig( + config, + () => { + AsyncClient.getConfig(); + this.setState({serverError: null, saveNeeded: false}); + $('#save-button').button('reset'); + }, + (err) => { + this.setState({serverError: err.message, saveNeeded: true}); + $('#save-button').button('reset'); + } + ); + } + + render() { + var serverError = ''; + if (this.state.serverError) { + serverError =
; + } + + var saveClass = 'btn'; + if (this.state.saveNeeded) { + saveClass = 'btn btn-primary'; + } + + return ( +
+

{'Log Settings'}

+
+ +
+ +
+ + +

{'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 then the server will output messages to the standard output stream (stdout).'}

+
+
+ +
+ +
+ +

{'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 debugging issues working on debugging issues.'}

+
+
+ +
+ +
+ + +

{'Typically set to true in production. When true log files are written to the file specified in file location field below.'}

+
+
+ +
+ +
+ +

{'This setting determines the level of detail at which log events are written to the file. ERROR: Outputs only error messages. INFO: Outputs error messages and information around startup and initialization. DEBUG: Prints high detail for developers debugging issues working on debugging issues.'}

+
+
+ +
+ +
+ +

{'File to which log files are written. If blank, will be set to ./logs/mattermost.log. Log rotation is enabled and new files may be created in the same directory.'}

+
+
+ +
+ +
+ +

+ {'Format of log message output. If blank will be set to "[%D %T] [%L] %M", where:'} +

+ + + + + + + +
{'%T'}{'Time (15:04:05 MST)'}
{'%D'}{'Date (2006/01/02)'}
{'%d'}{'Date (01/02/06)'}
{'%L'}{'Level (DEBG, INFO, EROR)'}
{'%S'}{'Source'}
{'%M'}{'Message'}
+
+

+
+
+ +
+
+ {serverError} + +
+
+ +
+
+ ); + } +} + +LogSettings.propTypes = { + config: React.PropTypes.object +}; -- cgit v1.2.3-1-g7c22