mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-14 00:40:30 +00:00
bring all transfer rates inline, using bitrate
This commit is contained in:
parent
d36efa5796
commit
68c93c65e6
2 changed files with 16 additions and 30 deletions
|
@ -4,6 +4,16 @@ import Container from "components/services/widget/container";
|
|||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
function fromUnits(value) {
|
||||
const units = ["B", "K", "M", "G", "T", "P"];
|
||||
const [number, unit] = value.split(" ");
|
||||
const index = units.indexOf(unit);
|
||||
if (index === -1) {
|
||||
return 0;
|
||||
}
|
||||
return parseFloat(number) * 1024 ** index;
|
||||
}
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
@ -27,7 +37,7 @@ export default function Component({ service }) {
|
|||
|
||||
return (
|
||||
<Container>
|
||||
<Block label={t("sabnzbd.rate")} value={`${queueData.queue.speed}B/s`} />
|
||||
<Block label={t("sabnzbd.rate")} value={t("common.bitrate", { value: fromUnits(queueData.queue.speed) * 8 })} />
|
||||
<Block label={t("sabnzbd.queue")} value={t("common.number", { value: queueData.queue.noofslots })} />
|
||||
<Block label={t("sabnzbd.timeleft")} value={queueData.queue.timeleft} />
|
||||
</Container>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue