client: add form fields

This commit is contained in:
Ildar Kamalov 2023-11-21 16:28:03 +03:00
parent a700bfb42e
commit 789060e4d4
3 changed files with 43 additions and 3 deletions

View File

@ -734,5 +734,7 @@
"wednesday_short": "Wed", "wednesday_short": "Wed",
"thursday_short": "Thu", "thursday_short": "Thu",
"friday_short": "Fri", "friday_short": "Fri",
"saturday_short": "Sat" "saturday_short": "Sat",
"upstream_dns_cache_configuration": "Upstream DNS cache configuration",
"enable_upstream_dns_cache": "Enable upstream DNS cache"
} }

View File

@ -79,6 +79,10 @@ const ClientsTable = ({
} else { } else {
config.tags = []; config.tags = [];
} }
if (typeof values.upstreams_cache_size === 'string') {
config.upstreams_cache_size = 0;
}
} }
if (modalType === MODAL_TYPE.EDIT_FILTERS) { if (modalType === MODAL_TYPE.EDIT_FILTERS) {

View File

@ -12,8 +12,13 @@ import i18n from '../../../i18n';
import Tabs from '../../ui/Tabs'; import Tabs from '../../ui/Tabs';
import Examples from '../Dns/Upstream/Examples'; import Examples from '../Dns/Upstream/Examples';
import { ScheduleForm } from '../../Filters/Services/ScheduleForm'; import { ScheduleForm } from '../../Filters/Services/ScheduleForm';
import { toggleAllServices, trimLinesAndRemoveEmpty, captitalizeWords } from '../../../helpers/helpers';
import { import {
toggleAllServices,
trimLinesAndRemoveEmpty,
captitalizeWords,
} from '../../../helpers/helpers';
import {
toNumber,
renderInputField, renderInputField,
renderGroupField, renderGroupField,
CheckboxField, CheckboxField,
@ -21,7 +26,7 @@ import {
renderTextareaField, renderTextareaField,
} from '../../../helpers/form'; } from '../../../helpers/form';
import { validateClientId, validateRequiredValue } from '../../../helpers/validators'; import { validateClientId, validateRequiredValue } from '../../../helpers/validators';
import { CLIENT_ID_LINK, FORM_NAME } from '../../../helpers/constants'; import { CLIENT_ID_LINK, FORM_NAME, UINT32_RANGE } from '../../../helpers/constants';
import './Service.css'; import './Service.css';
const settingsCheckboxes = [ const settingsCheckboxes = [
@ -217,6 +222,35 @@ let Form = (props) => {
/> />
</div> </div>
))} ))}
<div className="form__label--bold form__label--top form__label--bot">
{t('upstream_dns_cache_configuration')}
</div>
<div className="form__group mb-2">
<Field
name="upstreams_cache_enabled"
type="checkbox"
component={CheckboxField}
placeholder={t('enable_upstream_dns_cache')}
/>
</div>
<div className="form__group form__group--settings">
<label
htmlFor="upstreams_cache_size"
className="form__label"
>
{t('cache_size')}
</label>
<Field
name="upstreams_cache_size"
type="number"
component={renderInputField}
placeholder={t('enter_cache_size')}
className="form-control"
normalize={toNumber}
min={0}
max={UINT32_RANGE.MAX}
/>
</div>
</div>, </div>,
}, },
block_services: { block_services: {