Poor mans desktop (UI) widgets for ratelimits

This commit is contained in:
Igor Katson 2024-11-20 16:12:37 +00:00
parent 06b50d65ab
commit 69a638fb81
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 37 additions and 0 deletions

View file

@ -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 {

View file

@ -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."
/>
<FormInput
label="Download rate limit"
name="ratelimits.download_bps"
inputType="number"
value={config.ratelimits.download_bps ?? ""}
onChange={handleInputChange}
help={`Limit total download speed to this number of bytes per second (${
(config.ratelimits.download_bps ?? 0) > 0
? "current " +
formatBytes(config.ratelimits.download_bps ?? 0) +
" per second"
: "currently disabled"
})`}
/>
<FormInput
label="Upload rate limit"
name="ratelimits.upload_bps"
inputType="number"
value={config.ratelimits.upload_bps ?? ""}
onChange={handleInputChange}
help={`Limit total upload speed to this number of bytes per second (${
(config.ratelimits.upload_bps ?? 0) > 0
? "current " +
formatBytes(config.ratelimits.upload_bps ?? 0) +
" per second"
: "currently disabled"
})`}
/>
</Fieldset>
</Tab>