feat: web add more types (#114)

This commit is contained in:
Ludvig Lundgren 2022-02-05 15:20:54 +01:00 committed by GitHub
parent 6df77de953
commit 8c9f9495ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 191 additions and 137 deletions

View file

@ -48,7 +48,7 @@ interface AddProps {
} }
export function IndexerAddForm({ isOpen, toggle }: AddProps) { export function IndexerAddForm({ isOpen, toggle }: AddProps) {
const { data } = useQuery<IndexerSchema[], Error>('indexerSchema', APIClient.indexers.getSchema, const { data } = useQuery<IndexerDefinition[], Error>('indexerDefinition', APIClient.indexers.getSchema,
{ {
enabled: isOpen, enabled: isOpen,
refetchOnWindowFocus: false refetchOnWindowFocus: false
@ -154,7 +154,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
Networks, channels and invite commands are configured automatically. Networks, channels and invite commands are configured automatically.
</p> </p>
</div> </div>
{ind.irc.settings.map((f: IndexerSchemaSettings, idx: number) => { {ind.irc.settings.map((f: IndexerSetting, idx: number) => {
switch (f.type) { switch (f.type) {
case "text": case "text":
return <TextFieldWide name={`irc.${f.name}`} label={f.label} required={f.required} key={idx} help={f.help} /> return <TextFieldWide name={`irc.${f.name}`} label={f.label} required={f.required} key={idx} help={f.help} />
@ -230,7 +230,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
</div> </div>
</div> </div>
<div className="py-6 space-y-6 space-y-0 divide-y divide-gray-200 dark:divide-gray-700"> <div className="py-6 space-y-4 divide-y divide-gray-200 dark:divide-gray-700">
<div className="py-4 flex items-center justify-between space-y-1 px-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5"> <div className="py-4 flex items-center justify-between space-y-1 px-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
<div> <div>
<label <label
@ -342,12 +342,14 @@ export function IndexerUpdateForm({ isOpen, toggle, indexer }: UpdateProps) {
deleteMutation.mutate(indexer.id) deleteMutation.mutate(indexer.id)
} }
const renderSettingFields = (settings: any[]) => { const renderSettingFields = (settings: IndexerSetting[]) => {
if (settings !== []) { if (settings === undefined) {
return null
}
return ( return (
<div key="opt"> <div key="opt">
{settings && settings.map((f: any, idx: number) => { {settings.map((f: IndexerSetting, idx: number) => {
switch (f.type) { switch (f.type) {
case "text": case "text":
return ( return (
@ -363,14 +365,19 @@ export function IndexerUpdateForm({ isOpen, toggle, indexer }: UpdateProps) {
</div> </div>
) )
} }
}
let initialValues = { let initialValues = {
id: indexer.id, id: indexer.id,
name: indexer.name, name: indexer.name,
enabled: indexer.enabled, enabled: indexer.enabled,
identifier: indexer.identifier, identifier: indexer.identifier,
settings: indexer.settings.reduce((o: any, obj: any) => ({ ...o, [obj.name]: obj.value }), {}), settings: indexer.settings?.reduce(
(o: Record<string, string>, obj: IndexerSetting) => ({
...o,
[obj.name]: obj.value
} as Record<string, string>),
{} as Record<string, string>
),
} }
return ( return (
@ -402,8 +409,7 @@ export function IndexerUpdateForm({ isOpen, toggle, indexer }: UpdateProps) {
{...field} {...field}
className="block w-full shadow-sm dark:bg-gray-800 sm:text-sm dark:text-white focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 dark:border-gray-700 rounded-md" className="block w-full shadow-sm dark:bg-gray-800 sm:text-sm dark:text-white focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 dark:border-gray-700 rounded-md"
/> />
{meta.touched && meta.error && {meta.touched && meta.error && <span>{meta.error}</span>}
<span>{meta.error}</span>}
</div> </div>
)} )}
</Field> </Field>

View file

@ -1,66 +0,0 @@
interface Action {
id: number;
name: string;
enabled: boolean;
type: ActionType;
exec_cmd: string;
exec_args: string;
watch_folder: string;
category: string;
tags: string;
label: string;
save_path: string;
paused: boolean;
ignore_rules: boolean;
limit_upload_speed: number;
limit_download_speed: number;
client_id: number;
filter_id: number;
}
interface Filter {
id: number;
name: string;
enabled: boolean;
shows: string;
min_size: string;
max_size: string;
match_sites: string[];
except_sites: string[];
delay: number;
years: string;
resolutions: string[];
sources: string[];
codecs: string[];
containers: string[];
match_release_types: string[];
quality: string[];
formats: string[];
media: string[];
match_hdr: string[];
except_hdr: string[];
log_score: number;
log: boolean;
cue: boolean;
perfect_flac: boolean;
artists: string;
albums: string;
seasons: string;
episodes: string;
match_releases: string;
except_releases: string;
match_release_groups: string;
except_release_groups: string;
match_categories: string;
except_categories: string;
tags: string;
except_tags: string;
match_uploaders: string;
except_uploaders: string;
freeleech: boolean;
freeleech_percent: string;
actions: Action[];
indexers: Indexer[];
}
type ActionType = 'TEST' | 'EXEC' | 'WATCH_FOLDER' | DownloadClientType;

View file

@ -6,15 +6,35 @@ type DownloadClientType =
'SONARR' | 'SONARR' |
'LIDARR'; 'LIDARR';
interface DownloadClientRules {
enabled: boolean;
max_active_downloads: number;
ignore_slow_torrents: boolean;
download_speed_threshold: number;
}
interface DownloadClientBasicAuth {
auth: boolean;
username: string;
password: string;
}
interface DownloadClientSettings {
apikey?: string;
basic?: DownloadClientBasicAuth;
rules?: DownloadClientRules;
}
interface DownloadClient { interface DownloadClient {
id?: number; id?: number;
id: number;
name: string; name: string;
type: DownloadClientType;
enabled: boolean; enabled: boolean;
host: string; host: string;
port: number; port: number;
ssl: boolean; ssl: boolean;
username: string; username: string;
password: string; password: string;
type: DownloadClientType; settings?: DownloadClientSettings;
settings: object;
} }

72
web/src/types/Filter.d.ts vendored Normal file
View file

@ -0,0 +1,72 @@
interface Filter {
id: number;
name: string;
enabled: boolean;
created_at: Date;
updated_at: Date;
min_size: string;
max_size: string;
delay: number;
match_releases: string;
except_releases: string;
use_regex: boolean;
match_release_groups: string;
except_release_groups: string;
scene: boolean;
origins: string;
freeleech: boolean;
freeleech_percent: string;
shows: string;
seasons: string;
episodes: string;
resolutions: string[];
codecs: string[];
sources: string[];
containers: string[];
match_hdr: string[];
except_hdr: string[];
years: string;
artists: string;
albums: string;
match_release_types: string[];
except_release_types: string[];
formats: string[];
quality: string[];
media: string[];
perfect_flac: boolean;
cue: boolean;
log: boolean;
log_score: string;
match_categories: string;
except_categories: string;
match_uploaders: string;
except_uploaders: string;
tags: string;
except_tags: string;
tags_any: string;
except_tags_any: string;
actions: Action[];
indexers: Indexer[];
}
interface Action {
id: number;
name: string;
type: ActionType;
enabled: boolean;
exec_cmd?: string;
exec_args?: string;
watch_folder?: string;
category?: string;
tags?: string;
label?: string;
save_path?: string;
paused?: boolean;
ignore_rules?: boolean;
limit_upload_speed?: number;
limit_download_speed?: number;
filter_id?: number;
client_id?: number;
}
type ActionType = 'TEST' | 'EXEC' | 'WATCH_FOLDER' | DownloadClientType;

View file

@ -3,40 +3,62 @@ interface Indexer {
name: string; name: string;
identifier: string; identifier: string;
enabled: boolean; enabled: boolean;
settings: object | any; type?: string;
settings: Array<IndexerSetting>;
} }
interface IndexerSchema { interface IndexerDefinition {
id?: number;
name: string; name: string;
identifier: string; identifier: string;
enabled?: boolean;
description: string; description: string;
language: string; language: string;
privacy: string; privacy: string;
protocol: string; protocol: string;
urls: string[]; urls: string[];
settings: IndexerSchemaSettings[]; supports: string[];
irc: IndexerSchemaIRC; settings: IndexerSetting[];
irc: IndexerIRC;
parse: IndexerParse;
} }
interface IndexerSchemaSettings { interface IndexerSetting {
name: string; name: string;
required?: boolean;
type: string; type: string;
required: boolean; value?: string;
label: string; label: string;
help: string; default?: string;
description: string; description?: string;
default: string; help?: string;
regex?: string;
} }
interface IndexerSchemaIRC { interface IndexerIRC {
network: string; network: string;
server: string; server: string;
port: number; port: number;
tls: boolean; tls: boolean;
nickserv: boolean; nickserv: boolean;
announcers: string[];
channels: string[]; channels: string[];
invite: string[]; announcers: string[];
invite_command: string; settings: IndexerSetting[];
settings: IndexerSchemaSettings[]; }
interface IndexerParse {
type: string;
lines: IndexerParseLines[];
match: IndexerParseMatch;
}
interface IndexerParseLines {
test: string[];
pattern: string;
vars: string[];
}
interface IndexerParseMatch {
torrentUrl: string;
encode: string[];
} }