mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-19 11:09:50 +00:00
Added PiAlert widget [WIP] (#1493)
* Added PiAlert widget * pialert: comments clean * Syntax changes to piAlert widget --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
c8eccc71a4
commit
36eaaafd88
5 changed files with 60 additions and 0 deletions
37
src/widgets/pialert/component.jsx
Normal file
37
src/widgets/pialert/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: pialertData, error: pialertError } = useWidgetAPI(widget, "data");
|
||||
|
||||
if (pialertError) {
|
||||
return <Container service={service} error={pialertError} />;
|
||||
}
|
||||
|
||||
if (!pialertData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="pialert.total" />
|
||||
<Block label="pialert.connected" />
|
||||
<Block label="pialert.new_devices" />
|
||||
<Block label="pialert.down_alerts" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="pialert.total" value={t("common.number", { value: parseInt(pialertData[0], 10) })} />
|
||||
<Block label="pialert.connected" value={t("common.number", { value: parseInt(pialertData[1], 10) })} />
|
||||
<Block label="pialert.new_devices" value={t("common.number", { value: parseInt(pialertData[3], 10) })} />
|
||||
<Block label="pialert.down_alerts" value={t("common.number", { value: parseInt(pialertData[4], 10) })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue