mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
Add Whats Up Docker widget (#1150)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
dc3019da80
commit
f4f58409a2
5 changed files with 53 additions and 0 deletions
32
src/widgets/whatsupdocker/component.jsx
Normal file
32
src/widgets/whatsupdocker/component.jsx
Normal 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>
|
||||
);
|
||||
}
|
14
src/widgets/whatsupdocker/widget.js
Normal file
14
src/widgets/whatsupdocker/widget.js
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue