diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-03-16 18:16:11 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-03-16 18:16:11 -0400 |
commit | 4a4859351a4cd277f94d3faa804daaad0733b270 (patch) | |
tree | 4e7f83d3e2564b9b89d669e9f7905ff11768b11a /webapp/components/admin_console/audits.jsx | |
parent | 29fe6a3d13c9c7aa490fffebbe5d1b5fdf1e3090 (diff) | |
parent | 12896bd23eeba79884245c1c29fdc568cf21a7fa (diff) | |
download | chat-4a4859351a4cd277f94d3faa804daaad0733b270.tar.gz chat-4a4859351a4cd277f94d3faa804daaad0733b270.tar.bz2 chat-4a4859351a4cd277f94d3faa804daaad0733b270.zip |
Merge pull request #2453 from mattermost/plt-2340
PLT-2340 Converting to Webpack. Stage 1.
Diffstat (limited to 'webapp/components/admin_console/audits.jsx')
-rw-r--r-- | webapp/components/admin_console/audits.jsx | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/webapp/components/admin_console/audits.jsx b/webapp/components/admin_console/audits.jsx new file mode 100644 index 000000000..28503d783 --- /dev/null +++ b/webapp/components/admin_console/audits.jsx @@ -0,0 +1,97 @@ +// 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 'react-intl'; + +import React from 'react'; + +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} + showUserId={true} + showIp={true} + showSession={true} + /> + </div> + ); + } + + return ( + <div className='panel'> + <h3> + <FormattedMessage + id='admin.audits.title' + defaultMessage='User Activity' + /> + </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> + ); + } +} |