diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 2afa38bd..72436717 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -523,6 +523,7 @@ "statistics_retention_confirm": "Are you sure you want to change statistics retention? If you decrease the interval value, some data will be lost", "statistics_cleared": "Statistics successfully cleared", "statistics_enable": "Enable statistics", + "statistics_ignore_domains": "Ignore domains (separated by newline)", "interval_hours": "{{count}} hour", "interval_hours_plural": "{{count}} hours", "filters_configuration": "Filters configuration", diff --git a/client/src/actions/stats.js b/client/src/actions/stats.js index d3948efa..0e5b416e 100644 --- a/client/src/actions/stats.js +++ b/client/src/actions/stats.js @@ -13,7 +13,7 @@ export const getStatsConfigSuccess = createAction('GET_STATS_CONFIG_SUCCESS'); export const getStatsConfig = () => async (dispatch) => { dispatch(getStatsConfigRequest()); try { - const data = await apiClient.getStatsInfo(); + const data = await apiClient.getStatsConfig(); dispatch(getStatsConfigSuccess(data)); } catch (error) { dispatch(addErrorToast({ error })); diff --git a/client/src/api/Api.js b/client/src/api/Api.js index d984bbb8..92d3e558 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -497,9 +497,9 @@ class Api { // Settings for statistics GET_STATS = { path: 'stats', method: 'GET' }; - STATS_INFO = { path: 'stats_info', method: 'GET' }; + GET_STATS_CONFIG = { path: 'stats/config', method: 'GET' }; - STATS_CONFIG = { path: 'stats_config', method: 'POST' }; + UPDATE_STATS_CONFIG = { path: 'stats/config/update', method: 'PUT' }; STATS_RESET = { path: 'stats_reset', method: 'POST' }; @@ -508,13 +508,13 @@ class Api { return this.makeRequest(path, method); } - getStatsInfo() { - const { path, method } = this.STATS_INFO; + getStatsConfig() { + const { path, method } = this.GET_STATS_CONFIG; return this.makeRequest(path, method); } setStatsConfig(data) { - const { path, method } = this.STATS_CONFIG; + const { path, method } = this.UPDATE_STATS_CONFIG; const config = { data, }; diff --git a/client/src/components/Settings/StatsConfig/Form.js b/client/src/components/Settings/StatsConfig/Form.js index cf8da0ac..637337c3 100644 --- a/client/src/components/Settings/StatsConfig/Form.js +++ b/client/src/components/Settings/StatsConfig/Form.js @@ -4,23 +4,31 @@ import { Field, reduxForm } from 'redux-form'; import { Trans, withTranslation } from 'react-i18next'; import flow from 'lodash/flow'; -import { renderRadioField, toNumber, CheckboxField } from '../../../helpers/form'; -import { FORM_NAME, STATS_INTERVALS_DAYS, DISABLED_STATS_INTERVAL } from '../../../helpers/constants'; +import { + renderRadioField, + toNumber, + CheckboxField, + renderTextareaField, +} from '../../../helpers/form'; +import { + FORM_NAME, + STATS_INTERVALS_DAYS, + DAY, +} from '../../../helpers/constants'; import '../FormButton.css'; -const getIntervalTitle = (interval, t) => { - switch (interval) { +const getIntervalTitle = (intervalMs, t) => { + switch (intervalMs / DAY) { case 1: return t('interval_24_hour'); default: - return t('interval_days', { count: interval }); + return t('interval_days', { count: intervalMs / DAY }); } }; const Form = (props) => { const { handleSubmit, - change, processing, submitting, invalid, @@ -38,13 +46,6 @@ const Form = (props) => { component={CheckboxField} placeholder={t('statistics_enable')} disabled={processing} - onChange={(event) => { - if (event.target.checked) { - change('interval', STATS_INTERVALS_DAYS[0]); - } else { - change('interval', DISABLED_STATS_INTERVAL); - } - }} />