From 8c9f9495ba4ad6b8cfc95fb3b2a041fb0c4a96f3 Mon Sep 17 00:00:00 2001
From: Ludvig Lundgren
Date: Sat, 5 Feb 2022 15:20:54 +0100
Subject: [PATCH] feat: web add more types (#114)
---
web/src/forms/settings/IndexerForms.tsx | 58 +++++++++-------
web/src/types/Action.d.ts | 66 ------------------
web/src/types/Download.d.ts | 40 ++++++++---
web/src/types/Filter.d.ts | 72 +++++++++++++++++++
web/src/types/Indexer.d.ts | 92 +++++++++++++++----------
5 files changed, 191 insertions(+), 137 deletions(-)
delete mode 100644 web/src/types/Action.d.ts
create mode 100644 web/src/types/Filter.d.ts
diff --git a/web/src/forms/settings/IndexerForms.tsx b/web/src/forms/settings/IndexerForms.tsx
index 9d4be34..0a1a04b 100644
--- a/web/src/forms/settings/IndexerForms.tsx
+++ b/web/src/forms/settings/IndexerForms.tsx
@@ -48,7 +48,7 @@ interface AddProps {
}
export function IndexerAddForm({ isOpen, toggle }: AddProps) {
- const { data } = useQuery('indexerSchema', APIClient.indexers.getSchema,
+ const { data } = useQuery('indexerDefinition', APIClient.indexers.getSchema,
{
enabled: isOpen,
refetchOnWindowFocus: false
@@ -154,7 +154,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
Networks, channels and invite commands are configured automatically.
- {ind.irc.settings.map((f: IndexerSchemaSettings, idx: number) => {
+ {ind.irc.settings.map((f: IndexerSetting, idx: number) => {
switch (f.type) {
case "text":
return
@@ -230,7 +230,7 @@ export function IndexerAddForm({ isOpen, toggle }: AddProps) {
-
+
)}
diff --git a/web/src/types/Action.d.ts b/web/src/types/Action.d.ts
deleted file mode 100644
index d41afdf..0000000
--- a/web/src/types/Action.d.ts
+++ /dev/null
@@ -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;
diff --git a/web/src/types/Download.d.ts b/web/src/types/Download.d.ts
index 1530211..fec119c 100644
--- a/web/src/types/Download.d.ts
+++ b/web/src/types/Download.d.ts
@@ -6,15 +6,35 @@ type DownloadClientType =
'SONARR' |
'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 {
- id?: number;
- name: string;
- enabled: boolean;
- host: string;
- port: number;
- ssl: boolean;
- username: string;
- password: string;
- type: DownloadClientType;
- settings: object;
+ id?: number;
+ id: number;
+ name: string;
+ type: DownloadClientType;
+ enabled: boolean;
+ host: string;
+ port: number;
+ ssl: boolean;
+ username: string;
+ password: string;
+ settings?: DownloadClientSettings;
}
\ No newline at end of file
diff --git a/web/src/types/Filter.d.ts b/web/src/types/Filter.d.ts
new file mode 100644
index 0000000..fa4286b
--- /dev/null
+++ b/web/src/types/Filter.d.ts
@@ -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;
diff --git a/web/src/types/Indexer.d.ts b/web/src/types/Indexer.d.ts
index 17c72cc..9e84056 100644
--- a/web/src/types/Indexer.d.ts
+++ b/web/src/types/Indexer.d.ts
@@ -1,42 +1,64 @@
interface Indexer {
- id: number;
- name: string;
- identifier: string;
- enabled: boolean;
- settings: object | any;
+ id: number;
+ name: string;
+ identifier: string;
+ enabled: boolean;
+ type?: string;
+ settings: Array
;
}
-interface IndexerSchema {
- name: string;
- identifier: string;
- description: string;
- language: string;
- privacy: string;
- protocol: string;
- urls: string[];
- settings: IndexerSchemaSettings[];
- irc: IndexerSchemaIRC;
+interface IndexerDefinition {
+ id?: number;
+ name: string;
+ identifier: string;
+ enabled?: boolean;
+ description: string;
+ language: string;
+ privacy: string;
+ protocol: string;
+ urls: string[];
+ supports: string[];
+ settings: IndexerSetting[];
+ irc: IndexerIRC;
+ parse: IndexerParse;
}
-interface IndexerSchemaSettings {
- name: string;
- type: string;
- required: boolean;
- label: string;
- help: string;
- description: string;
- default: string;
+interface IndexerSetting {
+ name: string;
+ required?: boolean;
+ type: string;
+ value?: string;
+ label: string;
+ default?: string;
+ description?: string;
+ help?: string;
+ regex?: string;
}
-interface IndexerSchemaIRC {
- network: string;
- server: string;
- port: number;
- tls: boolean;
- nickserv: boolean;
- announcers: string[];
- channels: string[];
- invite: string[];
- invite_command: string;
- settings: IndexerSchemaSettings[];
-}
\ No newline at end of file
+interface IndexerIRC {
+ network: string;
+ server: string;
+ port: number;
+ tls: boolean;
+ nickserv: boolean;
+ channels: string[];
+ announcers: string[];
+ settings: IndexerSetting[];
+}
+
+interface IndexerParse {
+ type: string;
+ lines: IndexerParseLines[];
+ match: IndexerParseMatch;
+}
+
+interface IndexerParseLines {
+ test: string[];
+ pattern: string;
+ vars: string[];
+}
+
+interface IndexerParseMatch {
+ torrentUrl: string;
+ encode: string[];
+}