mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-14 21:22:08 +08:00
Working Jdownloader
This commit is contained in:
37
src/widgets/jdownloader/component.jsx
Normal file
37
src/widgets/jdownloader/component.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: jdownloaderData, error: jdownloaderAPIError } = useWidgetAPI(widget, "unified", {
|
||||
refreshInterval: 30000,
|
||||
});
|
||||
|
||||
if (jdownloaderAPIError) {
|
||||
return <Container service={service} error={jdownloaderAPIError} />;
|
||||
}
|
||||
|
||||
if (!jdownloaderData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="jdownloader.downloadCount" />
|
||||
<Block label="jdownloader.downloadQueueSize" />
|
||||
<Block label="jdownloader.downloadSpeed" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="jdownloader.downloadCount" value={t("common.number", { value: jdownloaderData.downloadCount })} />
|
||||
<Block label="jdownloader.downloadQueueSize" value={t("common.bytes", { value: jdownloaderData.totalBytes })} />
|
||||
<Block label="jdownloader.downloadSpeed" value={t("common.byterate", { value: jdownloaderData.totalSpeed })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user