Feature: Deluge download client (#12)

* chore: add go-libdeluge package

* feat: implement deluge v1 and v2 clients

* feat(web): handle add and update deluge clients

* chore: temp remove releaseinfo parser
This commit is contained in:
Ludvig Lundgren 2021-08-20 22:08:32 +02:00 committed by GitHub
parent eb5b040eeb
commit 0c4aaa29b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 493 additions and 122 deletions

View file

@ -9,20 +9,7 @@ import {classNames} from "../../styles/utils";
import {Field, Form} from "react-final-form";
import DEBUG from "../../components/debug";
import APIClient from "../../api/APIClient";
interface radioFieldsetOption {
label: string;
description: string;
value: string;
}
const actionTypeOptions: radioFieldsetOption[] = [
{label: "Test", description: "A simple action to test a filter.", value: "TEST"},
{label: "Watch dir", description: "Add filtered torrents to a watch directory", value: "WATCH_FOLDER"},
{label: "Exec", description: "Run a custom command after a filter match", value: "EXEC"},
{label: "qBittorrent", description: "Add torrents directly to qBittorrent", value: "QBITTORRENT"},
{label: "Deluge", description: "Add torrents directly to Deluge", value: "DELUGE"},
];
import {ActionTypeOptions} from "../../domain/constants";
interface props {
filter: Filter;
@ -393,7 +380,8 @@ function FilterActionAddForm({filter, isOpen, toggle, clients}: props) {
</div>
</div>
)
case "DELUGE":
case "DELUGE_V1":
case "DELUGE_V2":
return (
<div>
{/*TODO choose client*/}
@ -729,14 +717,14 @@ function FilterActionAddForm({filter, isOpen, toggle, clients}: props) {
<RadioGroup value={values.type} onChange={input.onChange}>
<RadioGroup.Label className="sr-only">Privacy setting</RadioGroup.Label>
<div className="bg-white rounded-md -space-y-px">
{actionTypeOptions.map((setting, settingIdx) => (
{ActionTypeOptions.map((setting, settingIdx) => (
<RadioGroup.Option
key={setting.value}
value={setting.value}
className={({checked}) =>
classNames(
settingIdx === 0 ? 'rounded-tl-md rounded-tr-md' : '',
settingIdx === actionTypeOptions.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
settingIdx === ActionTypeOptions.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
checked ? 'bg-indigo-50 border-indigo-200 z-10' : 'border-gray-200',
'relative border p-4 flex cursor-pointer focus:outline-none'
)

View file

@ -9,20 +9,7 @@ import {classNames} from "../../styles/utils";
import {Field, Form} from "react-final-form";
import DEBUG from "../../components/debug";
import APIClient from "../../api/APIClient";
interface radioFieldsetOption {
label: string;
description: string;
value: string;
}
const actionTypeOptions: radioFieldsetOption[] = [
{label: "Test", description: "A simple action to test a filter.", value: "TEST"},
{label: "Watch dir", description: "Add filtered torrents to a watch directory", value: "WATCH_FOLDER"},
{label: "Exec", description: "Run a custom command after a filter match", value: "EXEC"},
{label: "qBittorrent", description: "Add torrents directly to qBittorrent", value: "QBITTORRENT"},
{label: "Deluge", description: "Add torrents directly to Deluge", value: "DELUGE"},
];
import {ActionTypeOptions} from "../../domain/constants";
interface props {
filter: Filter;
@ -35,7 +22,7 @@ interface props {
function FilterActionUpdateForm({filter, isOpen, toggle, clients, action}: props) {
const mutation = useMutation((action: Action) => APIClient.actions.update(action), {
onSuccess: () => {
console.log("add action");
// console.log("add action");
queryClient.invalidateQueries(['filter', filter.id]);
sleep(1500)
@ -44,7 +31,7 @@ function FilterActionUpdateForm({filter, isOpen, toggle, clients, action}: props
})
useEffect(() => {
console.log("render add action form", clients)
// console.log("render add action form", clients)
}, [clients]);
const onSubmit = (data: any) => {
@ -399,7 +386,8 @@ function FilterActionUpdateForm({filter, isOpen, toggle, clients, action}: props
</div>
</div>
)
case "DELUGE":
case "DELUGE_V1":
case "DELUGE_V2":
return (
<div>
{/*TODO choose client*/}
@ -734,14 +722,14 @@ function FilterActionUpdateForm({filter, isOpen, toggle, clients, action}: props
<RadioGroup value={values.type} onChange={input.onChange}>
<RadioGroup.Label className="sr-only">Privacy setting</RadioGroup.Label>
<div className="bg-white rounded-md -space-y-px">
{actionTypeOptions.map((setting, settingIdx) => (
{ActionTypeOptions.map((setting, settingIdx) => (
<RadioGroup.Option
key={setting.value}
value={setting.value}
className={({checked}) =>
classNames(
settingIdx === 0 ? 'rounded-tl-md rounded-tr-md' : '',
settingIdx === actionTypeOptions.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
settingIdx === ActionTypeOptions.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
checked ? 'bg-indigo-50 border-indigo-200 z-10' : 'border-gray-200',
'relative border p-4 flex cursor-pointer focus:outline-none'
)

View file

@ -1,4 +1,4 @@
import {Fragment, useState} from "react";
import React, {Fragment, useState} from "react";
import {useMutation} from "react-query";
import {DOWNLOAD_CLIENT_TYPES, DownloadClient} from "../../domain/interfaces";
import {Dialog, RadioGroup, Transition} from "@headlessui/react";
@ -10,21 +10,7 @@ import {SwitchGroup} from "../../components/inputs";
import {queryClient} from "../../App";
import APIClient from "../../api/APIClient";
import {sleep} from "../../utils/utils";
interface radioFieldsetOption {
label: string;
description: string;
value: string;
}
const downloadClientTypeOptions: radioFieldsetOption[] = [
{
label: "qBittorrent",
description: "Add torrents directly to qBittorrent",
value: DOWNLOAD_CLIENT_TYPES.qBittorrent
},
{label: "Deluge", description: "Add torrents directly to Deluge", value: DOWNLOAD_CLIENT_TYPES.Deluge},
];
import {DownloadClientTypeOptions} from "../../domain/constants";
function DownloadClientAddForm({isOpen, toggle}: any) {
const [isTesting, setIsTesting] = useState(false)
@ -181,18 +167,18 @@ function DownloadClientAddForm({isOpen, toggle}: any) {
<RadioGroup value={values.type}
onChange={input.onChange}>
<RadioGroup.Label
className="sr-only">Privacy
setting</RadioGroup.Label>
className="sr-only">Client
type</RadioGroup.Label>
<div
className="bg-white rounded-md -space-y-px">
{downloadClientTypeOptions.map((setting, settingIdx) => (
{DownloadClientTypeOptions.map((setting, settingIdx) => (
<RadioGroup.Option
key={setting.value}
value={setting.value}
className={({checked}) =>
classNames(
settingIdx === 0 ? 'rounded-tl-md rounded-tr-md' : '',
settingIdx === downloadClientTypeOptions.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
settingIdx === DownloadClientTypeOptions.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
checked ? 'bg-indigo-50 border-indigo-200 z-10' : 'border-gray-200',
'relative border p-4 flex cursor-pointer focus:outline-none'
)
@ -245,7 +231,6 @@ function DownloadClientAddForm({isOpen, toggle}: any) {
</fieldset>
<div>
<div
className="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>