Merge in DNS/adguard-home from 2504-querylog-ivl to master
Updates #2504.
Squashed commit of the following:
commit 5d15a6f735cd195fc81c8af909b56fbc7db1fe21
Merge: 8cd5c30d 97073d0d
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 18:45:10 2021 +0300
Merge branch 'master' into 2504-querylog-ivl
commit 8cd5c30de6f72d4b12162dbc9e3d90132795fe94
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 18:35:50 2021 +0300
client: fix fmt
commit e95d462c31d886bacec0735acc567fec7c962149
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 17:58:06 2021 +0300
home: imp code
commit 48737b249c52a997a4f34dac45fbaf699477b007
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 17:23:18 2021 +0300
home: imp duration
commit 44f5dc3d3ada5120d74caa24cace9a253b8f15d3
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 16:55:31 2021 +0300
home: imp code, docs
commit bb2826521b7e5d248ce2ab686528219c312b8ba2
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 16:11:40 2021 +0300
all: imp code, docs
commit d688aed1f340807a8bac8807c263956b0fc16f5b
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Thu Jul 1 13:49:42 2021 +0300
all: change querylog interval setting format
104 lines
3.4 KiB
JavaScript
104 lines
3.4 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Field, reduxForm } from 'redux-form';
|
|
import { Trans, withTranslation } from 'react-i18next';
|
|
import flow from 'lodash/flow';
|
|
|
|
import { CheckboxField, renderRadioField, toFloatNumber } from '../../../helpers/form';
|
|
import { FORM_NAME, QUERY_LOG_INTERVALS_DAYS } from '../../../helpers/constants';
|
|
import '../FormButton.css';
|
|
|
|
const getIntervalTitle = (interval, t) => {
|
|
switch (interval) {
|
|
case 0.25:
|
|
return t('interval_6_hour');
|
|
case 1:
|
|
return t('interval_24_hour');
|
|
default:
|
|
return t('interval_days', { count: interval });
|
|
}
|
|
};
|
|
|
|
const getIntervalFields = (processing, t, toNumber) => QUERY_LOG_INTERVALS_DAYS.map((interval) => (
|
|
<Field
|
|
key={interval}
|
|
name="interval"
|
|
type="radio"
|
|
component={renderRadioField}
|
|
value={interval}
|
|
placeholder={getIntervalTitle(interval, t)}
|
|
normalize={toNumber}
|
|
disabled={processing}
|
|
/>
|
|
));
|
|
|
|
const Form = (props) => {
|
|
const {
|
|
handleSubmit, submitting, invalid, processing, processingClear, handleClear, t,
|
|
} = props;
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit}>
|
|
<div className="form__group form__group--settings">
|
|
<Field
|
|
name="enabled"
|
|
type="checkbox"
|
|
component={CheckboxField}
|
|
placeholder={t('query_log_enable')}
|
|
disabled={processing}
|
|
/>
|
|
</div>
|
|
<div className="form__group form__group--settings">
|
|
<Field
|
|
name="anonymize_client_ip"
|
|
type="checkbox"
|
|
component={CheckboxField}
|
|
placeholder={t('anonymize_client_ip')}
|
|
subtitle={t('anonymize_client_ip_desc')}
|
|
disabled={processing}
|
|
/>
|
|
</div>
|
|
<label className="form__label">
|
|
<Trans>query_log_retention</Trans>
|
|
</label>
|
|
<div className="form__group form__group--settings">
|
|
<div className="custom-controls-stacked">
|
|
{getIntervalFields(processing, t, toFloatNumber)}
|
|
</div>
|
|
</div>
|
|
<div className="mt-5">
|
|
<button
|
|
type="submit"
|
|
className="btn btn-success btn-standard btn-large"
|
|
disabled={submitting || invalid || processing}
|
|
>
|
|
<Trans>save_btn</Trans>
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className="btn btn-outline-secondary btn-standard form__button"
|
|
onClick={() => handleClear()}
|
|
disabled={processingClear}
|
|
>
|
|
<Trans>query_log_clear</Trans>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
);
|
|
};
|
|
|
|
Form.propTypes = {
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
handleClear: PropTypes.func.isRequired,
|
|
submitting: PropTypes.bool.isRequired,
|
|
invalid: PropTypes.bool.isRequired,
|
|
processing: PropTypes.bool.isRequired,
|
|
processingClear: PropTypes.bool.isRequired,
|
|
t: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default flow([
|
|
withTranslation(),
|
|
reduxForm({ form: FORM_NAME.LOG_CONFIG }),
|
|
])(Form);
|