Implemented number input and used it with backup retention and port settings.

pull/1758/head
morpheus65535 3 years ago
parent ce1345a870
commit 0166d9a0dd

@ -46,7 +46,11 @@ const SettingsGeneralView: FunctionComponent = () => {
<Message>Valid IPv4 address or '0.0.0.0' for all interfaces</Message> <Message>Valid IPv4 address or '0.0.0.0' for all interfaces</Message>
</Input> </Input>
<Input name="Port"> <Input name="Port">
<Text placeholder={6767} settingKey="settings-general-port"></Text> <Text
placeholder={6767}
settingKey="settings-general-port"
numberWithArrows={true}
></Text>
</Input> </Input>
<Input name="Base URL"> <Input name="Base URL">
<InputGroup> <InputGroup>
@ -131,7 +135,10 @@ const SettingsGeneralView: FunctionComponent = () => {
<Text settingKey="settings-proxy-url"></Text> <Text settingKey="settings-proxy-url"></Text>
</Input> </Input>
<Input name="Port"> <Input name="Port">
<Text settingKey="settings-proxy-port"></Text> <Text
settingKey="settings-proxy-port"
numberWithArrows={true}
></Text>
</Input> </Input>
<Input name="Username"> <Input name="Username">
<Text settingKey="settings-proxy-username"></Text> <Text settingKey="settings-proxy-username"></Text>
@ -177,8 +184,17 @@ const SettingsGeneralView: FunctionComponent = () => {
</Input> </Input>
</Group> </Group>
<Group header="Backups"> <Group header="Backups">
<File settingKey="settings-backup-folder" type="bazarr"></File> <Input name="Folder">
<Message>Absolute path to the backup directory</Message> <File settingKey="settings-backup-folder" type="bazarr"></File>
<Message>Absolute path to the backup directory</Message>
</Input>
<Input name="Retention (days)">
<Text
settingKey="settings-backup-retention"
numberWithArrows={true}
></Text>
</Input>
</Group> </Group>
<Group header="Analytics"> <Group header="Analytics">
<Input> <Input>

@ -39,7 +39,10 @@ const SettingsRadarrView: FunctionComponent<Props> = () => {
<Message>Hostname or IPv4 Address</Message> <Message>Hostname or IPv4 Address</Message>
</Input> </Input>
<Input name="Port"> <Input name="Port">
<Text settingKey="settings-radarr-port"></Text> <Text
settingKey="settings-radarr-port"
numberWithArrows={true}
></Text>
</Input> </Input>
<Input name="Base URL"> <Input name="Base URL">
<InputGroup> <InputGroup>

@ -41,7 +41,10 @@ const SettingsSonarrView: FunctionComponent<Props> = () => {
<Message>Hostname or IPv4 Address</Message> <Message>Hostname or IPv4 Address</Message>
</Input> </Input>
<Input name="Port"> <Input name="Port">
<Text settingKey="settings-sonarr-port"></Text> <Text
settingKey="settings-sonarr-port"
numberWithArrows={true}
></Text>
</Input> </Input>
<Input name="Base URL"> <Input name="Base URL">
<InputGroup> <InputGroup>

@ -39,6 +39,7 @@ export interface TextProps extends BaseInput<React.ReactText> {
placeholder?: React.ReactText; placeholder?: React.ReactText;
password?: boolean; password?: boolean;
controlled?: boolean; controlled?: boolean;
numberWithArrows?: boolean;
} }
export const Text: FunctionComponent<TextProps> = ({ export const Text: FunctionComponent<TextProps> = ({
@ -49,15 +50,26 @@ export const Text: FunctionComponent<TextProps> = ({
override, override,
password, password,
settingKey, settingKey,
numberWithArrows,
}) => { }) => {
const value = useLatest<React.ReactText>(settingKey, isReactText, override); const value = useLatest<React.ReactText>(settingKey, isReactText, override);
const update = useSingleUpdate(); const update = useSingleUpdate();
const collapse = useCollapse(); const collapse = useCollapse();
const fieldType = () => {
if (password) {
return "password";
} else if (numberWithArrows) {
return "number";
} else {
return "text";
}
};
return ( return (
<Form.Control <Form.Control
type={password ? "password" : "text"} type={fieldType()}
placeholder={placeholder?.toString()} placeholder={placeholder?.toString()}
disabled={disabled} disabled={disabled}
defaultValue={controlled ? undefined : value ?? undefined} defaultValue={controlled ? undefined : value ?? undefined}

Loading…
Cancel
Save