mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-04 14:32:15 +08:00
Fix: rename pialert to netalertx (#3253)
This commit is contained in:
37
src/widgets/netalertx/component.jsx
Normal file
37
src/widgets/netalertx/component.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
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 { t } = useTranslation();
|
||||
|
||||
const { widget } = service;
|
||||
|
||||
const { data: netalertxData, error: netalertxError } = useWidgetAPI(widget, "data");
|
||||
|
||||
if (netalertxError) {
|
||||
return <Container service={service} error={netalertxError} />;
|
||||
}
|
||||
|
||||
if (!netalertxData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="netalertx.total" />
|
||||
<Block label="netalertx.connected" />
|
||||
<Block label="netalertx.new_devices" />
|
||||
<Block label="netalertx.down_alerts" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="netalertx.total" value={t("common.number", { value: parseInt(netalertxData[0], 10) })} />
|
||||
<Block label="netalertx.connected" value={t("common.number", { value: parseInt(netalertxData[1], 10) })} />
|
||||
<Block label="netalertx.new_devices" value={t("common.number", { value: parseInt(netalertxData[3], 10) })} />
|
||||
<Block label="netalertx.down_alerts" value={t("common.number", { value: parseInt(netalertxData[4], 10) })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user