mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Feature: DeveLanCacheUI service widget (#3854)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
ca1577166d
commit
0d25f5789b
14
docs/widgets/services/develancacheui.md
Normal file
14
docs/widgets/services/develancacheui.md
Normal file
@ -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)
|
@ -22,6 +22,7 @@ You can also find a list of all available service widgets in the sidebar navigat
|
||||
- [CrowdSec](crowdsec.md)
|
||||
- [Custom API](customapi.md)
|
||||
- [Deluge](deluge.md)
|
||||
- [DeveLanCacheUI](develancacheui.md)
|
||||
- [DiskStation](diskstation.md)
|
||||
- [DownloadStation](downloadstation.md)
|
||||
- [Emby](emby.md)
|
||||
|
@ -226,6 +226,10 @@
|
||||
"leech": "Leech",
|
||||
"seed": "Seed"
|
||||
},
|
||||
"develancacheui": {
|
||||
"cachehitbytes": "Cache Hit Bytes",
|
||||
"cachemissbytes": "Cache Miss Bytes"
|
||||
},
|
||||
"downloadstation": {
|
||||
"download": "Download",
|
||||
"upload": "Upload",
|
||||
|
@ -19,6 +19,7 @@ const components = {
|
||||
iframe: dynamic(() => import("./iframe/component")),
|
||||
customapi: dynamic(() => import("./customapi/component")),
|
||||
deluge: dynamic(() => import("./deluge/component")),
|
||||
develancacheui: dynamic(() => import("./develancacheui/component")),
|
||||
diskstation: dynamic(() => import("./diskstation/component")),
|
||||
downloadstation: dynamic(() => import("./downloadstation/component")),
|
||||
docker: dynamic(() => import("./docker/component")),
|
||||
|
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, "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>
|
||||
);
|
||||
}
|
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: {
|
||||
stats: {
|
||||
endpoint: "DownloadStats/GetTotalDownloadStats",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
@ -15,6 +15,7 @@ import coinmarketcap from "./coinmarketcap/widget";
|
||||
import crowdsec from "./crowdsec/widget";
|
||||
import customapi from "./customapi/widget";
|
||||
import deluge from "./deluge/widget";
|
||||
import develancacheui from "./develancacheui/widget";
|
||||
import diskstation from "./diskstation/widget";
|
||||
import downloadstation from "./downloadstation/widget";
|
||||
import emby from "./emby/widget";
|
||||
@ -135,6 +136,7 @@ const widgets = {
|
||||
crowdsec,
|
||||
customapi,
|
||||
deluge,
|
||||
develancacheui,
|
||||
diskstation,
|
||||
downloadstation,
|
||||
emby,
|
||||
|
Loading…
x
Reference in New Issue
Block a user