Enhancement: add bitrate precision config option for speedtest-tracker (#3354)

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
pull/3358/head
Ameer Abdallah 7 months ago committed by GitHub
parent 312e97d18b
commit 340424391f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -16,4 +16,5 @@ Allowed fields: `["download", "upload", "ping"]`.
widget:
type: speedtest
url: http://speedtest.host.or.ip
bitratePrecision: 3 # optional, default is 0
```

@ -450,6 +450,9 @@ export function cleanServiceGroups(groups) {
// proxmox
node,
// speedtest
bitratePrecision,
// sonarr, radarr
enableQueue,
@ -588,6 +591,11 @@ export function cleanServiceGroups(groups) {
if (type === "healthchecks") {
if (uuid !== undefined) cleanedService.widget.uuid = uuid;
}
if (type === "speedtest") {
if (bitratePrecision !== undefined) {
cleanedService.widget.bitratePrecision = parseInt(bitratePrecision, 10);
}
}
}
return cleanedService;

@ -11,6 +11,11 @@ export default function Component({ service }) {
const { data: speedtestData, error: speedtestError } = useWidgetAPI(widget, "speedtest/latest");
const bitratePrecision =
!widget?.bitratePrecision || Number.isNaN(widget?.bitratePrecision) || widget?.bitratePrecision < 0
? 0
: widget.bitratePrecision;
if (speedtestError) {
return <Container service={service} error={speedtestError} />;
}
@ -29,9 +34,18 @@ export default function Component({ service }) {
<Container service={service}>
<Block
label="speedtest.download"
value={t("common.bitrate", { value: speedtestData.data.download * 1000 * 1000 })}
value={t("common.bitrate", {
value: speedtestData.data.download * 1000 * 1000,
decimals: bitratePrecision,
})}
/>
<Block
label="speedtest.upload"
value={t("common.bitrate", {
value: speedtestData.data.upload * 1000 * 1000,
decimals: bitratePrecision,
})}
/>
<Block label="speedtest.upload" value={t("common.bitrate", { value: speedtestData.data.upload * 1000 * 1000 })} />
<Block
label="speedtest.ping"
value={t("common.ms", {

Loading…
Cancel
Save