diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 8a6a9d10..a2633ad8 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -257,12 +257,12 @@ "query_log_cleared": "The query log has been successfully cleared", "query_log_updated": "The query log has been successfully updated", "query_log_clear": "Clear query logs", - "query_log_retention": "Query logs retention", + "query_log_retention": "Query logs rotation", "query_log_enable": "Enable log", "query_log_configuration": "Logs configuration", "query_log_disabled": "The query log is disabled and can be configured in the <0>settings0>", "query_log_strict_search": "Use double quotes for strict search", - "query_log_retention_confirm": "Are you sure you want to change query log retention? If you decrease the interval value, some data will be lost", + "query_log_retention_confirm": "Are you sure you want to change query log rotation? If you decrease the interval value, some data will be lost", "anonymize_client_ip": "Anonymize client IP", "anonymize_client_ip_desc": "Don't save the client's full IP address to logs or statistics", "dns_config": "DNS server configuration", @@ -669,6 +669,8 @@ "disable_notify_for_hours_plural": "Disable protection for {{count}} hours", "disable_notify_until_tomorrow": "Disable protection until tomorrow", "enable_protection_timer": "Protection will be enabled in {{time}}", + "custom_retention_input": "Enter retention in hours", + "custom_rotation_input": "Enter rotation in hours", "protection_section_label": "Protection", "log_and_stats_section_label": "Query log and statistics", "ignore_query_log": "Ignore this client in query log", diff --git a/client/src/components/Settings/LogsConfig/Form.js b/client/src/components/Settings/LogsConfig/Form.js index b29b974e..dbecc183 100644 --- a/client/src/components/Settings/LogsConfig/Form.js +++ b/client/src/components/Settings/LogsConfig/Form.js @@ -1,25 +1,37 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; -import { Field, reduxForm } from 'redux-form'; +import { + change, + Field, + formValueSelector, + reduxForm, +} from 'redux-form'; +import { connect } from 'react-redux'; import { Trans, withTranslation } from 'react-i18next'; import flow from 'lodash/flow'; import { CheckboxField, - renderRadioField, toFloatNumber, - renderTextareaField, + renderTextareaField, renderInputField, renderRadioField, } from '../../../helpers/form'; import { FORM_NAME, QUERY_LOG_INTERVALS_DAYS, HOUR, DAY, + RETENTION_CUSTOM, + RETENTION_CUSTOM_INPUT, + RETENTION_RANGE, + CUSTOM_INTERVAL, } from '../../../helpers/constants'; import '../FormButton.css'; + const getIntervalTitle = (interval, t) => { switch (interval) { + case RETENTION_CUSTOM: + return t('settings_custom'); case 6 * HOUR: return t('interval_6_hour'); case DAY: @@ -42,11 +54,26 @@ const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS. /> )); -const Form = (props) => { +let Form = (props) => { const { - handleSubmit, submitting, invalid, processing, processingClear, handleClear, t, + handleSubmit, + submitting, + invalid, + processing, + processingClear, + handleClear, + t, + interval, + customInterval, + dispatch, } = props; + useEffect(() => { + if (QUERY_LOG_INTERVALS_DAYS.includes(interval)) { + dispatch(change(FORM_NAME.LOG_CONFIG, CUSTOM_INTERVAL, null)); + } + }, [interval]); + return (