mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(clients): add rTorrent support (#421)
This commit is contained in:
parent
765215270a
commit
54d7151894
13 changed files with 692 additions and 541 deletions
|
@ -17,7 +17,7 @@ Installation guide and documentation can be found at https://autobrr.com
|
||||||
|
|
||||||
## Key features
|
## Key features
|
||||||
|
|
||||||
- Support for 40+ trackers with IRC announces
|
- Support for 45+ trackers with IRC announces
|
||||||
- Torznab/RSS support via Prowlarr to easily get access to hundreds of trackers
|
- Torznab/RSS support via Prowlarr to easily get access to hundreds of trackers
|
||||||
- Powerful but simple filtering with RegEx support (like in autodl-irssi)
|
- Powerful but simple filtering with RegEx support (like in autodl-irssi)
|
||||||
- Easy to use and mobile friendly web UI (with dark mode!) to manage everything
|
- Easy to use and mobile friendly web UI (with dark mode!) to manage everything
|
||||||
|
@ -32,6 +32,7 @@ Available download clients and actions
|
||||||
|
|
||||||
- qBittorrent (with built in re-announce, categories, rules, max active downloads, etc)
|
- qBittorrent (with built in re-announce, categories, rules, max active downloads, etc)
|
||||||
- Deluge v1+ and v2+
|
- Deluge v1+ and v2+
|
||||||
|
- rTorrent
|
||||||
- Transmission
|
- Transmission
|
||||||
- Sonarr, Radarr, Lidarr and Whisparr (pushes releases directly to them and gets in the early swarm, instead of getting them via RSS when it's already over)
|
- Sonarr, Radarr, Lidarr and Whisparr (pushes releases directly to them and gets in the early swarm, instead of getting them via RSS when it's already over)
|
||||||
- Watch folder
|
- Watch folder
|
||||||
|
|
3
go.mod
3
go.mod
|
@ -20,7 +20,9 @@ require (
|
||||||
github.com/hekmon/transmissionrpc/v2 v2.0.1
|
github.com/hekmon/transmissionrpc/v2 v2.0.1
|
||||||
github.com/lib/pq v1.10.6
|
github.com/lib/pq v1.10.6
|
||||||
github.com/mattn/go-shellwords v1.0.12
|
github.com/mattn/go-shellwords v1.0.12
|
||||||
|
github.com/mmcdole/gofeed v1.1.3
|
||||||
github.com/moistari/rls v0.2.6
|
github.com/moistari/rls v0.2.6
|
||||||
|
github.com/mrobinsn/go-rtorrent v1.8.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/r3labs/sse/v2 v2.8.1
|
github.com/r3labs/sse/v2 v2.8.1
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
|
@ -63,7 +65,6 @@ require (
|
||||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/mmcdole/gofeed v1.1.3 // indirect
|
|
||||||
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf // indirect
|
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
|
5
go.sum
5
go.sum
|
@ -106,6 +106,7 @@ github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnht
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/cytec/releaseparser v0.0.0-20200706155913-2341b265c370 h1:g9q5BGfDdhcXn4EmVZD8UydPXrvhSvgz3FRBn7zAJNs=
|
github.com/cytec/releaseparser v0.0.0-20200706155913-2341b265c370 h1:g9q5BGfDdhcXn4EmVZD8UydPXrvhSvgz3FRBn7zAJNs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
@ -305,6 +306,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/moistari/rls v0.2.6 h1:0PfId/3t2hC+uSKVvtvlH7UO6k4YLu8/tHR10dgcplQ=
|
github.com/moistari/rls v0.2.6 h1:0PfId/3t2hC+uSKVvtvlH7UO6k4YLu8/tHR10dgcplQ=
|
||||||
github.com/moistari/rls v0.2.6/go.mod h1:2oVpWLhkuUzu2xqRINGnvvlcAGizZGMfMv8UYnntUCg=
|
github.com/moistari/rls v0.2.6/go.mod h1:2oVpWLhkuUzu2xqRINGnvvlcAGizZGMfMv8UYnntUCg=
|
||||||
|
github.com/mrobinsn/go-rtorrent v1.8.0 h1:+61aDIP0asy57lRD/uZtmxfE0/gjkHnt3uddOhMKUJ8=
|
||||||
|
github.com/mrobinsn/go-rtorrent v1.8.0/go.mod h1:CdVq2IwM+JU9D6TnWiQSg9lqZWu6zUfK67YXET2LqIM=
|
||||||
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
||||||
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
@ -361,6 +364,7 @@ github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJ
|
||||||
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
|
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
|
||||||
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
|
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
|
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
|
||||||
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
|
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
|
||||||
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
|
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
|
||||||
|
@ -397,6 +401,7 @@ github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDW
|
||||||
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
|
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||||
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
|
68
internal/action/rtorrent.go
Normal file
68
internal/action/rtorrent.go
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package action
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/autobrr/autobrr/internal/domain"
|
||||||
|
"github.com/autobrr/autobrr/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/mrobinsn/go-rtorrent/rtorrent"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *service) rtorrent(action domain.Action, release domain.Release) ([]string, error) {
|
||||||
|
s.log.Debug().Msgf("action rTorrent: %v", action.Name)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// get client for action
|
||||||
|
client, err := s.clientSvc.FindByID(context.TODO(), action.ClientID)
|
||||||
|
if err != nil {
|
||||||
|
s.log.Error().Stack().Err(err).Msgf("error finding client: %v", action.ClientID)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if client == nil {
|
||||||
|
return nil, errors.New("could not find client by id: %v", action.ClientID)
|
||||||
|
}
|
||||||
|
|
||||||
|
var rejections []string
|
||||||
|
|
||||||
|
if release.TorrentTmpFile == "" {
|
||||||
|
if err = release.DownloadTorrentFile(); err != nil {
|
||||||
|
s.log.Error().Err(err).Msgf("could not download torrent file for release: %v", release.TorrentName)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create client
|
||||||
|
rt := rtorrent.New(client.Host, true)
|
||||||
|
|
||||||
|
tmpFile, err := ioutil.ReadFile(release.TorrentTmpFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "could not read torrent file: %v", release.TorrentTmpFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
var args []*rtorrent.FieldValue
|
||||||
|
|
||||||
|
if action.Label != "" {
|
||||||
|
args = append(args, &rtorrent.FieldValue{
|
||||||
|
Field: "d.custom1",
|
||||||
|
Value: action.Label,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if action.SavePath != "" {
|
||||||
|
args = append(args, &rtorrent.FieldValue{
|
||||||
|
Field: "d.base_path",
|
||||||
|
Value: action.SavePath,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := rt.AddTorrent(tmpFile, args...); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "could not add torrent file: %v", release.TorrentTmpFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.log.Info().Msgf("torrent with hash %v successfully added to client: '%v'", "", client.Name)
|
||||||
|
|
||||||
|
return rejections, nil
|
||||||
|
}
|
|
@ -48,6 +48,9 @@ func (s *service) RunAction(action *domain.Action, release domain.Release) ([]st
|
||||||
case domain.ActionTypeQbittorrent:
|
case domain.ActionTypeQbittorrent:
|
||||||
rejections, err = s.qbittorrent(*action, release)
|
rejections, err = s.qbittorrent(*action, release)
|
||||||
|
|
||||||
|
case domain.ActionTypeRTorrent:
|
||||||
|
rejections, err = s.rtorrent(*action, release)
|
||||||
|
|
||||||
case domain.ActionTypeTransmission:
|
case domain.ActionTypeTransmission:
|
||||||
rejections, err = s.transmission(*action, release)
|
rejections, err = s.transmission(*action, release)
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ const (
|
||||||
ActionTypeQbittorrent ActionType = "QBITTORRENT"
|
ActionTypeQbittorrent ActionType = "QBITTORRENT"
|
||||||
ActionTypeDelugeV1 ActionType = "DELUGE_V1"
|
ActionTypeDelugeV1 ActionType = "DELUGE_V1"
|
||||||
ActionTypeDelugeV2 ActionType = "DELUGE_V2"
|
ActionTypeDelugeV2 ActionType = "DELUGE_V2"
|
||||||
|
ActionTypeRTorrent ActionType = "RTORRENT"
|
||||||
ActionTypeTransmission ActionType = "TRANSMISSION"
|
ActionTypeTransmission ActionType = "TRANSMISSION"
|
||||||
ActionTypeWatchFolder ActionType = "WATCH_FOLDER"
|
ActionTypeWatchFolder ActionType = "WATCH_FOLDER"
|
||||||
ActionTypeWebhook ActionType = "WEBHOOK"
|
ActionTypeWebhook ActionType = "WEBHOOK"
|
||||||
|
|
|
@ -49,6 +49,7 @@ const (
|
||||||
DownloadClientTypeQbittorrent DownloadClientType = "QBITTORRENT"
|
DownloadClientTypeQbittorrent DownloadClientType = "QBITTORRENT"
|
||||||
DownloadClientTypeDelugeV1 DownloadClientType = "DELUGE_V1"
|
DownloadClientTypeDelugeV1 DownloadClientType = "DELUGE_V1"
|
||||||
DownloadClientTypeDelugeV2 DownloadClientType = "DELUGE_V2"
|
DownloadClientTypeDelugeV2 DownloadClientType = "DELUGE_V2"
|
||||||
|
DownloadClientTypeRTorrent DownloadClientType = "RTORRENT"
|
||||||
DownloadClientTypeTransmission DownloadClientType = "TRANSMISSION"
|
DownloadClientTypeTransmission DownloadClientType = "TRANSMISSION"
|
||||||
DownloadClientTypeRadarr DownloadClientType = "RADARR"
|
DownloadClientTypeRadarr DownloadClientType = "RADARR"
|
||||||
DownloadClientTypeSonarr DownloadClientType = "SONARR"
|
DownloadClientTypeSonarr DownloadClientType = "SONARR"
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
|
|
||||||
delugeClient "github.com/gdm85/go-libdeluge"
|
delugeClient "github.com/gdm85/go-libdeluge"
|
||||||
"github.com/hekmon/transmissionrpc/v2"
|
"github.com/hekmon/transmissionrpc/v2"
|
||||||
|
"github.com/mrobinsn/go-rtorrent/rtorrent"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *service) testConnection(client domain.DownloadClient) error {
|
func (s *service) testConnection(client domain.DownloadClient) error {
|
||||||
|
@ -24,6 +25,9 @@ func (s *service) testConnection(client domain.DownloadClient) error {
|
||||||
case domain.DownloadClientTypeDelugeV1, domain.DownloadClientTypeDelugeV2:
|
case domain.DownloadClientTypeDelugeV1, domain.DownloadClientTypeDelugeV2:
|
||||||
return s.testDelugeConnection(client)
|
return s.testDelugeConnection(client)
|
||||||
|
|
||||||
|
case domain.DownloadClientTypeRTorrent:
|
||||||
|
return s.testRTorrentConnection(client)
|
||||||
|
|
||||||
case domain.DownloadClientTypeTransmission:
|
case domain.DownloadClientTypeTransmission:
|
||||||
return s.testTransmissionConnection(client)
|
return s.testTransmissionConnection(client)
|
||||||
|
|
||||||
|
@ -119,6 +123,21 @@ func (s *service) testDelugeConnection(client domain.DownloadClient) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *service) testRTorrentConnection(client domain.DownloadClient) error {
|
||||||
|
// create client
|
||||||
|
rt := rtorrent.New(client.Host, true)
|
||||||
|
name, err := rt.Name()
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "error logging into client: %v", client.Host)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.log.Trace().Msgf("test client connection for rTorrent: got client: %v", name)
|
||||||
|
|
||||||
|
s.log.Debug().Msgf("test client connection for rTorrent: success")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *service) testTransmissionConnection(client domain.DownloadClient) error {
|
func (s *service) testTransmissionConnection(client domain.DownloadClient) error {
|
||||||
tbt, err := transmissionrpc.New(client.Host, client.Username, client.Password, &transmissionrpc.AdvancedConfig{
|
tbt, err := transmissionrpc.New(client.Host, client.Username, client.Password, &transmissionrpc.AdvancedConfig{
|
||||||
HTTPS: client.TLS,
|
HTTPS: client.TLS,
|
||||||
|
|
|
@ -176,6 +176,11 @@ export const DownloadClientTypeOptions: RadioFieldsetOption[] = [
|
||||||
description: "Add torrents directly to Deluge 2",
|
description: "Add torrents directly to Deluge 2",
|
||||||
value: "DELUGE_V2"
|
value: "DELUGE_V2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "rTorrent",
|
||||||
|
description: "Add torrents directly to rTorrent",
|
||||||
|
value: "RTORRENT"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Transmission",
|
label: "Transmission",
|
||||||
description: "Add torrents directly to Transmission",
|
description: "Add torrents directly to Transmission",
|
||||||
|
@ -207,6 +212,7 @@ export const DownloadClientTypeNameMap: Record<DownloadClientType | string, stri
|
||||||
"DELUGE_V1": "Deluge v1",
|
"DELUGE_V1": "Deluge v1",
|
||||||
"DELUGE_V2": "Deluge v2",
|
"DELUGE_V2": "Deluge v2",
|
||||||
"QBITTORRENT": "qBittorrent",
|
"QBITTORRENT": "qBittorrent",
|
||||||
|
"RTORRENT": "rTorrent",
|
||||||
"TRANSMISSION": "Transmission",
|
"TRANSMISSION": "Transmission",
|
||||||
"RADARR": "Radarr",
|
"RADARR": "Radarr",
|
||||||
"SONARR": "Sonarr",
|
"SONARR": "Sonarr",
|
||||||
|
@ -222,6 +228,7 @@ export const ActionTypeOptions: RadioFieldsetOption[] = [
|
||||||
{ label: "qBittorrent", description: "Add torrents directly to qBittorrent", value: "QBITTORRENT" },
|
{ label: "qBittorrent", description: "Add torrents directly to qBittorrent", value: "QBITTORRENT" },
|
||||||
{ label: "Deluge", description: "Add torrents directly to Deluge", value: "DELUGE_V1" },
|
{ label: "Deluge", description: "Add torrents directly to Deluge", value: "DELUGE_V1" },
|
||||||
{ label: "Deluge v2", description: "Add torrents directly to Deluge 2", value: "DELUGE_V2" },
|
{ label: "Deluge v2", description: "Add torrents directly to Deluge 2", value: "DELUGE_V2" },
|
||||||
|
{ label: "rTorrent", description: "Add torrents directly to rTorrent", value: "RTORRENT" },
|
||||||
{ label: "Transmission", description: "Add torrents directly to Transmission", value: "TRANSMISSION" },
|
{ label: "Transmission", description: "Add torrents directly to Transmission", value: "TRANSMISSION" },
|
||||||
{ label: "Radarr", description: "Send to Radarr and let it decide", value: "RADARR" },
|
{ label: "Radarr", description: "Send to Radarr and let it decide", value: "RADARR" },
|
||||||
{ label: "Sonarr", description: "Send to Sonarr and let it decide", value: "SONARR" },
|
{ label: "Sonarr", description: "Send to Sonarr and let it decide", value: "SONARR" },
|
||||||
|
@ -237,6 +244,7 @@ export const ActionTypeNameMap = {
|
||||||
"DELUGE_V1": "Deluge v1",
|
"DELUGE_V1": "Deluge v1",
|
||||||
"DELUGE_V2": "Deluge v2",
|
"DELUGE_V2": "Deluge v2",
|
||||||
"QBITTORRENT": "qBittorrent",
|
"QBITTORRENT": "qBittorrent",
|
||||||
|
"RTORRENT": "rTorrent",
|
||||||
"TRANSMISSION": "Transmission",
|
"TRANSMISSION": "Transmission",
|
||||||
"RADARR": "Radarr",
|
"RADARR": "Radarr",
|
||||||
"SONARR": "Sonarr",
|
"SONARR": "Sonarr",
|
||||||
|
@ -247,7 +255,7 @@ export const ActionTypeNameMap = {
|
||||||
export const ActionContentLayoutOptions: SelectGenericOption<ActionContentLayout>[] = [
|
export const ActionContentLayoutOptions: SelectGenericOption<ActionContentLayout>[] = [
|
||||||
{ label: "Original", description: "Original", value: "ORIGINAL" },
|
{ label: "Original", description: "Original", value: "ORIGINAL" },
|
||||||
{ label: "Create subfolder", description: "Create subfolder", value: "SUBFOLDER_CREATE" },
|
{ label: "Create subfolder", description: "Create subfolder", value: "SUBFOLDER_CREATE" },
|
||||||
{ label: "Don't create subfolder", description: "Don't create subfolder", value: "SUBFOLDER_NONE" },
|
{ label: "Don't create subfolder", description: "Don't create subfolder", value: "SUBFOLDER_NONE" }
|
||||||
];
|
];
|
||||||
|
|
||||||
export interface OptionBasic {
|
export interface OptionBasic {
|
||||||
|
|
|
@ -44,7 +44,7 @@ interface InitialValues {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function FormFieldsDefault() {
|
function FormFieldsDeluge() {
|
||||||
const {
|
const {
|
||||||
values: { tls }
|
values: { tls }
|
||||||
} = useFormikContext<InitialValues>();
|
} = useFormikContext<InitialValues>();
|
||||||
|
@ -60,7 +60,7 @@ function FormFieldsDefault() {
|
||||||
<NumberFieldWide
|
<NumberFieldWide
|
||||||
name="port"
|
name="port"
|
||||||
label="Port"
|
label="Port"
|
||||||
help="WebUI port for qBittorrent and daemon port for Deluge"
|
help="Daemon port"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SwitchGroupWide name="tls" label="TLS" />
|
<SwitchGroupWide name="tls" label="TLS" />
|
||||||
|
@ -115,7 +115,7 @@ function FormFieldsQbit() {
|
||||||
<TextFieldWide
|
<TextFieldWide
|
||||||
name="host"
|
name="host"
|
||||||
label="Host"
|
label="Host"
|
||||||
help="Eg. client.domain.ltd, domain.ltd/client, domain.ltd:port"
|
help="Eg. http(s)://client.domain.ltd, http(s)://domain.ltd/qbittorrent, http://domain.ltd:port"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{port > 0 && (
|
{port > 0 && (
|
||||||
|
@ -150,6 +150,18 @@ function FormFieldsQbit() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FormFieldsRTorrent() {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col space-y-4 px-1 py-6 sm:py-0 sm:space-y-0">
|
||||||
|
<TextFieldWide
|
||||||
|
name="host"
|
||||||
|
label="Host"
|
||||||
|
help="Eg. http(s)://client.domain.ltd/RPC2, http(s)://domain.ltd/client, http(s)://domain.ltd/RPC2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function FormFieldsTransmission() {
|
function FormFieldsTransmission() {
|
||||||
const {
|
const {
|
||||||
values: { tls }
|
values: { tls }
|
||||||
|
@ -185,9 +197,10 @@ export interface componentMapType {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const componentMap: componentMapType = {
|
export const componentMap: componentMapType = {
|
||||||
DELUGE_V1: <FormFieldsDefault/>,
|
DELUGE_V1: <FormFieldsDeluge/>,
|
||||||
DELUGE_V2: <FormFieldsDefault/>,
|
DELUGE_V2: <FormFieldsDeluge/>,
|
||||||
QBITTORRENT: <FormFieldsQbit/>,
|
QBITTORRENT: <FormFieldsQbit/>,
|
||||||
|
RTORRENT: <FormFieldsRTorrent />,
|
||||||
TRANSMISSION: <FormFieldsTransmission/>,
|
TRANSMISSION: <FormFieldsTransmission/>,
|
||||||
RADARR: <FormFieldsArr/>,
|
RADARR: <FormFieldsArr/>,
|
||||||
SONARR: <FormFieldsArr/>,
|
SONARR: <FormFieldsArr/>,
|
||||||
|
|
544
web/src/screens/filters/action.tsx
Normal file
544
web/src/screens/filters/action.tsx
Normal file
|
@ -0,0 +1,544 @@
|
||||||
|
import { AlertWarning } from "../../components/alerts";
|
||||||
|
import { DownloadClientSelect, NumberField, Select, SwitchGroup, TextField } from "../../components/inputs";
|
||||||
|
import { ActionContentLayoutOptions, ActionTypeNameMap, ActionTypeOptions } from "../../domain/constants";
|
||||||
|
import React, { Fragment, useRef } from "react";
|
||||||
|
import { useQuery } from "react-query";
|
||||||
|
import { APIClient } from "../../api/APIClient";
|
||||||
|
import { Field, FieldArray, FieldProps, FormikValues } from "formik";
|
||||||
|
import { EmptyListState } from "../../components/emptystates";
|
||||||
|
import { useToggle } from "../../hooks/hooks";
|
||||||
|
import { classNames } from "../../utils";
|
||||||
|
import { Dialog, Switch as SwitchBasic, Transition } from "@headlessui/react";
|
||||||
|
import { ChevronRightIcon } from "@heroicons/react/solid";
|
||||||
|
import { DeleteModal } from "../../components/modals";
|
||||||
|
import { CollapsableSection } from "./details";
|
||||||
|
|
||||||
|
interface FilterActionsProps {
|
||||||
|
filter: Filter;
|
||||||
|
values: FormikValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FilterActions({ filter, values }: FilterActionsProps) {
|
||||||
|
const { data } = useQuery(
|
||||||
|
["filters", "download_clients"],
|
||||||
|
() => APIClient.download_clients.getAll(),
|
||||||
|
{ refetchOnWindowFocus: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
const newAction = {
|
||||||
|
name: "new action",
|
||||||
|
enabled: true,
|
||||||
|
type: "TEST",
|
||||||
|
watch_folder: "",
|
||||||
|
exec_cmd: "",
|
||||||
|
exec_args: "",
|
||||||
|
category: "",
|
||||||
|
tags: "",
|
||||||
|
label: "",
|
||||||
|
save_path: "",
|
||||||
|
paused: false,
|
||||||
|
ignore_rules: false,
|
||||||
|
skip_hash_check: false,
|
||||||
|
content_layout: "",
|
||||||
|
limit_upload_speed: 0,
|
||||||
|
limit_download_speed: 0,
|
||||||
|
limit_ratio: 0,
|
||||||
|
limit_seed_time: 0,
|
||||||
|
reannounce_skip: false,
|
||||||
|
reannounce_delete: false,
|
||||||
|
reannounce_interval: 7,
|
||||||
|
reannounce_max_attempts: 25,
|
||||||
|
filter_id: filter.id,
|
||||||
|
webhook_host: "",
|
||||||
|
webhook_type: "",
|
||||||
|
webhook_method: "",
|
||||||
|
webhook_data: "",
|
||||||
|
webhook_headers: []
|
||||||
|
// client_id: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mt-10">
|
||||||
|
<FieldArray name="actions">
|
||||||
|
{({ remove, push }) => (
|
||||||
|
<Fragment>
|
||||||
|
<div className="-ml-4 -mt-4 mb-6 flex justify-between items-center flex-wrap sm:flex-nowrap">
|
||||||
|
<div className="ml-4 mt-4">
|
||||||
|
<h3 className="text-lg leading-6 font-medium text-gray-900 dark:text-gray-200">Actions</h3>
|
||||||
|
<p className="mt-1 text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
Add to download clients or run custom commands.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="ml-4 mt-4 flex-shrink-0">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="relative inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 dark:bg-blue-600 hover:bg-indigo-700 dark:hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-blue-500"
|
||||||
|
onClick={() => push(newAction)}
|
||||||
|
>
|
||||||
|
Add new
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="light:bg-white dark:bg-gray-800 light:shadow sm:rounded-md">
|
||||||
|
{values.actions.length > 0 ?
|
||||||
|
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
|
||||||
|
{values.actions.map((action: Action, index: number) => (
|
||||||
|
<FilterActionsItem action={action} clients={data ?? []} idx={index} remove={remove} key={index}/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
: <EmptyListState text="No actions yet!"/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</Fragment>
|
||||||
|
)}
|
||||||
|
</FieldArray>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TypeFormProps {
|
||||||
|
action: Action;
|
||||||
|
idx: number;
|
||||||
|
clients: Array<DownloadClient>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TypeForm = ({ action, idx, clients }: TypeFormProps) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case "TEST":
|
||||||
|
return (
|
||||||
|
<AlertWarning
|
||||||
|
text="The test action does nothing except to show if the filter works."
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case "EXEC":
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.exec_cmd`}
|
||||||
|
label="Command"
|
||||||
|
columns={6}
|
||||||
|
placeholder="Path to program eg. /bin/test"
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.exec_args`}
|
||||||
|
label="Arguments"
|
||||||
|
columns={6}
|
||||||
|
placeholder="Arguments eg. --test"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "WATCH_FOLDER":
|
||||||
|
return (
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.watch_folder`}
|
||||||
|
label="Watch folder"
|
||||||
|
columns={6}
|
||||||
|
placeholder="Watch directory eg. /home/user/rwatch"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "WEBHOOK":
|
||||||
|
return (
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.webhook_host`}
|
||||||
|
label="Host"
|
||||||
|
columns={6}
|
||||||
|
placeholder="Host eg. http://localhost/webhook"
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.webhook_data`}
|
||||||
|
label="Data (json)"
|
||||||
|
columns={6}
|
||||||
|
placeholder={"Request data: { \"key\": \"value\" }"}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "QBITTORRENT":
|
||||||
|
return (
|
||||||
|
<div className="w-full">
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<DownloadClientSelect
|
||||||
|
name={`actions.${idx}.client_id`}
|
||||||
|
action={action}
|
||||||
|
clients={clients}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="col-span-6 sm:col-span-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.save_path`}
|
||||||
|
label="Save path"
|
||||||
|
columns={6}
|
||||||
|
placeholder="eg. /full/path/to/watch_folder"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.category`}
|
||||||
|
label="Category"
|
||||||
|
columns={6}
|
||||||
|
placeholder="eg. category"
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.tags`}
|
||||||
|
label="Tags"
|
||||||
|
columns={6}
|
||||||
|
placeholder="eg. tag1,tag2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CollapsableSection title="Rules" subtitle="client options">
|
||||||
|
<div className="col-span-12">
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.limit_download_speed`}
|
||||||
|
label="Limit download speed (KiB/s)"
|
||||||
|
/>
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.limit_upload_speed`}
|
||||||
|
label="Limit upload speed (KiB/s)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.limit_ratio`}
|
||||||
|
label="Ratio limit"
|
||||||
|
step={0.5}
|
||||||
|
/>
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.limit_seed_time`}
|
||||||
|
label="Seed time limit (seconds)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-6">
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.paused`}
|
||||||
|
label="Add paused"
|
||||||
|
description="Add torrent as paused"
|
||||||
|
/>
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.ignore_rules`}
|
||||||
|
label="Ignore client rules"
|
||||||
|
description="Download if max active reached"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-6">
|
||||||
|
<Select
|
||||||
|
name={`actions.${idx}.content_layout`}
|
||||||
|
label="Content Layout"
|
||||||
|
optionDefaultText="Select content layout"
|
||||||
|
options={ActionContentLayoutOptions}
|
||||||
|
/>
|
||||||
|
<div className="mt-2">
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.skip_hash_check`}
|
||||||
|
label="Skip hash check"
|
||||||
|
description="Add torrent and skip hash check"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CollapsableSection>
|
||||||
|
|
||||||
|
<CollapsableSection title="Advanced" subtitle="Advanced options">
|
||||||
|
<div className="col-span-12">
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.reannounce_interval`}
|
||||||
|
label="Reannounce interval. Run every X seconds"
|
||||||
|
/>
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.reannounce_max_attempts`}
|
||||||
|
label="Run reannounce Y times"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-6">
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.reannounce_skip`}
|
||||||
|
label="Skip reannounce"
|
||||||
|
description="If reannounce is not needed, skip"
|
||||||
|
/>
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.reannounce_delete`}
|
||||||
|
label="Delete stalled"
|
||||||
|
description="Delete stalled torrents after X attempts"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CollapsableSection>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "DELUGE_V1":
|
||||||
|
case "DELUGE_V2":
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<DownloadClientSelect
|
||||||
|
name={`actions.${idx}.client_id`}
|
||||||
|
action={action}
|
||||||
|
clients={clients}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.save_path`}
|
||||||
|
label="Save path"
|
||||||
|
columns={6}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 col-span-12 sm:col-span-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.label`}
|
||||||
|
label="Label"
|
||||||
|
columns={6}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.limit_download_speed`}
|
||||||
|
label="Limit download speed (KB/s)"
|
||||||
|
/>
|
||||||
|
<NumberField
|
||||||
|
name={`actions.${idx}.limit_upload_speed`}
|
||||||
|
label="Limit upload speed (KB/s)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<div className="col-span-6">
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.paused`}
|
||||||
|
label="Add paused"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "RTORRENT":
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<DownloadClientSelect
|
||||||
|
name={`actions.${idx}.client_id`}
|
||||||
|
action={action}
|
||||||
|
clients={clients}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.label`}
|
||||||
|
label="Label"
|
||||||
|
columns={6}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.save_path`}
|
||||||
|
label="Save path"
|
||||||
|
columns={6}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "TRANSMISSION":
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<DownloadClientSelect
|
||||||
|
name={`actions.${idx}.client_id`}
|
||||||
|
action={action}
|
||||||
|
clients={clients}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<TextField
|
||||||
|
name={`actions.${idx}.save_path`}
|
||||||
|
label="Save path"
|
||||||
|
columns={6}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<div className="col-span-6">
|
||||||
|
<SwitchGroup
|
||||||
|
name={`actions.${idx}.paused`}
|
||||||
|
label="Add paused"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
case "RADARR":
|
||||||
|
case "SONARR":
|
||||||
|
case "LIDARR":
|
||||||
|
case "WHISPARR":
|
||||||
|
return (
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<DownloadClientSelect
|
||||||
|
name={`actions.${idx}.client_id`}
|
||||||
|
action={action}
|
||||||
|
clients={clients}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
interface FilterActionsItemProps {
|
||||||
|
action: Action;
|
||||||
|
clients: DownloadClient[];
|
||||||
|
idx: number;
|
||||||
|
remove: <T>(index: number) => T | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FilterActionsItem({ action, clients, idx, remove }: FilterActionsItemProps) {
|
||||||
|
const cancelButtonRef = useRef(null);
|
||||||
|
|
||||||
|
const [deleteModalIsOpen, toggleDeleteModal] = useToggle(false);
|
||||||
|
const [edit, toggleEdit] = useToggle(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<div
|
||||||
|
className={classNames(
|
||||||
|
idx % 2 === 0 ? "bg-white dark:bg-gray-800" : "bg-gray-50 dark:bg-gray-700",
|
||||||
|
"flex items-center sm:px-6 hover:bg-gray-50 dark:hover:bg-gray-600"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Field name={`actions.${idx}.enabled`} type="checkbox">
|
||||||
|
{({
|
||||||
|
field,
|
||||||
|
form: { setFieldValue }
|
||||||
|
}: FieldProps) => (
|
||||||
|
<SwitchBasic
|
||||||
|
{...field}
|
||||||
|
type="button"
|
||||||
|
value={field.value}
|
||||||
|
checked={field.checked ?? false}
|
||||||
|
onChange={(value: boolean) => {
|
||||||
|
setFieldValue(field?.name ?? "", value);
|
||||||
|
}}
|
||||||
|
className={classNames(
|
||||||
|
field.value ? "bg-teal-500 dark:bg-blue-500" : "bg-gray-200 dark:bg-gray-600",
|
||||||
|
"relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="sr-only">toggle enabled</span>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={classNames(
|
||||||
|
field.value ? "translate-x-5" : "translate-x-0",
|
||||||
|
"inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SwitchBasic>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
|
||||||
|
<button className="px-4 py-4 w-full flex" type="button" onClick={toggleEdit}>
|
||||||
|
<div className="min-w-0 flex-1 sm:flex sm:items-center sm:justify-between">
|
||||||
|
<div className="truncate">
|
||||||
|
<div className="flex text-sm">
|
||||||
|
<p className="ml-4 font-medium text-indigo-600 dark:text-gray-100 truncate">
|
||||||
|
{action.name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4 flex-shrink-0 sm:mt-0 sm:ml-5">
|
||||||
|
<div className="flex overflow-hidden -space-x-1">
|
||||||
|
<span className="text-sm font-normal text-gray-500 dark:text-gray-400">
|
||||||
|
{ActionTypeNameMap[action.type]}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="ml-5 flex-shrink-0">
|
||||||
|
<ChevronRightIcon
|
||||||
|
className="h-5 w-5 text-gray-400"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{edit && (
|
||||||
|
<div className="px-4 py-4 flex items-center sm:px-6 border dark:border-gray-600">
|
||||||
|
<Transition.Root show={deleteModalIsOpen} as={Fragment}>
|
||||||
|
<Dialog
|
||||||
|
as="div"
|
||||||
|
static
|
||||||
|
className="fixed inset-0 overflow-y-auto"
|
||||||
|
initialFocus={cancelButtonRef}
|
||||||
|
open={deleteModalIsOpen}
|
||||||
|
onClose={toggleDeleteModal}
|
||||||
|
>
|
||||||
|
<DeleteModal
|
||||||
|
isOpen={deleteModalIsOpen}
|
||||||
|
buttonRef={cancelButtonRef}
|
||||||
|
toggle={toggleDeleteModal}
|
||||||
|
deleteAction={() => remove(idx)}
|
||||||
|
title="Remove filter action"
|
||||||
|
text="Are you sure you want to remove this action? This action cannot be undone."
|
||||||
|
/>
|
||||||
|
</Dialog>
|
||||||
|
</Transition.Root>
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
|
||||||
|
<div className="mt-6 grid grid-cols-12 gap-6">
|
||||||
|
<Select
|
||||||
|
name={`actions.${idx}.type`}
|
||||||
|
label="Type"
|
||||||
|
optionDefaultText="Select type"
|
||||||
|
options={ActionTypeOptions}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextField name={`actions.${idx}.name`} label="Name" columns={6}/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TypeForm action={action} clients={clients} idx={idx}/>
|
||||||
|
|
||||||
|
<div className="pt-6 divide-y divide-gray-200">
|
||||||
|
<div className="mt-4 pt-4 flex justify-between">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex items-center justify-center py-2 border border-transparent font-medium rounded-md text-red-700 dark:text-red-500 hover:text-red-500 dark:hover:text-red-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:text-sm"
|
||||||
|
onClick={toggleDeleteModal}
|
||||||
|
>
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="light:bg-white light:border light:border-gray-300 rounded-md shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-gray-700 dark:text-gray-500 light:hover:bg-gray-50 dark:hover:text-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
||||||
|
onClick={toggleEdit}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,34 +1,23 @@
|
||||||
import React, { Fragment, useRef } from "react";
|
import React, { useRef } from "react";
|
||||||
import { useMutation, useQuery } from "react-query";
|
import { useMutation, useQuery } from "react-query";
|
||||||
import {
|
import { NavLink, Route, Routes, useLocation, useNavigate, useParams } from "react-router-dom";
|
||||||
NavLink,
|
|
||||||
Route,
|
|
||||||
Routes,
|
|
||||||
useLocation,
|
|
||||||
useNavigate,
|
|
||||||
useParams
|
|
||||||
} from "react-router-dom";
|
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Field, FieldArray, FieldProps, Form, Formik, FormikValues, useFormikContext } from "formik";
|
import { Form, Formik, FormikValues, useFormikContext } from "formik";
|
||||||
import { Dialog, Transition, Switch as SwitchBasic } from "@headlessui/react";
|
|
||||||
import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/solid";
|
import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/solid";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CONTAINER_OPTIONS,
|
|
||||||
CODECS_OPTIONS,
|
CODECS_OPTIONS,
|
||||||
RESOLUTION_OPTIONS,
|
CONTAINER_OPTIONS,
|
||||||
SOURCES_OPTIONS,
|
downloadsPerUnitOptions,
|
||||||
ActionTypeNameMap,
|
|
||||||
ActionTypeOptions,
|
|
||||||
HDR_OPTIONS,
|
|
||||||
FORMATS_OPTIONS,
|
FORMATS_OPTIONS,
|
||||||
SOURCES_MUSIC_OPTIONS,
|
HDR_OPTIONS,
|
||||||
|
ORIGIN_OPTIONS,
|
||||||
|
OTHER_OPTIONS,
|
||||||
QUALITY_MUSIC_OPTIONS,
|
QUALITY_MUSIC_OPTIONS,
|
||||||
RELEASE_TYPE_MUSIC_OPTIONS,
|
RELEASE_TYPE_MUSIC_OPTIONS,
|
||||||
OTHER_OPTIONS,
|
RESOLUTION_OPTIONS,
|
||||||
ORIGIN_OPTIONS,
|
SOURCES_MUSIC_OPTIONS,
|
||||||
downloadsPerUnitOptions,
|
SOURCES_OPTIONS
|
||||||
ActionContentLayoutOptions
|
|
||||||
} from "../../domain/constants";
|
} from "../../domain/constants";
|
||||||
import { queryClient } from "../../App";
|
import { queryClient } from "../../App";
|
||||||
import { APIClient } from "../../api/APIClient";
|
import { APIClient } from "../../api/APIClient";
|
||||||
|
@ -36,22 +25,20 @@ import { useToggle } from "../../hooks/hooks";
|
||||||
import { classNames } from "../../utils";
|
import { classNames } from "../../utils";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NumberField,
|
CheckboxField,
|
||||||
TextField,
|
|
||||||
SwitchGroup,
|
|
||||||
Select,
|
|
||||||
MultiSelect,
|
|
||||||
DownloadClientSelect,
|
|
||||||
IndexerMultiSelect,
|
IndexerMultiSelect,
|
||||||
CheckboxField
|
MultiSelect,
|
||||||
|
NumberField,
|
||||||
|
Select,
|
||||||
|
SwitchGroup,
|
||||||
|
TextField
|
||||||
} from "../../components/inputs";
|
} from "../../components/inputs";
|
||||||
import DEBUG from "../../components/debug";
|
import DEBUG from "../../components/debug";
|
||||||
import Toast from "../../components/notifications/Toast";
|
import Toast from "../../components/notifications/Toast";
|
||||||
import { AlertWarning } from "../../components/alerts";
|
|
||||||
import { DeleteModal } from "../../components/modals";
|
import { DeleteModal } from "../../components/modals";
|
||||||
import { TitleSubtitle } from "../../components/headings";
|
import { TitleSubtitle } from "../../components/headings";
|
||||||
import { EmptyListState } from "../../components/emptystates";
|
|
||||||
import { TextArea } from "../../components/inputs/input";
|
import { TextArea } from "../../components/inputs/input";
|
||||||
|
import { FilterActions } from "./action";
|
||||||
|
|
||||||
interface tabType {
|
interface tabType {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -531,7 +518,7 @@ interface CollapsableSectionProps {
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function CollapsableSection({ title, subtitle, children, defaultOpen }: CollapsableSectionProps) {
|
export function CollapsableSection({ title, subtitle, children, defaultOpen }: CollapsableSectionProps) {
|
||||||
const [isOpen, toggleOpen] = useToggle(defaultOpen ?? false);
|
const [isOpen, toggleOpen] = useToggle(defaultOpen ?? false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -628,504 +615,3 @@ export function External() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FilterActionsProps {
|
|
||||||
filter: Filter;
|
|
||||||
values: FormikValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function FilterActions({ filter, values }: FilterActionsProps) {
|
|
||||||
const { data } = useQuery(
|
|
||||||
["filters", "download_clients"],
|
|
||||||
() => APIClient.download_clients.getAll(),
|
|
||||||
{ refetchOnWindowFocus: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
const newAction = {
|
|
||||||
name: "new action",
|
|
||||||
enabled: true,
|
|
||||||
type: "TEST",
|
|
||||||
watch_folder: "",
|
|
||||||
exec_cmd: "",
|
|
||||||
exec_args: "",
|
|
||||||
category: "",
|
|
||||||
tags: "",
|
|
||||||
label: "",
|
|
||||||
save_path: "",
|
|
||||||
paused: false,
|
|
||||||
ignore_rules: false,
|
|
||||||
skip_hash_check: false,
|
|
||||||
content_layout: "",
|
|
||||||
limit_upload_speed: 0,
|
|
||||||
limit_download_speed: 0,
|
|
||||||
limit_ratio: 0,
|
|
||||||
limit_seed_time: 0,
|
|
||||||
reannounce_skip: false,
|
|
||||||
reannounce_delete: false,
|
|
||||||
reannounce_interval: 7,
|
|
||||||
reannounce_max_attempts: 25,
|
|
||||||
filter_id: filter.id,
|
|
||||||
webhook_host: "",
|
|
||||||
webhook_type: "",
|
|
||||||
webhook_method: "",
|
|
||||||
webhook_data: "",
|
|
||||||
webhook_headers: []
|
|
||||||
// client_id: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="mt-10">
|
|
||||||
<FieldArray name="actions">
|
|
||||||
{({ remove, push }) => (
|
|
||||||
<Fragment>
|
|
||||||
<div className="-ml-4 -mt-4 mb-6 flex justify-between items-center flex-wrap sm:flex-nowrap">
|
|
||||||
<div className="ml-4 mt-4">
|
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900 dark:text-gray-200">Actions</h3>
|
|
||||||
<p className="mt-1 text-sm text-gray-500 dark:text-gray-400">
|
|
||||||
Add to download clients or run custom commands.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="ml-4 mt-4 flex-shrink-0">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="relative inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 dark:bg-blue-600 hover:bg-indigo-700 dark:hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-blue-500"
|
|
||||||
onClick={() => push(newAction)}
|
|
||||||
>
|
|
||||||
Add new
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="light:bg-white dark:bg-gray-800 light:shadow sm:rounded-md">
|
|
||||||
{values.actions.length > 0 ?
|
|
||||||
<ul className="divide-y divide-gray-200 dark:divide-gray-700">
|
|
||||||
{values.actions.map((action: Action, index: number) => (
|
|
||||||
<FilterActionsItem action={action} clients={data ?? []} idx={index} remove={remove} key={index} />
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
: <EmptyListState text="No actions yet!" />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</Fragment>
|
|
||||||
)}
|
|
||||||
</FieldArray>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeFormProps {
|
|
||||||
action: Action;
|
|
||||||
idx: number;
|
|
||||||
clients: Array<DownloadClient>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TypeForm = ({ action, idx, clients }: TypeFormProps) => {
|
|
||||||
switch (action.type) {
|
|
||||||
case "TEST":
|
|
||||||
return (
|
|
||||||
<AlertWarning
|
|
||||||
text="The test action does nothing except to show if the filter works."
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
case "EXEC":
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.exec_cmd`}
|
|
||||||
label="Command"
|
|
||||||
columns={6}
|
|
||||||
placeholder="Path to program eg. /bin/test"
|
|
||||||
/>
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.exec_args`}
|
|
||||||
label="Arguments"
|
|
||||||
columns={6}
|
|
||||||
placeholder="Arguments eg. --test"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
case "WATCH_FOLDER":
|
|
||||||
return (
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.watch_folder`}
|
|
||||||
label="Watch folder"
|
|
||||||
columns={6}
|
|
||||||
placeholder="Watch directory eg. /home/user/rwatch"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
case "WEBHOOK":
|
|
||||||
return (
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.webhook_host`}
|
|
||||||
label="Host"
|
|
||||||
columns={6}
|
|
||||||
placeholder="Host eg. http://localhost/webhook"
|
|
||||||
/>
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.webhook_data`}
|
|
||||||
label="Data (json)"
|
|
||||||
columns={6}
|
|
||||||
placeholder={"Request data: { \"key\": \"value\" }"}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
case "QBITTORRENT":
|
|
||||||
return (
|
|
||||||
<div className="w-full">
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<DownloadClientSelect
|
|
||||||
name={`actions.${idx}.client_id`}
|
|
||||||
action={action}
|
|
||||||
clients={clients}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="col-span-6 sm:col-span-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.save_path`}
|
|
||||||
label="Save path"
|
|
||||||
columns={6}
|
|
||||||
placeholder="eg. /full/path/to/watch_folder"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.category`}
|
|
||||||
label="Category"
|
|
||||||
columns={6}
|
|
||||||
placeholder="eg. category"
|
|
||||||
/>
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.tags`}
|
|
||||||
label="Tags"
|
|
||||||
columns={6}
|
|
||||||
placeholder="eg. tag1,tag2"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<CollapsableSection title="Rules" subtitle="client options">
|
|
||||||
<div className="col-span-12">
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.limit_download_speed`}
|
|
||||||
label="Limit download speed (KiB/s)"
|
|
||||||
/>
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.limit_upload_speed`}
|
|
||||||
label="Limit upload speed (KiB/s)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.limit_ratio`}
|
|
||||||
label="Ratio limit"
|
|
||||||
step={0.5}
|
|
||||||
/>
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.limit_seed_time`}
|
|
||||||
label="Seed time limit (seconds)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-6">
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.paused`}
|
|
||||||
label="Add paused"
|
|
||||||
description="Add torrent as paused"
|
|
||||||
/>
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.ignore_rules`}
|
|
||||||
label="Ignore client rules"
|
|
||||||
description="Download if max active reached"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-6">
|
|
||||||
<Select
|
|
||||||
name={`actions.${idx}.content_layout`}
|
|
||||||
label="Content Layout"
|
|
||||||
optionDefaultText="Select content layout"
|
|
||||||
options={ActionContentLayoutOptions}
|
|
||||||
/>
|
|
||||||
<div className="mt-2">
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.skip_hash_check`}
|
|
||||||
label="Skip hash check"
|
|
||||||
description="Add torrent and skip hash check"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CollapsableSection>
|
|
||||||
|
|
||||||
<CollapsableSection title="Advanced" subtitle="Advanced options">
|
|
||||||
<div className="col-span-12">
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.reannounce_interval`}
|
|
||||||
label="Reannounce interval. Run every X seconds"
|
|
||||||
/>
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.reannounce_max_attempts`}
|
|
||||||
label="Run reannounce Y times"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-6">
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.reannounce_skip`}
|
|
||||||
label="Skip reannounce"
|
|
||||||
description="If reannounce is not needed, skip"
|
|
||||||
/>
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.reannounce_delete`}
|
|
||||||
label="Delete stalled"
|
|
||||||
description="Delete stalled torrents after X attempts"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CollapsableSection>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
case "DELUGE_V1":
|
|
||||||
case "DELUGE_V2":
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<DownloadClientSelect
|
|
||||||
name={`actions.${idx}.client_id`}
|
|
||||||
action={action}
|
|
||||||
clients={clients}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="col-span-12 sm:col-span-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.save_path`}
|
|
||||||
label="Save path"
|
|
||||||
columns={6}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 col-span-12 sm:col-span-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.label`}
|
|
||||||
label="Label"
|
|
||||||
columns={6}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.limit_download_speed`}
|
|
||||||
label="Limit download speed (KB/s)"
|
|
||||||
/>
|
|
||||||
<NumberField
|
|
||||||
name={`actions.${idx}.limit_upload_speed`}
|
|
||||||
label="Limit upload speed (KB/s)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<div className="col-span-6">
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.paused`}
|
|
||||||
label="Add paused"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
case "TRANSMISSION":
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<DownloadClientSelect
|
|
||||||
name={`actions.${idx}.client_id`}
|
|
||||||
action={action}
|
|
||||||
clients={clients}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="col-span-12 sm:col-span-6">
|
|
||||||
<TextField
|
|
||||||
name={`actions.${idx}.save_path`}
|
|
||||||
label="Save path"
|
|
||||||
columns={6}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<div className="col-span-6">
|
|
||||||
<SwitchGroup
|
|
||||||
name={`actions.${idx}.paused`}
|
|
||||||
label="Add paused"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
case "RADARR":
|
|
||||||
case "SONARR":
|
|
||||||
case "LIDARR":
|
|
||||||
case "WHISPARR":
|
|
||||||
return (
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<DownloadClientSelect
|
|
||||||
name={`actions.${idx}.client_id`}
|
|
||||||
action={action}
|
|
||||||
clients={clients}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
interface FilterActionsItemProps {
|
|
||||||
action: Action;
|
|
||||||
clients: DownloadClient[];
|
|
||||||
idx: number;
|
|
||||||
remove: <T>(index: number) => T | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function FilterActionsItem({ action, clients, idx, remove }: FilterActionsItemProps) {
|
|
||||||
const cancelButtonRef = useRef(null);
|
|
||||||
|
|
||||||
const [deleteModalIsOpen, toggleDeleteModal] = useToggle(false);
|
|
||||||
const [edit, toggleEdit] = useToggle(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<li>
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
idx % 2 === 0 ? "bg-white dark:bg-gray-800" : "bg-gray-50 dark:bg-gray-700",
|
|
||||||
"flex items-center sm:px-6 hover:bg-gray-50 dark:hover:bg-gray-600"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Field name={`actions.${idx}.enabled`} type="checkbox">
|
|
||||||
{({
|
|
||||||
field,
|
|
||||||
form: { setFieldValue }
|
|
||||||
}: FieldProps) => (
|
|
||||||
<SwitchBasic
|
|
||||||
{...field}
|
|
||||||
type="button"
|
|
||||||
value={field.value}
|
|
||||||
checked={field.checked ?? false}
|
|
||||||
onChange={(value: boolean) => {
|
|
||||||
setFieldValue(field?.name ?? "", value);
|
|
||||||
}}
|
|
||||||
className={classNames(
|
|
||||||
field.value ? "bg-teal-500 dark:bg-blue-500" : "bg-gray-200 dark:bg-gray-600",
|
|
||||||
"relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="sr-only">toggle enabled</span>
|
|
||||||
<span
|
|
||||||
aria-hidden="true"
|
|
||||||
className={classNames(
|
|
||||||
field.value ? "translate-x-5" : "translate-x-0",
|
|
||||||
"inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</SwitchBasic>
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
|
|
||||||
<button className="px-4 py-4 w-full flex" type="button" onClick={toggleEdit}>
|
|
||||||
<div className="min-w-0 flex-1 sm:flex sm:items-center sm:justify-between">
|
|
||||||
<div className="truncate">
|
|
||||||
<div className="flex text-sm">
|
|
||||||
<p className="ml-4 font-medium text-indigo-600 dark:text-gray-100 truncate">
|
|
||||||
{action.name}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-4 flex-shrink-0 sm:mt-0 sm:ml-5">
|
|
||||||
<div className="flex overflow-hidden -space-x-1">
|
|
||||||
<span className="text-sm font-normal text-gray-500 dark:text-gray-400">
|
|
||||||
{ActionTypeNameMap[action.type]}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="ml-5 flex-shrink-0">
|
|
||||||
<ChevronRightIcon
|
|
||||||
className="h-5 w-5 text-gray-400"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{edit && (
|
|
||||||
<div className="px-4 py-4 flex items-center sm:px-6 border dark:border-gray-600">
|
|
||||||
<Transition.Root show={deleteModalIsOpen} as={Fragment}>
|
|
||||||
<Dialog
|
|
||||||
as="div"
|
|
||||||
static
|
|
||||||
className="fixed inset-0 overflow-y-auto"
|
|
||||||
initialFocus={cancelButtonRef}
|
|
||||||
open={deleteModalIsOpen}
|
|
||||||
onClose={toggleDeleteModal}
|
|
||||||
>
|
|
||||||
<DeleteModal
|
|
||||||
isOpen={deleteModalIsOpen}
|
|
||||||
buttonRef={cancelButtonRef}
|
|
||||||
toggle={toggleDeleteModal}
|
|
||||||
deleteAction={() => remove(idx)}
|
|
||||||
title="Remove filter action"
|
|
||||||
text="Are you sure you want to remove this action? This action cannot be undone."
|
|
||||||
/>
|
|
||||||
</Dialog>
|
|
||||||
</Transition.Root>
|
|
||||||
|
|
||||||
<div className="w-full">
|
|
||||||
|
|
||||||
<div className="mt-6 grid grid-cols-12 gap-6">
|
|
||||||
<Select
|
|
||||||
name={`actions.${idx}.type`}
|
|
||||||
label="Type"
|
|
||||||
optionDefaultText="Select type"
|
|
||||||
options={ActionTypeOptions}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextField name={`actions.${idx}.name`} label="Name" columns={6} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<TypeForm action={action} clients={clients} idx={idx} />
|
|
||||||
|
|
||||||
<div className="pt-6 divide-y divide-gray-200">
|
|
||||||
<div className="mt-4 pt-4 flex justify-between">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="inline-flex items-center justify-center py-2 border border-transparent font-medium rounded-md text-red-700 dark:text-red-500 hover:text-red-500 dark:hover:text-red-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:text-sm"
|
|
||||||
onClick={toggleDeleteModal}
|
|
||||||
>
|
|
||||||
Remove
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="light:bg-white light:border light:border-gray-300 rounded-md shadow-sm py-2 px-4 inline-flex justify-center text-sm font-medium text-gray-700 dark:text-gray-500 light:hover:bg-gray-50 dark:hover:text-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
||||||
onClick={toggleEdit}
|
|
||||||
>
|
|
||||||
Close
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
1
web/src/types/Download.d.ts
vendored
1
web/src/types/Download.d.ts
vendored
|
@ -2,6 +2,7 @@ type DownloadClientType =
|
||||||
"QBITTORRENT" |
|
"QBITTORRENT" |
|
||||||
"DELUGE_V1" |
|
"DELUGE_V1" |
|
||||||
"DELUGE_V2" |
|
"DELUGE_V2" |
|
||||||
|
"RTORRENT" |
|
||||||
"TRANSMISSION" |
|
"TRANSMISSION" |
|
||||||
"RADARR" |
|
"RADARR" |
|
||||||
"SONARR" |
|
"SONARR" |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue