// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import $ from 'jquery';
import LoadingScreen from '../loading_screen.jsx';
import * as Utils from '../../utils/utils.jsx';
import AdminStore from '../../stores/admin_store.jsx';
import UserStore from '../../stores/user_store.jsx';
import Client from 'utils/web_client.jsx';
import * as AsyncClient from '../../utils/async_client.jsx';
import {FormattedMessage, FormattedDate, FormattedTime} from 'react-intl';
import React from 'react';
import ReactDOM from 'react-dom';
export default class ComplianceReports extends React.Component {
constructor(props) {
super(props);
this.onComplianceReportsListenerChange = this.onComplianceReportsListenerChange.bind(this);
this.reload = this.reload.bind(this);
this.runReport = this.runReport.bind(this);
this.getDateTime = this.getDateTime.bind(this);
this.state = {
enabled: AdminStore.getConfig().ComplianceSettings.Enable,
reports: AdminStore.getComplianceReports(),
serverError: null
};
}
componentDidMount() {
AdminStore.addComplianceReportsChangeListener(this.onComplianceReportsListenerChange);
if (global.window.mm_license.IsLicensed !== 'true' || !this.state.enabled) {
return;
}
AsyncClient.getComplianceReports();
}
componentWillUnmount() {
AdminStore.removeComplianceReportsChangeListener(this.onComplianceReportsListenerChange);
}
onComplianceReportsListenerChange() {
this.setState({
reports: AdminStore.getComplianceReports()
});
}
reload() {
AdminStore.saveComplianceReports(null);
this.setState({
reports: null,
serverError: null
});
AsyncClient.getComplianceReports();
}
runReport(e) {
e.preventDefault();
$('#run-button').button('loading');
var job = {};
job.desc = ReactDOM.findDOMNode(this.refs.desc).value;
job.emails = ReactDOM.findDOMNode(this.refs.emails).value;
job.keywords = ReactDOM.findDOMNode(this.refs.keywords).value;
job.start_at = Date.parse(ReactDOM.findDOMNode(this.refs.from).value);
job.end_at = Date.parse(ReactDOM.findDOMNode(this.refs.to).value);
Client.saveComplianceReports(
job,
() => {
ReactDOM.findDOMNode(this.refs.emails).value = '';
ReactDOM.findDOMNode(this.refs.keywords).value = '';
ReactDOM.findDOMNode(this.refs.desc).value = '';
ReactDOM.findDOMNode(this.refs.from).value = '';
ReactDOM.findDOMNode(this.refs.to).value = '';
this.reload();
$('#run-button').button('reset');
},
(err) => {
this.setState({serverError: err.message});
$('#run-button').button('reset');
}
);
}
getDateTime(millis) {
const date = new Date(millis);
return (
|
|
|
|
|
|
|
---|