You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
966 B
38 lines
966 B
2 years ago
|
import useSWR from "swr";
|
||
|
import { useTranslation } from "react-i18next";
|
||
|
|
||
|
import Widget from "../widget";
|
||
|
import Block from "../block";
|
||
|
|
||
|
import { formatApiUrl } from "utils/api-helpers";
|
||
|
|
||
|
export default function SABnzbd({ service }) {
|
||
|
const { t } = useTranslation();
|
||
|
|
||
|
const config = service.widget;
|
||
|
|
||
|
const { data: queueData, error: queueError } = useSWR(formatApiUrl(config, "queue"));
|
||
|
|
||
|
if (queueError) {
|
||
|
return <Widget error={t("widget.api_error")} />;
|
||
|
}
|
||
|
|
||
|
if (!queueData) {
|
||
|
return (
|
||
|
<Widget>
|
||
|
<Block label={t("sabnzbd.rate")} />
|
||
|
<Block label={t("sabnzbd.queue")} />
|
||
|
<Block label={t("sabnzbd.timeleft")} />
|
||
|
</Widget>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<Widget>
|
||
|
<Block label={t("sabnzbd.rate")} value={`${queueData.queue.speed}bps`} />
|
||
|
<Block label={t("sabnzbd.queue")} value={queueData.queue.noofslots} />
|
||
|
<Block label={t("sabnzbd.timeleft")} value={queueData.queue.timeleft} />
|
||
|
</Widget>
|
||
|
);
|
||
|
}
|