diff --git a/public/locales/en/common.json b/public/locales/en/common.json index d3eb43cc8..9dd10d047 100755 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -587,5 +587,9 @@ "people_home": "People Home", "lights_on": "Lights On", "switches_on": "Switches On" + }, + "whatsupdocker": { + "monitoring": "Monitoring", + "updates": "Updates" } } diff --git a/src/widgets/components.js b/src/widgets/components.js index 673383322..f8828f3bd 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -81,6 +81,7 @@ const components = { unmanic: dynamic(() => import("./unmanic/component")), uptimekuma: dynamic(() => import("./uptimekuma/component")), watchtower: dynamic(() => import("./watchtower/component")), + whatsupdocker: dynamic(() => import("./whatsupdocker/component")), xteve: dynamic(() => import("./xteve/component")), }; diff --git a/src/widgets/whatsupdocker/component.jsx b/src/widgets/whatsupdocker/component.jsx new file mode 100644 index 000000000..26b38dee6 --- /dev/null +++ b/src/widgets/whatsupdocker/component.jsx @@ -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 ; + } + + if (!containersData) { + return ( + + + + + ); + } + + const totalCount = containersData.length; + const updatesAvailable = containersData.filter(container => container.updateAvailable).length; + + return ( + + + + + ); +} diff --git a/src/widgets/whatsupdocker/widget.js b/src/widgets/whatsupdocker/widget.js new file mode 100644 index 000000000..6c2423a05 --- /dev/null +++ b/src/widgets/whatsupdocker/widget.js @@ -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; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index 9878d50dd..9e1553831 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -75,6 +75,7 @@ import unifi from "./unifi/widget"; import unmanic from "./unmanic/widget"; import uptimekuma from "./uptimekuma/widget"; import watchtower from "./watchtower/widget"; +import whatsupdocker from "./whatsupdocker/widget"; import xteve from "./xteve/widget"; const widgets = { @@ -157,6 +158,7 @@ const widgets = { unmanic, uptimekuma, watchtower, + whatsupdocker, xteve, };