Updates#3404
Squashed commit of the following:
commit b68a1d08b0676ebb7abbb13c9274c8d509cd6eed
Merge: 81265147 6d402dc8
Author: Artem Krisanov <a.krisanov@adguard.com>
Date: Mon Apr 17 15:48:33 2023 +0300
Merge master
commit 81265147b5613be11a6621a416f9588c0e1c0ef5
Author: Artem Krisanov <a.krisanov@adguard.com>
Date: Thu Apr 13 10:54:39 2023 +0300
Changed query log 'retention' --> 'rotation'.
commit 02c5dc0b54bca9ec293ee8629d769489bc5dc533
Author: Artem Krisanov <a.krisanov@adguard.com>
Date: Wed Apr 12 13:22:22 2023 +0300
Custom inputs for query log and stats configs.
commit 21dbfbd8aac868baeea0f8b25d14786aecf09a0d
Author: Artem Krisanov <a.krisanov@adguard.com>
Date: Tue Apr 11 18:12:40 2023 +0300
Temporary changes.
88 lines
2.6 KiB
JavaScript
88 lines
2.6 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';
|
|
import { HOUR } from '../../../helpers/constants';
|
|
|
|
class StatsConfig extends Component {
|
|
handleFormSubmit = ({
|
|
enabled, interval, ignored, customInterval,
|
|
}) => {
|
|
const { t, interval: prevInterval } = this.props;
|
|
const newInterval = customInterval ? customInterval * HOUR : interval;
|
|
|
|
const config = {
|
|
enabled,
|
|
interval: newInterval,
|
|
ignored: ignored ? ignored.split('\n') : [],
|
|
};
|
|
|
|
if (config.interval < prevInterval) {
|
|
if (window.confirm(t('statistics_retention_confirm'))) {
|
|
this.props.setStatsConfig(config);
|
|
}
|
|
} else {
|
|
this.props.setStatsConfig(config);
|
|
}
|
|
};
|
|
|
|
handleReset = () => {
|
|
const { t, resetStats } = this.props;
|
|
// eslint-disable-next-line no-alert
|
|
if (window.confirm(t('statistics_clear_confirm'))) {
|
|
resetStats();
|
|
}
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
t,
|
|
interval,
|
|
customInterval,
|
|
processing,
|
|
processingReset,
|
|
ignored,
|
|
enabled,
|
|
} = this.props;
|
|
|
|
return (
|
|
<Card
|
|
title={t('statistics_configuration')}
|
|
bodyType="card-body box-body--settings"
|
|
id="stats-config"
|
|
>
|
|
<div className="form">
|
|
<Form
|
|
initialValues={{
|
|
interval,
|
|
customInterval,
|
|
enabled,
|
|
ignored: ignored.join('\n'),
|
|
}}
|
|
onSubmit={this.handleFormSubmit}
|
|
processing={processing}
|
|
processingReset={processingReset}
|
|
handleReset={this.handleReset}
|
|
/>
|
|
</div>
|
|
</Card>
|
|
);
|
|
}
|
|
}
|
|
|
|
StatsConfig.propTypes = {
|
|
interval: PropTypes.number.isRequired,
|
|
customInterval: PropTypes.number,
|
|
ignored: PropTypes.array.isRequired,
|
|
enabled: PropTypes.bool.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);
|