mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Added component
This commit is contained in:
39
src/widgets/develancacheui/component.jsx
Normal file
39
src/widgets/develancacheui/component.jsx
Normal file
@@ -0,0 +1,39 @@
|
||||
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: downloadStatsData, error: downloadStatsError } = useWidgetAPI(widget, "DownloadStats/GetTotalDownloadStats");
|
||||
|
||||
if (downloadStatsError) {
|
||||
return <Container service={service} error={downloadStatsError} />;
|
||||
}
|
||||
|
||||
if (!downloadStatsData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="develancacheui.cachehitbytes" />
|
||||
<Block label="develancacheui.cachemissbytes" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block
|
||||
label="develancacheui.cachehitbytes"
|
||||
value={t("common.number", { value: downloadStatsData.totalCacheHitBytes })}
|
||||
/>
|
||||
<Block
|
||||
label="develancacheui.cachemissbytes"
|
||||
value={t("common.number", { value: downloadStatsData.totalCacheMissBytes })}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
14
src/widgets/develancacheui/widget.js
Normal file
14
src/widgets/develancacheui/widget.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
"DownloadStats/GetTotalDownloadStats": {
|
||||
endpoint: "DownloadStats/GetTotalDownloadStats",
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
||||
Reference in New Issue
Block a user