mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-19 02:59:50 +00:00
Feature: OpenWRT service widget (#2782)
* Feat: OpenWRT widget implementation * Update proxy.js * fixes from review --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
d20cdbb9ab
commit
86740c6d7b
10 changed files with 280 additions and 0 deletions
37
src/widgets/openwrt/methods/interface.jsx
Normal file
37
src/widgets/openwrt/methods/interface.jsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
const { data, error } = useWidgetAPI(service.widget);
|
||||
|
||||
if (error) {
|
||||
return <Container service={service} error={error} />;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { up, bytesTx, bytesRx } = data;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block
|
||||
label="widget.status"
|
||||
value={
|
||||
up ? (
|
||||
<span className="text-green-500">{t("openwrt.up")}</span>
|
||||
) : (
|
||||
<span className="text-red-500">{t("openwrt.down")}</span>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Block label="openwrt.bytesTx" value={t("common.bytes", { value: bytesTx })} />
|
||||
<Block label="openwrt.bytesRx" value={t("common.bytes", { value: bytesRx })} />
|
||||
</Container>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue