2022-04-25 23:33:32 +02:00
|
|
|
import {
|
2022-06-27 21:30:08 +02:00
|
|
|
ActionIcon,
|
|
|
|
|
Anchor,
|
|
|
|
|
Button,
|
2022-04-25 23:33:32 +02:00
|
|
|
Center,
|
|
|
|
|
Group,
|
|
|
|
|
Image,
|
2022-05-11 08:55:38 +02:00
|
|
|
LoadingOverlay,
|
2022-06-27 21:30:08 +02:00
|
|
|
Modal,
|
2022-06-16 15:38:50 -04:00
|
|
|
MultiSelect,
|
2022-08-01 14:13:35 +02:00
|
|
|
PasswordInput,
|
2022-06-27 21:30:08 +02:00
|
|
|
Select,
|
2022-08-26 19:52:20 -04:00
|
|
|
Space,
|
2022-07-26 00:51:55 +02:00
|
|
|
Stack,
|
2022-06-20 09:52:05 +02:00
|
|
|
Switch,
|
2022-06-27 21:30:08 +02:00
|
|
|
Tabs,
|
|
|
|
|
TextInput,
|
2022-05-16 12:37:38 +02:00
|
|
|
Title,
|
2022-06-27 21:30:08 +02:00
|
|
|
Tooltip,
|
2022-04-25 23:33:32 +02:00
|
|
|
} from '@mantine/core';
|
2022-05-11 08:55:38 +02:00
|
|
|
import { useForm } from '@mantine/form';
|
2022-08-26 19:52:20 -04:00
|
|
|
import { useDebouncedValue } from '@mantine/hooks';
|
2022-07-26 00:51:55 +02:00
|
|
|
import { IconApps } from '@tabler/icons';
|
2022-08-26 19:52:20 -04:00
|
|
|
import { useTranslation } from 'next-i18next';
|
2022-06-27 17:27:59 +02:00
|
|
|
import { useEffect, useState } from 'react';
|
2022-05-23 10:24:54 +02:00
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
2022-05-03 19:52:09 +02:00
|
|
|
import { useConfig } from '../../tools/state';
|
2022-09-02 13:01:56 +02:00
|
|
|
import { tryMatchPort, ServiceTypeList, StatusCodes, Config } from '../../tools/types';
|
2022-09-22 22:14:52 +03:00
|
|
|
import apiKeyPaths from './apiKeyPaths.json';
|
2022-06-28 19:08:18 +02:00
|
|
|
import Tip from '../layout/Tip';
|
2022-04-25 23:33:32 +02:00
|
|
|
|
2022-05-14 21:41:30 +02:00
|
|
|
export function AddItemShelfButton(props: any) {
|
2022-09-02 13:01:56 +02:00
|
|
|
const { config, setConfig } = useConfig();
|
2022-05-14 21:41:30 +02:00
|
|
|
const [opened, setOpened] = useState(false);
|
2022-08-22 09:50:54 +02:00
|
|
|
const { t } = useTranslation('layout/add-service-app-shelf');
|
2022-05-14 21:41:30 +02:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Modal
|
2022-05-16 13:51:14 +02:00
|
|
|
size="xl"
|
2022-05-14 21:41:30 +02:00
|
|
|
radius="md"
|
2022-08-22 09:50:54 +02:00
|
|
|
title={<Title order={3}>{t('modal.title')}</Title>}
|
2022-05-14 21:41:30 +02:00
|
|
|
opened={props.opened || opened}
|
|
|
|
|
onClose={() => setOpened(false)}
|
|
|
|
|
>
|
2022-09-02 13:01:56 +02:00
|
|
|
<AddAppShelfItemForm config={config} setConfig={setConfig} setOpened={setOpened} />
|
2022-05-14 21:41:30 +02:00
|
|
|
</Modal>
|
2022-08-22 09:50:54 +02:00
|
|
|
<Tooltip withinPortal label={t('actionIcon.tooltip')}>
|
2022-07-26 00:51:55 +02:00
|
|
|
<ActionIcon
|
|
|
|
|
variant="default"
|
|
|
|
|
radius="md"
|
|
|
|
|
size="xl"
|
|
|
|
|
color="blue"
|
|
|
|
|
style={props.style}
|
|
|
|
|
onClick={() => setOpened(true)}
|
|
|
|
|
>
|
|
|
|
|
<IconApps />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
</Tooltip>
|
2022-05-14 21:41:30 +02:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-22 13:13:41 +02:00
|
|
|
function MatchIcon(name: string | undefined, form: any) {
|
|
|
|
|
if (name === undefined || name === '') return null;
|
2022-05-12 14:24:15 +02:00
|
|
|
fetch(
|
2022-08-29 11:20:39 +02:00
|
|
|
`https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/${name
|
2022-05-12 14:24:15 +02:00
|
|
|
.replace(/\s+/g, '-')
|
2022-06-27 21:30:08 +02:00
|
|
|
.toLowerCase()
|
|
|
|
|
.replace(/^dash\.$/, 'dashdot')}.png`
|
2022-05-21 00:54:36 +02:00
|
|
|
).then((res) => {
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
form.setFieldValue('icon', res.url);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-05-08 20:00:47 +02:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-05-12 14:24:15 +02:00
|
|
|
|
2022-05-27 13:14:09 +02:00
|
|
|
function MatchService(name: string, form: any) {
|
2022-06-12 16:34:24 +02:00
|
|
|
const service = ServiceTypeList.find((s) => s.toLowerCase() === name.toLowerCase());
|
2022-05-27 13:14:09 +02:00
|
|
|
if (service) {
|
|
|
|
|
form.setFieldValue('type', service);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 13:59:46 +02:00
|
|
|
const DEFAULT_ICON = '/favicon.png';
|
2022-05-27 13:14:09 +02:00
|
|
|
|
2022-09-02 13:01:56 +02:00
|
|
|
interface AddAppShelfItemFormProps {
|
|
|
|
|
setOpened: (b: boolean) => void;
|
|
|
|
|
config: Config;
|
|
|
|
|
setConfig: (config: Config) => void;
|
|
|
|
|
// Any other props you want to pass to the form
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function AddAppShelfItemForm(props: AddAppShelfItemFormProps) {
|
|
|
|
|
const { setOpened, config, setConfig } = props;
|
|
|
|
|
// Only get config and setConfig from useCOnfig if they are not present in props
|
2022-05-11 08:55:38 +02:00
|
|
|
const [isLoading, setLoading] = useState(false);
|
2022-08-22 09:50:54 +02:00
|
|
|
const { t } = useTranslation('layout/add-service-app-shelf');
|
2022-05-11 08:55:38 +02:00
|
|
|
|
2022-05-29 10:45:49 +02:00
|
|
|
// Extract all the categories from the services in config
|
2022-08-02 00:20:04 +02:00
|
|
|
const InitialCategories = config.services.reduce((acc, cur) => {
|
2022-05-29 10:45:49 +02:00
|
|
|
if (cur.category && !acc.includes(cur.category)) {
|
|
|
|
|
acc.push(cur.category);
|
|
|
|
|
}
|
|
|
|
|
return acc;
|
|
|
|
|
}, [] as string[]);
|
2022-08-02 00:20:04 +02:00
|
|
|
const [categories, setCategories] = useState<string[]>(InitialCategories);
|
2022-05-29 10:45:49 +02:00
|
|
|
|
2022-05-06 22:29:47 +02:00
|
|
|
const form = useForm({
|
|
|
|
|
initialValues: {
|
2022-05-23 10:23:10 +02:00
|
|
|
id: props.id ?? uuidv4(),
|
2022-05-06 22:29:47 +02:00
|
|
|
type: props.type ?? 'Other',
|
2022-08-02 00:20:04 +02:00
|
|
|
category: props.category ?? null,
|
2022-05-06 22:29:47 +02:00
|
|
|
name: props.name ?? '',
|
2022-07-06 18:08:39 +02:00
|
|
|
icon: props.icon ?? DEFAULT_ICON,
|
2022-05-06 22:29:47 +02:00
|
|
|
url: props.url ?? '',
|
2022-08-02 00:20:04 +02:00
|
|
|
apiKey: props.apiKey ?? undefined,
|
|
|
|
|
username: props.username ?? undefined,
|
|
|
|
|
password: props.password ?? undefined,
|
|
|
|
|
openedUrl: props.openedUrl ?? undefined,
|
2022-08-26 19:52:20 -04:00
|
|
|
ping: props.ping ?? true,
|
2022-06-16 15:38:50 -04:00
|
|
|
status: props.status ?? ['200'],
|
2022-06-20 09:52:05 +02:00
|
|
|
newTab: props.newTab ?? true,
|
2022-05-06 22:29:47 +02:00
|
|
|
},
|
2022-05-11 08:55:38 +02:00
|
|
|
validate: {
|
2022-05-12 21:38:21 +02:00
|
|
|
apiKey: () => null,
|
2022-05-11 08:55:38 +02:00
|
|
|
// Validate icon with a regex
|
2022-06-21 19:22:14 +02:00
|
|
|
icon: (value: string) =>
|
|
|
|
|
// Disable matching to allow any values
|
|
|
|
|
null,
|
2022-05-11 08:55:38 +02:00
|
|
|
// Validate url with a regex http/https
|
|
|
|
|
url: (value: string) => {
|
2022-05-21 00:54:36 +02:00
|
|
|
try {
|
|
|
|
|
const _isValid = new URL(value);
|
|
|
|
|
} catch (e) {
|
2022-08-22 09:50:54 +02:00
|
|
|
return t('modal.form.validation.invalidUrl');
|
2022-05-11 08:55:38 +02:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
2022-06-16 15:38:50 -04:00
|
|
|
status: (value: string[]) => {
|
|
|
|
|
if (!value.length) {
|
2022-08-22 09:50:54 +02:00
|
|
|
return t('modal.form.validation.noStatusCodeSelected');
|
2022-06-16 15:38:50 -04:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
2022-05-11 08:55:38 +02:00
|
|
|
},
|
2022-05-06 22:29:47 +02:00
|
|
|
});
|
|
|
|
|
|
2022-05-29 21:39:57 +02:00
|
|
|
const [debounced, cancel] = useDebouncedValue(form.values.name, 250);
|
|
|
|
|
useEffect(() => {
|
2022-08-11 17:04:43 +02:00
|
|
|
if (
|
|
|
|
|
form.values.name !== debounced ||
|
|
|
|
|
form.values.icon !== DEFAULT_ICON ||
|
|
|
|
|
form.values.type !== 'Other'
|
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-05-29 21:39:57 +02:00
|
|
|
MatchIcon(form.values.name, form);
|
|
|
|
|
MatchService(form.values.name, form);
|
2022-07-22 16:19:07 +02:00
|
|
|
tryMatchPort(form.values.name, form);
|
2022-05-29 21:39:57 +02:00
|
|
|
}, [debounced]);
|
|
|
|
|
|
2022-05-29 10:45:49 +02:00
|
|
|
// Try to set const hostname to new URL(form.values.url).hostname)
|
|
|
|
|
// If it fails, set it to the form.values.url
|
|
|
|
|
let hostname = form.values.url;
|
|
|
|
|
try {
|
|
|
|
|
hostname = new URL(form.values.url).origin;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-06 22:29:47 +02:00
|
|
|
return (
|
|
|
|
|
<>
|
2022-08-08 15:17:51 +02:00
|
|
|
<Center mb="lg">
|
2022-05-17 21:36:07 +02:00
|
|
|
<Image
|
|
|
|
|
height={120}
|
|
|
|
|
width={120}
|
|
|
|
|
fit="contain"
|
|
|
|
|
src={form.values.icon}
|
|
|
|
|
alt="Placeholder"
|
|
|
|
|
withPlaceholder
|
|
|
|
|
/>
|
2022-05-06 22:29:47 +02:00
|
|
|
</Center>
|
|
|
|
|
<form
|
|
|
|
|
onSubmit={form.onSubmit(() => {
|
2022-08-02 00:20:04 +02:00
|
|
|
const newForm = { ...form.values };
|
|
|
|
|
if (newForm.newTab === true) newForm.newTab = undefined;
|
2022-08-12 15:09:45 +02:00
|
|
|
if (newForm.openedUrl === '') newForm.openedUrl = undefined;
|
2022-08-02 00:20:04 +02:00
|
|
|
if (newForm.category === null) newForm.category = undefined;
|
2022-08-26 19:52:20 -04:00
|
|
|
if (newForm.ping === true) newForm.ping = undefined;
|
|
|
|
|
if (
|
|
|
|
|
(newForm.status.length === 1 && newForm.status[0] === '200') ||
|
|
|
|
|
newForm.ping === false
|
|
|
|
|
) {
|
2022-08-02 00:20:04 +02:00
|
|
|
delete newForm.status;
|
2022-06-16 16:54:07 -04:00
|
|
|
}
|
2022-05-06 22:29:47 +02:00
|
|
|
// If service already exists, update it.
|
2022-08-02 00:20:04 +02:00
|
|
|
if (config.services && config.services.find((s) => s.id === newForm.id)) {
|
2022-05-06 22:29:47 +02:00
|
|
|
setConfig({
|
|
|
|
|
...config,
|
2022-05-19 22:29:35 +02:00
|
|
|
// replace the found item by matching ID
|
2022-05-06 22:29:47 +02:00
|
|
|
services: config.services.map((s) => {
|
2022-08-02 00:20:04 +02:00
|
|
|
if (s.id === newForm.id) {
|
2022-05-06 22:29:47 +02:00
|
|
|
return {
|
2022-08-02 00:20:04 +02:00
|
|
|
...newForm,
|
2022-05-06 22:29:47 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return s;
|
|
|
|
|
}),
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2022-05-12 21:38:21 +02:00
|
|
|
setConfig({
|
|
|
|
|
...config,
|
2022-08-02 00:20:04 +02:00
|
|
|
services: [...config.services, newForm],
|
2022-05-12 21:38:21 +02:00
|
|
|
});
|
2022-05-06 22:29:47 +02:00
|
|
|
}
|
2022-09-02 13:01:56 +02:00
|
|
|
setOpened(false);
|
2022-05-06 22:29:47 +02:00
|
|
|
form.reset();
|
|
|
|
|
})}
|
|
|
|
|
>
|
2022-07-26 00:51:55 +02:00
|
|
|
<Tabs defaultValue="Options">
|
|
|
|
|
<Tabs.List grow>
|
2022-08-22 09:50:54 +02:00
|
|
|
<Tabs.Tab value="Options">{t('modal.tabs.options.title')}</Tabs.Tab>
|
|
|
|
|
<Tabs.Tab value="Advanced Options">{t('modal.tabs.advancedOptions.title')}</Tabs.Tab>
|
2022-07-26 00:51:55 +02:00
|
|
|
</Tabs.List>
|
|
|
|
|
<Tabs.Panel value="Options">
|
2022-08-26 19:52:20 -04:00
|
|
|
<Space h="sm" />
|
2022-07-26 00:51:55 +02:00
|
|
|
<Stack>
|
|
|
|
|
<TextInput
|
|
|
|
|
required
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.serviceName.label')}
|
|
|
|
|
placeholder={t('modal.tabs.options.form.serviceName.placeholder')}
|
2022-07-26 00:51:55 +02:00
|
|
|
{...form.getInputProps('name')}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
required
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.iconUrl.label')}
|
2022-07-26 00:51:55 +02:00
|
|
|
placeholder={DEFAULT_ICON}
|
|
|
|
|
{...form.getInputProps('icon')}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
|
|
|
|
required
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.serviceUrl.label')}
|
2022-07-26 00:51:55 +02:00
|
|
|
placeholder="http://localhost:7575"
|
|
|
|
|
{...form.getInputProps('url')}
|
|
|
|
|
/>
|
|
|
|
|
<TextInput
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.onClickUrl.label')}
|
2022-07-26 00:51:55 +02:00
|
|
|
placeholder="http://sonarr.example.com"
|
|
|
|
|
{...form.getInputProps('openedUrl')}
|
|
|
|
|
/>
|
|
|
|
|
<Select
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.serviceType.label')}
|
|
|
|
|
defaultValue={t('modal.tabs.options.form.serviceType.defaultValue')}
|
|
|
|
|
placeholder={t('modal.tabs.options.form.serviceType.placeholder')}
|
2022-07-26 00:51:55 +02:00
|
|
|
required
|
|
|
|
|
searchable
|
|
|
|
|
data={ServiceTypeList}
|
|
|
|
|
{...form.getInputProps('type')}
|
|
|
|
|
/>
|
|
|
|
|
<Select
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.category.label')}
|
2022-08-02 00:20:04 +02:00
|
|
|
data={categories}
|
2022-08-22 09:50:54 +02:00
|
|
|
placeholder={t('modal.tabs.options.form.category.placeholder')}
|
|
|
|
|
nothingFound={t('modal.tabs.options.form.category.nothingFound')}
|
2022-07-26 00:51:55 +02:00
|
|
|
searchable
|
|
|
|
|
clearable
|
|
|
|
|
creatable
|
2022-08-02 00:20:04 +02:00
|
|
|
onCreate={(query) => {
|
|
|
|
|
const item = { value: query, label: query };
|
|
|
|
|
setCategories([...InitialCategories, query]);
|
|
|
|
|
return item;
|
2022-07-26 00:51:55 +02:00
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
getCreateLabel={(query) =>
|
2022-08-22 09:50:54 +02:00
|
|
|
t('modal.tabs.options.form.category.createLabel', {
|
2022-08-18 21:46:46 +02:00
|
|
|
query,
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
{...form.getInputProps('category')}
|
|
|
|
|
/>
|
|
|
|
|
<LoadingOverlay visible={isLoading} />
|
|
|
|
|
{(form.values.type === 'Sonarr' ||
|
|
|
|
|
form.values.type === 'Radarr' ||
|
|
|
|
|
form.values.type === 'Lidarr' ||
|
2022-08-08 15:17:51 +02:00
|
|
|
form.values.type === 'Overseerr' ||
|
2022-08-09 13:26:55 +02:00
|
|
|
form.values.type === 'Jellyseerr' ||
|
2022-08-25 18:10:23 +02:00
|
|
|
form.values.type === 'Readarr' ||
|
|
|
|
|
form.values.type === 'Sabnzbd') && (
|
2022-07-26 00:51:55 +02:00
|
|
|
<>
|
|
|
|
|
<TextInput
|
|
|
|
|
required
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.integrations.apiKey.label')}
|
|
|
|
|
placeholder={t('modal.tabs.options.form.integrations.apiKey.placeholder')}
|
2022-07-26 00:51:55 +02:00
|
|
|
value={form.values.apiKey}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
form.setFieldValue('apiKey', event.currentTarget.value);
|
|
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
error={
|
|
|
|
|
form.errors.apiKey &&
|
2022-08-22 09:50:54 +02:00
|
|
|
t('modal.tabs.options.form.integrations.apiKey.validation.noKey')
|
2022-08-18 21:46:46 +02:00
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
/>
|
|
|
|
|
<Tip>
|
2022-08-22 09:50:54 +02:00
|
|
|
{t('modal.tabs.options.form.integrations.apiKey.tip.text')}{' '}
|
2022-07-26 00:51:55 +02:00
|
|
|
<Anchor
|
|
|
|
|
target="_blank"
|
|
|
|
|
weight="bold"
|
|
|
|
|
style={{ fontStyle: 'inherit', fontSize: 'inherit' }}
|
2022-09-22 22:14:52 +03:00
|
|
|
href={`${hostname}/${apiKeyPaths[form.values.type as keyof typeof apiKeyPaths]}`}
|
2022-07-26 00:51:55 +02:00
|
|
|
>
|
2022-08-22 09:50:54 +02:00
|
|
|
{t('modal.tabs.options.form.integrations.apiKey.tip.link')}
|
2022-07-26 00:51:55 +02:00
|
|
|
</Anchor>
|
|
|
|
|
</Tip>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{form.values.type === 'qBittorrent' && (
|
|
|
|
|
<>
|
|
|
|
|
<TextInput
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.integrations.qBittorrent.username.label')}
|
2022-08-18 21:46:46 +02:00
|
|
|
placeholder={t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.qBittorrent.username.placeholder'
|
2022-08-18 21:46:46 +02:00
|
|
|
)}
|
2022-07-26 00:51:55 +02:00
|
|
|
value={form.values.username}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
form.setFieldValue('username', event.currentTarget.value);
|
|
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
error={
|
|
|
|
|
form.errors.username &&
|
|
|
|
|
t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.qBittorrent.username.validation.invalidUsername'
|
2022-08-18 21:46:46 +02:00
|
|
|
)
|
|
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
/>
|
2022-08-01 14:13:35 +02:00
|
|
|
<PasswordInput
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.integrations.qBittorrent.password.label')}
|
2022-08-18 21:46:46 +02:00
|
|
|
placeholder={t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.qBittorrent.password.placeholder'
|
2022-08-18 21:46:46 +02:00
|
|
|
)}
|
2022-07-26 00:51:55 +02:00
|
|
|
value={form.values.password}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
form.setFieldValue('password', event.currentTarget.value);
|
|
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
error={
|
|
|
|
|
form.errors.password &&
|
|
|
|
|
t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.qBittorrent.password.validation.invalidPassword'
|
2022-08-18 21:46:46 +02:00
|
|
|
)
|
|
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{form.values.type === 'Deluge' && (
|
|
|
|
|
<>
|
2022-08-01 14:13:35 +02:00
|
|
|
<PasswordInput
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.integrations.deluge.password.label')}
|
2022-08-18 21:46:46 +02:00
|
|
|
placeholder={t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.deluge.password.placeholder'
|
2022-08-18 21:46:46 +02:00
|
|
|
)}
|
2022-07-26 00:51:55 +02:00
|
|
|
value={form.values.password}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
form.setFieldValue('password', event.currentTarget.value);
|
|
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
error={
|
|
|
|
|
form.errors.password &&
|
|
|
|
|
t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.deluge.password.validation.invalidPassword'
|
2022-08-18 21:46:46 +02:00
|
|
|
)
|
|
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{form.values.type === 'Transmission' && (
|
|
|
|
|
<>
|
|
|
|
|
<TextInput
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.integrations.transmission.username.label')}
|
2022-08-18 21:46:46 +02:00
|
|
|
placeholder={t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.transmission.username.placeholder'
|
2022-08-18 21:46:46 +02:00
|
|
|
)}
|
2022-07-26 00:51:55 +02:00
|
|
|
value={form.values.username}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
form.setFieldValue('username', event.currentTarget.value);
|
|
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
error={
|
|
|
|
|
form.errors.username &&
|
|
|
|
|
t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.transmission.username.validation.invalidUsername'
|
2022-08-18 21:46:46 +02:00
|
|
|
)
|
|
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
/>
|
2022-08-01 14:13:35 +02:00
|
|
|
<PasswordInput
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.options.form.integrations.transmission.password.label')}
|
2022-08-18 21:46:46 +02:00
|
|
|
placeholder={t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.transmission.password.placeholder'
|
2022-08-18 21:46:46 +02:00
|
|
|
)}
|
2022-07-26 00:51:55 +02:00
|
|
|
value={form.values.password}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
form.setFieldValue('password', event.currentTarget.value);
|
|
|
|
|
}}
|
2022-08-18 21:46:46 +02:00
|
|
|
error={
|
|
|
|
|
form.errors.password &&
|
|
|
|
|
t(
|
2022-08-22 09:50:54 +02:00
|
|
|
'modal.tabs.options.form.integrations.transmission.password.validation.invalidPassword'
|
2022-08-18 21:46:46 +02:00
|
|
|
)
|
|
|
|
|
}
|
2022-07-26 00:51:55 +02:00
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Stack>
|
|
|
|
|
</Tabs.Panel>
|
2022-09-02 12:42:37 +02:00
|
|
|
<Tabs.Panel value="Advanced Options">
|
2022-09-02 23:47:13 +02:00
|
|
|
<Space h="sm" />
|
2022-07-26 00:51:55 +02:00
|
|
|
<Stack>
|
2022-08-26 19:52:20 -04:00
|
|
|
<Switch
|
|
|
|
|
label={t('modal.tabs.advancedOptions.form.ping.label')}
|
|
|
|
|
defaultChecked={form.values.ping}
|
|
|
|
|
{...form.getInputProps('ping')}
|
2022-05-26 18:17:59 +02:00
|
|
|
/>
|
2022-08-26 19:52:20 -04:00
|
|
|
{form.values.ping && (
|
|
|
|
|
<MultiSelect
|
|
|
|
|
required
|
|
|
|
|
label={t('modal.tabs.advancedOptions.form.httpStatusCodes.label')}
|
|
|
|
|
data={StatusCodes}
|
|
|
|
|
placeholder={t('modal.tabs.advancedOptions.form.httpStatusCodes.placeholder')}
|
|
|
|
|
clearButtonLabel={t(
|
|
|
|
|
'modal.tabs.advancedOptions.form.httpStatusCodes.clearButtonLabel'
|
|
|
|
|
)}
|
|
|
|
|
nothingFound={t('modal.tabs.advancedOptions.form.httpStatusCodes.nothingFound')}
|
|
|
|
|
defaultValue={['200']}
|
|
|
|
|
clearable
|
|
|
|
|
searchable
|
|
|
|
|
{...form.getInputProps('status')}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2022-06-20 09:52:05 +02:00
|
|
|
<Switch
|
2022-08-22 09:50:54 +02:00
|
|
|
label={t('modal.tabs.advancedOptions.form.openServiceInNewTab.label')}
|
2022-06-20 09:52:05 +02:00
|
|
|
defaultChecked={form.values.newTab}
|
|
|
|
|
{...form.getInputProps('newTab')}
|
2022-05-26 21:07:01 +02:00
|
|
|
/>
|
2022-07-26 00:51:55 +02:00
|
|
|
</Stack>
|
|
|
|
|
</Tabs.Panel>
|
2022-06-16 15:38:50 -04:00
|
|
|
</Tabs>
|
2022-05-06 22:29:47 +02:00
|
|
|
<Group grow position="center" mt="xl">
|
2022-08-18 21:46:46 +02:00
|
|
|
<Button type="submit">
|
2022-08-22 09:50:54 +02:00
|
|
|
{props.message ?? t('modal.tabs.advancedOptions.form.buttons.submit.content')}
|
2022-08-18 21:46:46 +02:00
|
|
|
</Button>
|
2022-05-06 22:29:47 +02:00
|
|
|
</Group>
|
|
|
|
|
</form>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|