Closes #3313
Squashed commit of the following:
commit 6f2ff98a8282789e2dbb16694ca87a1f4cc8c076
Merge: 1221f02f f4dde3f2
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Wed Jul 14 15:53:18 2021 +0300
Merge branch 'master' into 3313-statistics
commit 1221f02f40628964febd22967d85d5185f87b08d
Author: Ildar Kamalov <ik@adguard.com>
Date: Wed Jul 14 15:23:09 2021 +0300
client: make client names clickable
commit 99770ec065e14ce2522a59820f9851d79001923c
Author: Ildar Kamalov <ik@adguard.com>
Date: Wed Jul 14 15:06:30 2021 +0300
client: decreasing interval confirm, disabled stats message
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
import Card from '../../ui/Card';
|
|
import Form from './Form';
|
|
|
|
class StatsConfig extends Component {
|
|
handleFormSubmit = (values) => {
|
|
const { t, interval: prevInterval } = this.props;
|
|
|
|
if (values.interval < prevInterval) {
|
|
if (window.confirm(t('statistics_retention_confirm'))) {
|
|
this.props.setStatsConfig(values);
|
|
}
|
|
} else {
|
|
this.props.setStatsConfig(values);
|
|
}
|
|
};
|
|
|
|
handleReset = () => {
|
|
const { t, resetStats } = this.props;
|
|
// eslint-disable-next-line no-alert
|
|
if (window.confirm(t('statistics_clear_confirm'))) {
|
|
resetStats();
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
t, interval, processing, processingReset,
|
|
} = this.props;
|
|
|
|
return (
|
|
<Card
|
|
title={t('statistics_configuration')}
|
|
bodyType="card-body box-body--settings"
|
|
id="stats-config"
|
|
>
|
|
<div className="form">
|
|
<Form
|
|
initialValues={{ interval }}
|
|
onSubmit={this.handleFormSubmit}
|
|
processing={processing}
|
|
processingReset={processingReset}
|
|
handleReset={this.handleReset}
|
|
/>
|
|
</div>
|
|
</Card>
|
|
);
|
|
}
|
|
}
|
|
|
|
StatsConfig.propTypes = {
|
|
interval: PropTypes.number.isRequired,
|
|
processing: PropTypes.bool.isRequired,
|
|
processingReset: PropTypes.bool.isRequired,
|
|
setStatsConfig: PropTypes.func.isRequired,
|
|
resetStats: PropTypes.func.isRequired,
|
|
t: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default withTranslation()(StatsConfig);
|