Skip to content

Commit

Permalink
feat: add Transmission settings to Other settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 28, 2024
1 parent 78aa73e commit 9846534
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lang/en/settings_other.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
"reset_token_success": "Reset Token Successfully",
"unknown_type": "Unknown type",
"set_qbit": "Set qBittorrent",
"qbittorrent": "qBittorrent"
"qbittorrent": "qBittorrent",
"transmission": "Transmission",
"set_transmission": "Set Transmission"
}
40 changes: 40 additions & 0 deletions src/pages/manage/settings/Other.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const OtherSettings = () => {
const [secret, setSecret] = createSignal("")
const [qbitUrl, setQbitUrl] = createSignal("")
const [qbitSeedTime, setQbitSeedTime] = createSignal("")
const [transmissionUrl, setTransmissionUrl] = createSignal("")
const [transmissionSeedTime, setTransmissionSeedTime] = createSignal("")
const [token, setToken] = createSignal("")
const [settings, setSettings] = createSignal<SettingItem[]>([])
const [settingsLoading, settingsData] = useFetch(
Expand All @@ -30,6 +32,13 @@ const OtherSettings = () => {
seedtime: qbitSeedTime(),
}),
)
const [setTransmissionLoading, setTransmission] = useFetch(
(): PResp<string> =>
r.post("/admin/setting/set_transmission", {
uri: transmissionUrl(),
seedtime: transmissionSeedTime(),
}),
)
const refresh = async () => {
const resp = await settingsData()
handleResp(resp, (data) => {
Expand All @@ -40,6 +49,12 @@ const OtherSettings = () => {
setQbitSeedTime(
data.find((i) => i.key === "qbittorrent_seedtime")?.value || "",
)
setTransmissionUrl(
data.find((i) => i.key === "transmission_uri")?.value || "",
)
setTransmissionSeedTime(
data.find((i) => i.key === "transmission_seedtime")?.value || "",
)
setSettings(data)
})
}
Expand Down Expand Up @@ -101,6 +116,31 @@ const OtherSettings = () => {
>
{t("settings_other.set_qbit")}
</Button>
<Heading my="$2">{t("settings_other.transmission")}</Heading>
<SimpleGrid gap="$2" columns={{ "@initial": 1, "@md": 2 }}>
<Item
{...settings().find((i) => i.key === "transmission_uri")!}
value={transmissionUrl()}
onChange={(str) => setTransmissionUrl(str)}
/>
<Item
{...settings().find((i) => i.key === "transmission_seedtime")!}
value={transmissionSeedTime()}
onChange={(str) => setTransmissionSeedTime(str)}
/>
</SimpleGrid>
<Button
my="$2"
loading={setTransmissionLoading()}
onClick={async () => {
const resp = await setTransmission()
handleResp(resp, (data) => {
notify.success(data)
})
}}
>
{t("settings_other.set_transmission")}
</Button>
<Heading my="$2">{t("settings.token")}</Heading>
<Input value={token()} readOnly />
<HStack my="$2" spacing="$2">
Expand Down

0 comments on commit 9846534

Please sign in to comment.