Enhancement: Checkmk widget (#5301)
Some checks failed
Docker CI / Linting Checks (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Crowdin Action / Crowdin Sync (push) Has been cancelled

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Dmitry Chumak
2025-05-22 20:07:53 +03:00
committed by GitHub
parent ee07a7dcbe
commit 0d47fa8215
7 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import Block from "components/services/widget/block";
import Container from "components/services/widget/container";
import { useTranslation } from "next-i18next";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: servicesData, error: servicesError } = useWidgetAPI(widget, "services_info", {
columns: "state",
query: '{"op": "!=", "left": "state", "right": "0"}',
});
const { data: hostsData, error: hostsError } = useWidgetAPI(widget, "hosts_info", {
columns: "state",
query: '{"op": "!=", "left": "state", "right": "0"}',
});
if (servicesError || hostsError) {
return <Container service={service} error={servicesError ?? hostsError} />;
}
if (!servicesData || !hostsData) {
return (
<Container service={service}>
<Block label="checkmk.serviceErrors" />
<Block label="checkmk.hostErrors" />
</Container>
);
}
return (
<Container service={service}>
<Block label="checkmk.serviceErrors" value={t("common.number", { value: servicesData.value.length })} />
<Block label="checkmk.hostErrors" value={t("common.number", { value: hostsData.value.length })} />
</Container>
);
}