diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-02-03 08:52:18 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-02-03 08:52:18 -0500 |
commit | 75f412c4be81abfd99e2aed8c24dd15db9ae1068 (patch) | |
tree | 7e1aeb0ced8e02b8d6bed5bdce841d3f5b99f45e /web/react/components/admin_console | |
parent | d479b08c997d3216938a3e92c3634a8b5afdb841 (diff) | |
parent | d153d661db7d4349d69824d318aa9ad571970606 (diff) | |
download | chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.tar.gz chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.tar.bz2 chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.zip |
Merge pull request #2049 from mattermost/plt-1856
PLT-1856 Add basic server audit tab to system console for EE
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 | 19 | ||||
-rw-r--r-- | web/react/components/admin_console/audits.jsx | 94 |
3 files changed, 116 insertions, 0 deletions
diff --git a/web/react/components/admin_console/admin_controller.jsx b/web/react/components/admin_console/admin_controller.jsx index efd163017..360ae3ef3 100644 --- a/web/react/components/admin_console/admin_controller.jsx +++ b/web/react/components/admin_console/admin_controller.jsx @@ -11,6 +11,7 @@ import * as Utils from '../../utils/utils.jsx'; import EmailSettingsTab from './email_settings.jsx'; import LogSettingsTab from './log_settings.jsx'; import LogsTab from './logs.jsx'; +import AuditsTab from './audits.jsx'; import FileSettingsTab from './image_settings.jsx'; import PrivacySettingsTab from './privacy_settings.jsx'; import RateSettingsTab from './rate_settings.jsx'; @@ -138,6 +139,8 @@ export default class AdminController extends React.Component { tab = <LogSettingsTab config={this.state.config} />; } else if (this.state.selected === 'logs') { tab = <LogsTab />; + } else if (this.state.selected === 'audits') { + tab = <AuditsTab />; } else if (this.state.selected === 'image_settings') { tab = <FileSettingsTab config={this.state.config} />; } else if (this.state.selected === 'privacy_settings') { diff --git a/web/react/components/admin_console/admin_sidebar.jsx b/web/react/components/admin_console/admin_sidebar.jsx index d6bae1feb..642bfe9d7 100644 --- a/web/react/components/admin_console/admin_sidebar.jsx +++ b/web/react/components/admin_console/admin_sidebar.jsx @@ -214,6 +214,24 @@ export default class AdminSidebar extends React.Component { ); } + let audits; + if (global.window.mm_license.IsLicensed === 'true') { + audits = ( + <li> + <a + href='#' + className={this.isSelected('audits')} + onClick={this.handleClick.bind(this, 'audits', null)} + > + <FormattedMessage + id='admin.sidebar.audits' + defaultMessage='Audits' + /> + </a> + </li> + ); + } + return ( <div className='sidebar--left sidebar--collapsable'> <div> @@ -448,6 +466,7 @@ export default class AdminSidebar extends React.Component { /> </a> </li> + {audits} </ul> </li> </ul> diff --git a/web/react/components/admin_console/audits.jsx b/web/react/components/admin_console/audits.jsx new file mode 100644 index 000000000..866539b3d --- /dev/null +++ b/web/react/components/admin_console/audits.jsx @@ -0,0 +1,94 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import LoadingScreen from '../loading_screen.jsx'; +import AuditTable from '../audit_table.jsx'; + +import AdminStore from '../../stores/admin_store.jsx'; + +import * as AsyncClient from '../../utils/async_client.jsx'; + +import {FormattedMessage} from 'mm-intl'; + +export default class Audits extends React.Component { + constructor(props) { + super(props); + + this.onAuditListenerChange = this.onAuditListenerChange.bind(this); + this.reload = this.reload.bind(this); + + this.state = { + audits: AdminStore.getAudits() + }; + } + + componentDidMount() { + AdminStore.addAuditChangeListener(this.onAuditListenerChange); + AsyncClient.getServerAudits(); + } + + componentWillUnmount() { + AdminStore.removeAuditChangeListener(this.onAuditListenerChange); + } + + onAuditListenerChange() { + this.setState({ + audits: AdminStore.getAudits() + }); + } + + reload() { + AdminStore.saveAudits(null); + this.setState({ + audits: null + }); + + AsyncClient.getServerAudits(); + } + + render() { + var content = null; + + if (global.window.mm_license.IsLicensed !== 'true') { + return <div/>; + } + + if (this.state.audits === null) { + content = <LoadingScreen />; + } else { + content = ( + <div style={{margin: '10px'}}> + <AuditTable + audits={this.state.audits} + oneLine={true} + showUserId={true} + /> + </div> + ); + } + + return ( + <div className='panel'> + <h3> + <FormattedMessage + id='admin.audits.title' + defaultMessage='Server Audits' + /> + </h3> + <button + type='submit' + className='btn btn-primary' + onClick={this.reload} + > + <FormattedMessage + id='admin.audits.reload' + defaultMessage='Reload' + /> + </button> + <div className='log__panel'> + {content} + </div> + </div> + ); + } +} |