mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
added tdarr widget
This commit is contained in:
parent
e7b0fc1419
commit
aaa1f76176
6 changed files with 120 additions and 0 deletions
45
src/widgets/tdarr/component.jsx
Normal file
45
src/widgets/tdarr/component.jsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: tdarrData, error: tdarrError } = useWidgetAPI(widget);
|
||||
|
||||
if (tdarrError) {
|
||||
return <Container error={tdarrError} />;
|
||||
}
|
||||
|
||||
if (!tdarrData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="tdarr.queue" />
|
||||
<Block label="tdarr.processed" />
|
||||
<Block label="tdarr.errored" />
|
||||
<Block label="tdarr.saved" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
// const { torrents } = tdarrData.arguments;
|
||||
|
||||
const queue = parseInt(tdarrData.table1Count) + parseInt(tdarrData.table4Count);
|
||||
const processed = parseInt(tdarrData.table2Count) + parseInt(tdarrData.table5Count);
|
||||
const errored = parseInt(tdarrData.table3Count) + parseInt(tdarrData.table6Count);
|
||||
|
||||
const saved = parseFloat(tdarrData.sizeDiff) * 1000000000;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="tdarr.queue" value={t("common.number", { value: queue })} />
|
||||
<Block label="tdarr.processed" value={t("common.number", { value: processed })} />
|
||||
<Block label="tdarr.errored" value={t("common.number", { value: errored })} />
|
||||
<Block label="tdarr.saved" value={t("common.bytes", { value: saved })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue