+ client: handle clear statistics
This commit is contained in:
@@ -38,10 +38,10 @@ const Form = (props) => {
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<label className="form__label form__label--with-desc" htmlFor="server_name">
|
||||
<Trans>time_period</Trans>
|
||||
<Trans>statistics_retention</Trans>
|
||||
</label>
|
||||
<div className="form__desc form__desc--top">
|
||||
<Trans>time_period_desc</Trans>
|
||||
<Trans>statistics_retention_desc</Trans>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { withNamespaces } from 'react-i18next';
|
||||
import { withNamespaces, Trans } from 'react-i18next';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
import { DEBOUNCE_TIMEOUT } from '../../../helpers/constants';
|
||||
@@ -12,18 +12,21 @@ class StatsConfig extends Component {
|
||||
this.props.setStatsConfig(values);
|
||||
}, DEBOUNCE_TIMEOUT);
|
||||
|
||||
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,
|
||||
t, interval, processing, processingReset,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<Card
|
||||
title={t('stats_params')}
|
||||
bodyType="card-body box-body--settings"
|
||||
>
|
||||
<Card title={t('statistics_logs')} bodyType="card-body box-body--settings">
|
||||
<div className="form">
|
||||
<Form
|
||||
initialValues={{
|
||||
@@ -33,6 +36,15 @@ class StatsConfig extends Component {
|
||||
onChange={this.handleFormChange}
|
||||
processing={processing}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-outline-secondary btn-sm mt-3"
|
||||
onClick={this.handleReset}
|
||||
disabled={processingReset}
|
||||
>
|
||||
<Trans>statistics_clear</Trans>
|
||||
</button>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
@@ -42,7 +54,9 @@ class StatsConfig extends Component {
|
||||
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,
|
||||
};
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class Settings extends Component {
|
||||
services,
|
||||
setBlockedServices,
|
||||
setStatsConfig,
|
||||
resetStats,
|
||||
stats,
|
||||
t,
|
||||
} = this.props;
|
||||
@@ -89,7 +90,9 @@ class Settings extends Component {
|
||||
<StatsConfig
|
||||
interval={stats.interval}
|
||||
processing={stats.processingSetConfig}
|
||||
processingReset={stats.processingReset}
|
||||
setStatsConfig={setStatsConfig}
|
||||
resetStats={resetStats}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-12">
|
||||
@@ -107,13 +110,13 @@ class Settings extends Component {
|
||||
}
|
||||
|
||||
Settings.propTypes = {
|
||||
initSettings: PropTypes.func,
|
||||
settings: PropTypes.object,
|
||||
settingsList: PropTypes.object,
|
||||
toggleSetting: PropTypes.func,
|
||||
getStatsConfig: PropTypes.func,
|
||||
setStatsConfig: PropTypes.func,
|
||||
t: PropTypes.func,
|
||||
initSettings: PropTypes.func.isRequired,
|
||||
settings: PropTypes.object.isRequired,
|
||||
toggleSetting: PropTypes.func.isRequired,
|
||||
getStatsConfig: PropTypes.func.isRequired,
|
||||
setStatsConfig: PropTypes.func.isRequired,
|
||||
resetStats: PropTypes.func.isRequired,
|
||||
t: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default withNamespaces()(Settings);
|
||||
|
||||
Reference in New Issue
Block a user