Feature: DeveLanCacheUI service widget (#3854)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>pull/3876/head
parent
ca1577166d
commit
0d25f5789b
@ -0,0 +1,14 @@
|
||||
---
|
||||
title: DeveLanCacheUI
|
||||
description: DeveLanCacheUI Widget Configuration
|
||||
---
|
||||
|
||||
Learn more about [DeveLanCacheUI](https://github.com/devedse/DeveLanCacheUI_Backend).
|
||||
|
||||
```yaml
|
||||
widget:
|
||||
type: develancacheui
|
||||
url: http://your.develancacheui_backend.host:port
|
||||
```
|
||||
|
||||
The url should point to the DeveLanCacheUI Backend (API)
|
@ -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, "stats");
|
||||
|
||||
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.bytes", { value: downloadStatsData.totalCacheHitBytes })}
|
||||
/>
|
||||
<Block
|
||||
label="develancacheui.cachemissbytes"
|
||||
value={t("common.bytes", { value: downloadStatsData.totalCacheMissBytes })}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
stats: {
|
||||
endpoint: "DownloadStats/GetTotalDownloadStats",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
Loading…
Reference in new issue