From 69a638fb8196e0cb75694345be57587acaaaded4 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Wed, 20 Nov 2024 16:12:37 +0000 Subject: [PATCH] Poor mans desktop (UI) widgets for ratelimits --- desktop/src/configuration.tsx | 6 ++++++ desktop/src/configure.tsx | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/desktop/src/configuration.tsx b/desktop/src/configuration.tsx index 013680b..bea5c76 100644 --- a/desktop/src/configuration.tsx +++ b/desktop/src/configuration.tsx @@ -39,6 +39,11 @@ interface RqbitDesktopConfigUpnp { server_friendly_name: string; } +export interface LimitsConfig { + upload_bps?: number | null; + download_bps?: number | null; +} + export interface RqbitDesktopConfig { default_download_location: PathLike; disable_upload?: boolean; @@ -48,6 +53,7 @@ export interface RqbitDesktopConfig { persistence: RqbitDesktopConfigPersistence; peer_opts: RqbitDesktopConfigPeerOpts; http_api: RqbitDesktopConfigHttpApi; + ratelimits: LimitsConfig; } export interface CurrentDesktopState { diff --git a/desktop/src/configure.tsx b/desktop/src/configure.tsx index 65e715d..0f6f4c4 100644 --- a/desktop/src/configure.tsx +++ b/desktop/src/configure.tsx @@ -10,6 +10,7 @@ import { Modal } from "rqbit-webui/src/components/modal/Modal"; import { Fieldset } from "rqbit-webui/src/components/forms/Fieldset"; import { ModalFooter } from "rqbit-webui/src/components/modal/ModalFooter"; import { Button } from "rqbit-webui/src/components/buttons/Button"; +import { formatBytes } from "rqbit-webui/src/helper/formatBytes"; const FormCheck: React.FC<{ label: string; @@ -344,6 +345,36 @@ Might be useful e.g. if rqbit upload consumes all your upload bandwidth and inte onChange={handleToggleChange} help="If enabled, restarting will not rehash torrents, and thus will be faster. You should not modify the downloaded files in any way if you use that." /> + + 0 + ? "current " + + formatBytes(config.ratelimits.download_bps ?? 0) + + " per second" + : "currently disabled" + })`} + /> + + 0 + ? "current " + + formatBytes(config.ratelimits.upload_bps ?? 0) + + " per second" + : "currently disabled" + })`} + />