// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import LoadingScreen from 'components/loading_screen.jsx';
import * as Utils from 'utils/utils.jsx';
import UserStore from 'stores/user_store.jsx';
import {Client4} from 'mattermost-redux/client';
import React from 'react';
import PropTypes from 'prop-types';
import {FormattedMessage, FormattedDate, FormattedTime} from 'react-intl';
export default class ComplianceReports extends React.PureComponent {
static propTypes = {
/*
* Set if compliance reports are enabled in the config
*/
enabled: PropTypes.bool.isRequired,
/*
* Array of reports to render
*/
reports: PropTypes.arrayOf(PropTypes.object).isRequired,
/*
* Error message to display
*/
serverError: PropTypes.string,
actions: PropTypes.shape({
/*
* Function to get compliance reports
*/
getComplianceReports: PropTypes.func.isRequired,
/*
* Function to save compliance reports
*/
createComplianceReport: PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
this.state = {
loadingReports: true
};
}
componentDidMount() {
if (global.window.mm_license.IsLicensed !== 'true' || !this.props.enabled) {
return;
}
this.props.actions.getComplianceReports().then(
() => this.setState({loadingReports: false})
);
}
reload = () => {
this.setState({loadingReports: true});
this.props.actions.getComplianceReports().then(
() => this.setState({loadingReports: false})
);
}
runReport = (e) => {
e.preventDefault();
this.setState({runningReport: true});
const job = {};
job.desc = this.refs.desc.value;
job.emails = this.refs.emails.value;
job.keywords = this.refs.keywords.value;
job.start_at = Date.parse(this.refs.from.value);
job.end_at = Date.parse(this.refs.to.value);
this.props.actions.createComplianceReport(job).then(
(data) => {
if (data) {
this.refs.emails.value = '';
this.refs.keywords.value = '';
this.refs.desc.value = '';
this.refs.from.value = '';
this.refs.to.value = '';
}
this.setState({runningReport: false});
}
);
}
getDateTime(millis) {
const date = new Date(millis);
return (
|
|
|
|
|
|
|
---|