From 07a9583ddf5c8b9fffba84995fb1990a92ff057f Mon Sep 17 00:00:00 2001 From: Ludvig Lundgren Date: Sun, 15 Aug 2021 18:13:11 +0200 Subject: [PATCH] add freeleech toggle (#8) --- web/src/domain/interfaces.ts | 2 + web/src/screens/Filters.tsx | 166 ++++++++++++++++++++++++++--------- 2 files changed, 127 insertions(+), 41 deletions(-) diff --git a/web/src/domain/interfaces.ts b/web/src/domain/interfaces.ts index f1e194a..8dbc4c9 100644 --- a/web/src/domain/interfaces.ts +++ b/web/src/domain/interfaces.ts @@ -58,6 +58,8 @@ export interface Filter { except_tags: string; match_uploaders: string; except_uploaders: string; + freeleech: boolean; + freeleech_percent: string; actions: Action[]; indexers: Indexer[]; } diff --git a/web/src/screens/Filters.tsx b/web/src/screens/Filters.tsx index 0d50131..2479127 100644 --- a/web/src/screens/Filters.tsx +++ b/web/src/screens/Filters.tsx @@ -1,6 +1,6 @@ import React, {Fragment, useRef, useState} from "react"; import {Dialog, Switch, Transition} from "@headlessui/react"; -import {ChevronRightIcon, ExclamationIcon, } from '@heroicons/react/solid' +import {ChevronDownIcon, ChevronRightIcon, ExclamationIcon,} from '@heroicons/react/solid' import {EmptyListState} from "../components/EmptyListState"; import { @@ -492,6 +492,8 @@ function FilterTabGeneral({filter}: FilterTabGeneralProps) { except_tags: filter.except_tags, match_uploaders: filter.match_uploaders, except_uploaders: filter.except_uploaders, + freeleech: filter.freeleech, + freeleech_percent: filter.freeleech_percent, indexers: filter.indexers || [], }} // validate={validate} @@ -542,7 +544,7 @@ function FilterTabGeneral({filter}: FilterTabGeneralProps) { -
+
@@ -615,6 +617,8 @@ function FilterTabMoviesTvNew2({filter}: FilterTabGeneralProps) { except_tags: filter.except_tags, match_uploaders: filter.match_uploaders, except_uploaders: filter.except_uploaders, + freeleech: filter.freeleech, + freeleech_percent: filter.freeleech_percent, indexers: filter.indexers || [], }} // validate={validate} @@ -664,6 +668,11 @@ function FilterTabMoviesTvNew2({filter}: FilterTabGeneralProps) { function FilterTabAdvanced({filter}: FilterTabGeneralProps) { const history = useHistory(); + const [releasesIsOpen, toggleReleases] = useToggle(false) + const [groupsIsOpen, toggleGroups] = useToggle(false) + const [categoriesIsOpen, toggleCategories] = useToggle(false) + const [uploadersIsOpen, toggleUploaders] = useToggle(false) + const [freeleechIsOpen, toggleFreeleech] = useToggle(false) const updateMutation = useMutation((filter: Filter) => APIClient.filters.update(filter), { onSuccess: () => { @@ -717,6 +726,8 @@ function FilterTabAdvanced({filter}: FilterTabGeneralProps) { except_tags: filter.except_tags, match_uploaders: filter.match_uploaders, except_uploaders: filter.except_uploaders, + freeleech: filter.freeleech, + freeleech_percent: filter.freeleech_percent, indexers: filter.indexers || [], }} // validate={validate} @@ -725,58 +736,131 @@ function FilterTabAdvanced({filter}: FilterTabGeneralProps) { {({handleSubmit, submitting, values, valid}) => { return (
-
- - -
- - +
+
+
+

Releases

+

Match or ignore

+
+
+ +
+ {releasesIsOpen && ( +
+ + +
+ )}
-
- - -
- - +
+
+
+

Groups

+

Match or ignore

+
+
+ +
+ {groupsIsOpen && ( +
+ + +
+ )}
- -
- - -
- - +
+
+
+

Categories and tags

+

Match or ignore categories or tags

+
+
+ +
+ {categoriesIsOpen && ( +
+ + + + + +
+ )}
-
- - -
- - +
+
+
+

Uploaders

+

Match or ignore uploaders

+
+
+ +
+ {uploadersIsOpen && ( +
+ + +
+ )}
-
- - -
- - +
+
+
+

Freeleech

+

Match only freeleech and freeleech percent

+
+
+ +
+ {freeleechIsOpen && ( +
+
+ +
+ + +
+ )}