mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-01 21:13:39 +01:00
add traefik service widget
This commit is contained in:
parent
82b0ef38fd
commit
2de82795c7
@ -10,7 +10,7 @@
|
|||||||
- Status light + CPU, Memory & Network Reporting *(click on the status light)*
|
- Status light + CPU, Memory & Network Reporting *(click on the status light)*
|
||||||
- Service Integration
|
- Service Integration
|
||||||
- Currently supports Sonarr, Radarr, Ombi, Emby, Jellyfin, NZBGet, ruTorrent
|
- Currently supports Sonarr, Radarr, Ombi, Emby, Jellyfin, NZBGet, ruTorrent
|
||||||
- Portainer, Speedtest Tracker, PiHole
|
- Portainer, Traefik, Speedtest Tracker, PiHole
|
||||||
* Homepage Widgets
|
* Homepage Widgets
|
||||||
- System Stats (Disk, CPU, Memory)
|
- System Stats (Disk, CPU, Memory)
|
||||||
- Weather (via weatherapi.com)
|
- Weather (via weatherapi.com)
|
||||||
|
@ -9,6 +9,7 @@ import Pihole from "./widgets/service/pihole";
|
|||||||
import Rutorrent from "./widgets/service/rutorrent";
|
import Rutorrent from "./widgets/service/rutorrent";
|
||||||
import Jellyfin from "./widgets/service/jellyfin";
|
import Jellyfin from "./widgets/service/jellyfin";
|
||||||
import Speedtest from "./widgets/service/speedtest";
|
import Speedtest from "./widgets/service/speedtest";
|
||||||
|
import Traefik from "./widgets/service/traefik";
|
||||||
|
|
||||||
const widgetMappings = {
|
const widgetMappings = {
|
||||||
docker: Docker,
|
docker: Docker,
|
||||||
@ -22,6 +23,7 @@ const widgetMappings = {
|
|||||||
pihole: Pihole,
|
pihole: Pihole,
|
||||||
rutorrent: Rutorrent,
|
rutorrent: Rutorrent,
|
||||||
speedtest: Speedtest,
|
speedtest: Speedtest,
|
||||||
|
traefik: Traefik,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Widget({ service }) {
|
export default function Widget({ service }) {
|
||||||
|
38
src/components/services/widgets/service/traefik.jsx
Normal file
38
src/components/services/widgets/service/traefik.jsx
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import useSWR from "swr";
|
||||||
|
|
||||||
|
import Widget from "../widget";
|
||||||
|
import Block from "../block";
|
||||||
|
|
||||||
|
export default function Traefik({ service }) {
|
||||||
|
const config = service.widget;
|
||||||
|
|
||||||
|
function buildApiUrl(endpoint) {
|
||||||
|
const { url } = config;
|
||||||
|
const fullUrl = `${url}/api/${endpoint}`;
|
||||||
|
return `/api/proxy?url=${encodeURIComponent(fullUrl)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: traefikData, error: traefikError } = useSWR(buildApiUrl("overview"));
|
||||||
|
|
||||||
|
if (traefikError) {
|
||||||
|
return <Widget error="Traefik API Error" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!traefikData) {
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Block label="Routers" />
|
||||||
|
<Block label="Services" />
|
||||||
|
<Block label="Middleware" />
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Widget>
|
||||||
|
<Block label="Routers" value={traefikData.http.routers.total} />
|
||||||
|
<Block label="Services" value={traefikData.http.services.total} />
|
||||||
|
<Block label="Middleware" value={traefikData.http.middlewares.total} />
|
||||||
|
</Widget>
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user