From 984653425f532a21e6588c8a087b88eec675ac04 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Sat, 28 Sep 2024 23:14:37 +0800 Subject: [PATCH] feat: add Transmission settings to Other settings page --- src/lang/en/settings_other.json | 4 ++- src/pages/manage/settings/Other.tsx | 40 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/lang/en/settings_other.json b/src/lang/en/settings_other.json index 46f45a778..c1fd77447 100644 --- a/src/lang/en/settings_other.json +++ b/src/lang/en/settings_other.json @@ -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" } diff --git a/src/pages/manage/settings/Other.tsx b/src/pages/manage/settings/Other.tsx index a29e5047a..5ddae0bf7 100644 --- a/src/pages/manage/settings/Other.tsx +++ b/src/pages/manage/settings/Other.tsx @@ -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([]) const [settingsLoading, settingsData] = useFetch( @@ -30,6 +32,13 @@ const OtherSettings = () => { seedtime: qbitSeedTime(), }), ) + const [setTransmissionLoading, setTransmission] = useFetch( + (): PResp => + r.post("/admin/setting/set_transmission", { + uri: transmissionUrl(), + seedtime: transmissionSeedTime(), + }), + ) const refresh = async () => { const resp = await settingsData() handleResp(resp, (data) => { @@ -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) }) } @@ -101,6 +116,31 @@ const OtherSettings = () => { > {t("settings_other.set_qbit")} + {t("settings_other.transmission")} + + i.key === "transmission_uri")!} + value={transmissionUrl()} + onChange={(str) => setTransmissionUrl(str)} + /> + i.key === "transmission_seedtime")!} + value={transmissionSeedTime()} + onChange={(str) => setTransmissionSeedTime(str)} + /> + + {t("settings.token")}