Files
mattermost/webapp/components/admin_console/audits.jsx

104 lines
2.9 KiB
React
Raw Normal View History

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import LoadingScreen from '../loading_screen.jsx';
import AuditTable from '../audit_table.jsx';
2016-03-14 16:07:58 -07:00
import ComplianceReports from './compliance_reports.jsx';
2016-03-14 08:50:46 -04:00
import AdminStore from 'stores/admin_store.jsx';
2016-03-14 08:50:46 -04:00
import * as AsyncClient from 'utils/async_client.jsx';
2016-03-14 08:50:46 -04:00
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) {
2016-02-22 08:31:10 -05:00
content = <LoadingScreen/>;
} else {
content = (
<div style={{margin: '10px'}}>
2016-03-14 16:07:58 -07:00
<AuditTable
audits={this.state.audits}
showUserId={true}
showIp={true}
showSession={true}
/>
</div>
);
}
return (
2016-03-14 16:07:58 -07:00
<div>
<ComplianceReports/>
<div className='panel audit-panel'>
<h3 className='admin-console-header'>
2016-03-14 16:07:58 -07:00
<FormattedMessage
id='admin.audits.title'
defaultMessage='User Activity Logs'
2016-03-14 16:07:58 -07:00
/>
<button
type='submit'
className='btn btn-link pull-right'
onClick={this.reload}
>
2016-09-23 12:29:54 -04:00
<i className='fa fa-refresh'/>
<FormattedMessage
id='admin.audits.reload'
defaultMessage='Reload User Activity Logs'
/>
</button>
2016-03-14 16:07:58 -07:00
</h3>
<div className='audit-panel__table'>
2016-03-14 16:07:58 -07:00
{content}
</div>
</div>
</div>
);
}
}