diff options
Diffstat (limited to 'web/react/components/admin_console')
-rw-r--r-- | web/react/components/admin_console/admin_controller.jsx | 3 | ||||
-rw-r--r-- | web/react/components/admin_console/admin_sidebar.jsx | 10 | ||||
-rw-r--r-- | web/react/components/admin_console/logs.jsx | 88 |
3 files changed, 100 insertions, 1 deletions
diff --git a/web/react/components/admin_console/admin_controller.jsx b/web/react/components/admin_console/admin_controller.jsx index bb43af802..68984c9e0 100644 --- a/web/react/components/admin_console/admin_controller.jsx +++ b/web/react/components/admin_console/admin_controller.jsx @@ -4,6 +4,7 @@ var AdminSidebar = require('./admin_sidebar.jsx'); var EmailTab = require('./email_settings.jsx'); var JobsTab = require('./jobs_settings.jsx'); +var LogsTab = require('./logs.jsx'); var Navbar = require('../../components/navbar.jsx'); export default class AdminController extends React.Component { @@ -28,6 +29,8 @@ export default class AdminController extends React.Component { tab = <EmailTab />; } else if (this.state.selected === 'job_settings') { tab = <JobsTab />; + } else if (this.state.selected === 'logs') { + tab = <LogsTab />; } return ( diff --git a/web/react/components/admin_console/admin_sidebar.jsx b/web/react/components/admin_console/admin_sidebar.jsx index 6b3be89d0..a04bceef5 100644 --- a/web/react/components/admin_console/admin_sidebar.jsx +++ b/web/react/components/admin_console/admin_sidebar.jsx @@ -83,7 +83,15 @@ export default class AdminSidebar extends React.Component { {'Email Settings'} </a> </li> - <li><a href='#'>{'Other Settings'}</a></li> + <li> + <a + href='#' + className={this.isSelected('logs')} + onClick={this.handleClick.bind(null, 'logs')} + > + {'Logs'} + </a> + </li> </ul> </li> <li> diff --git a/web/react/components/admin_console/logs.jsx b/web/react/components/admin_console/logs.jsx new file mode 100644 index 000000000..d7de76a94 --- /dev/null +++ b/web/react/components/admin_console/logs.jsx @@ -0,0 +1,88 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +var AdminStore = require('../../stores/admin_store.jsx'); +var LoadingScreen = require('../loading_screen.jsx'); +var AsyncClient = require('../../utils/async_client.jsx'); + +export default class Logs extends React.Component { + constructor(props) { + super(props); + + this.onLogListenerChange = this.onLogListenerChange.bind(this); + this.reload = this.reload.bind(this); + + this.state = { + logs: AdminStore.getLogs() + }; + } + + componentDidMount() { + AdminStore.addLogChangeListener(this.onLogListenerChange); + AsyncClient.getLogs(); + } + componentWillUnmount() { + AdminStore.removeLogChangeListener(this.onLogListenerChange); + } + onLogListenerChange() { + this.setState({ + logs: AdminStore.getLogs() + }); + } + + reload() { + AdminStore.saveLogs(null); + this.setState({ + logs: null + }); + + AsyncClient.getLogs(); + } + + render() { + var content = null; + + if (this.state.logs === null) { + content = <LoadingScreen />; + } else { + content = []; + + for (var i = 0; i < this.state.logs.length; i++) { + var style = { + whiteSpace: 'nowrap', + fontFamily: 'monospace' + }; + + if (this.state.logs[i].indexOf('[EROR]') > 0) { + style.color = 'red'; + } + + content.push(<br key={'br_' + i} />); + content.push( + <span + key={'log_' + i} + style={style} + > + {this.state.logs[i]} + </span> + ); + } + } + + return ( + <div className='panel'> + <h3>{'Server Logs'}</h3> + <button + type='submit' + className='btn btn-primary' + onClick={this.reload} + > + {'Reload'} + </button> + <div className='log__panel'> + {content} + </div> + </div> + ); + } +}
\ No newline at end of file |