mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-02 13:33:40 +01:00
commit
893c443f21
@ -354,6 +354,16 @@
|
|||||||
"child_bridges": "Child Bridges",
|
"child_bridges": "Child Bridges",
|
||||||
"child_bridges_status": "{{ok}}/{{total}}"
|
"child_bridges_status": "{{ok}}/{{total}}"
|
||||||
},
|
},
|
||||||
|
"healthchecks": {
|
||||||
|
"new": "New",
|
||||||
|
"up": "Online",
|
||||||
|
"grace": "In Grace Period",
|
||||||
|
"down": "Offline",
|
||||||
|
"paused": "Paused",
|
||||||
|
"status": "Status",
|
||||||
|
"last_ping": "Last Ping",
|
||||||
|
"never": "No pings yet"
|
||||||
|
},
|
||||||
"watchtower": {
|
"watchtower": {
|
||||||
"containers_scanned": "Scanned",
|
"containers_scanned": "Scanned",
|
||||||
"containers_updated": "Updated",
|
"containers_updated": "Updated",
|
||||||
|
@ -21,6 +21,7 @@ const components = {
|
|||||||
grafana: dynamic(() => import("./grafana/component")),
|
grafana: dynamic(() => import("./grafana/component")),
|
||||||
hdhomerun: dynamic(() => import("./hdhomerun/component")),
|
hdhomerun: dynamic(() => import("./hdhomerun/component")),
|
||||||
homebridge: dynamic(() => import("./homebridge/component")),
|
homebridge: dynamic(() => import("./homebridge/component")),
|
||||||
|
healthchecks: dynamic(() => import("./healthchecks/component")),
|
||||||
jackett: dynamic(() => import("./jackett/component")),
|
jackett: dynamic(() => import("./jackett/component")),
|
||||||
jellyfin: dynamic(() => import("./emby/component")),
|
jellyfin: dynamic(() => import("./emby/component")),
|
||||||
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
jellyseerr: dynamic(() => import("./jellyseerr/component")),
|
||||||
|
54
src/widgets/healthchecks/component.jsx
Normal file
54
src/widgets/healthchecks/component.jsx
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
|
import { i18n } from "../../../next-i18next.config";
|
||||||
|
|
||||||
|
import Block from "components/services/widget/block";
|
||||||
|
import Container from "components/services/widget/container";
|
||||||
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
|
function formatDate(dateString) {
|
||||||
|
const date = new Date(dateString);
|
||||||
|
const now = new Date();
|
||||||
|
let dateOptions = {
|
||||||
|
month: "numeric",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate()) {
|
||||||
|
dateOptions = { timeStyle: "short" };
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Intl.DateTimeFormat(i18n.language, dateOptions).format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Component({ service }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { widget } = service;
|
||||||
|
|
||||||
|
const { data, error } = useWidgetAPI(widget, "checks");
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return <Container error={error} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label={t("healthchecks.status")} />
|
||||||
|
<Block label={t("healthchecks.last_ping")} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label={t("healthchecks.status")} value={t(`healthchecks.${data.status}`)} />
|
||||||
|
<Block
|
||||||
|
label={t("healthchecks.last_ping")}
|
||||||
|
value={data.last_ping ? formatDate(data.last_ping) : t("healthchecks.never")}
|
||||||
|
/>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
18
src/widgets/healthchecks/widget.js
Normal file
18
src/widgets/healthchecks/widget.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "https://healthchecks.io/api/v2/{endpoint}/{uuid}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
checks: {
|
||||||
|
endpoint: "checks",
|
||||||
|
validate: [
|
||||||
|
"status",
|
||||||
|
"last_ping",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -16,6 +16,7 @@ import gotify from "./gotify/widget";
|
|||||||
import grafana from "./grafana/widget";
|
import grafana from "./grafana/widget";
|
||||||
import hdhomerun from "./hdhomerun/widget";
|
import hdhomerun from "./hdhomerun/widget";
|
||||||
import homebridge from "./homebridge/widget";
|
import homebridge from "./homebridge/widget";
|
||||||
|
import healthchecks from "./healthchecks/widget";
|
||||||
import jackett from "./jackett/widget";
|
import jackett from "./jackett/widget";
|
||||||
import jellyseerr from "./jellyseerr/widget";
|
import jellyseerr from "./jellyseerr/widget";
|
||||||
import komga from "./komga/widget";
|
import komga from "./komga/widget";
|
||||||
@ -87,6 +88,7 @@ const widgets = {
|
|||||||
grafana,
|
grafana,
|
||||||
hdhomerun,
|
hdhomerun,
|
||||||
homebridge,
|
homebridge,
|
||||||
|
healthchecks,
|
||||||
jackett,
|
jackett,
|
||||||
jellyfin: emby,
|
jellyfin: emby,
|
||||||
jellyseerr,
|
jellyseerr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user