Add Whats Up Docker widget

This commit is contained in:
RichyHBM 2023-03-27 18:06:11 +00:00
parent 924ba2f2cf
commit 70331a53fc
5 changed files with 53 additions and 0 deletions

View File

@ -540,5 +540,9 @@
"gross_percent_today": "Today", "gross_percent_today": "Today",
"gross_percent_1y": "One year", "gross_percent_1y": "One year",
"gross_percent_max": "All time" "gross_percent_max": "All time"
},
"whatsupdocker": {
"monitoring": "Monitoring",
"updates": "Updates"
} }
} }

View File

@ -77,6 +77,7 @@ const components = {
unmanic: dynamic(() => import("./unmanic/component")), unmanic: dynamic(() => import("./unmanic/component")),
uptimekuma: dynamic(() => import("./uptimekuma/component")), uptimekuma: dynamic(() => import("./uptimekuma/component")),
watchtower: dynamic(() => import("./watchtower/component")), watchtower: dynamic(() => import("./watchtower/component")),
whatsupdocker: dynamic(() => import("./whatsupdocker/component")),
xteve: dynamic(() => import("./xteve/component")), xteve: dynamic(() => import("./xteve/component")),
}; };

View File

@ -0,0 +1,32 @@
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 { widget } = service;
const { data: containersData, error: containersError } = useWidgetAPI(widget, "containers");
if (containersError) {
return <Container error={containersError} />;
}
if (!containersData) {
return (
<Container service={service}>
<Block label="whatsupdocker.monitoring" />
<Block label="whatsupdocker.updates" />
</Container>
);
}
const totalCount = containersData.length;
const updatesAvailable = containersData.filter(container => container.updateAvailable).length;
return (
<Container service={service}>
<Block label="whatsupdocker.monitoring" value={totalCount} />
<Block label="whatsupdocker.updates" value={updatesAvailable} />
</Container>
);
}

View File

@ -0,0 +1,14 @@
import genericProxyHandler from "utils/proxy/handlers/generic";
const widget = {
api: "{url}/{endpoint}",
proxyHandler: genericProxyHandler,
mappings: {
containers: {
endpoint: "api/containers"
},
},
};
export default widget;

View File

@ -71,6 +71,7 @@ import unifi from "./unifi/widget";
import unmanic from "./unmanic/widget"; import unmanic from "./unmanic/widget";
import uptimekuma from "./uptimekuma/widget"; import uptimekuma from "./uptimekuma/widget";
import watchtower from "./watchtower/widget"; import watchtower from "./watchtower/widget";
import whatsupdocker from "./whatsupdocker/widget";
import xteve from "./xteve/widget"; import xteve from "./xteve/widget";
const widgets = { const widgets = {
@ -149,6 +150,7 @@ const widgets = {
unmanic, unmanic,
uptimekuma, uptimekuma,
watchtower, watchtower,
whatsupdocker,
xteve, xteve,
}; };