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";
import { sys } from "typescript";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: systemData, error: systemError } = useWidgetAPI(widget, "system");
const { data: interfaceData, error: interfaceError } = useWidgetAPI(widget, "interface");
const showDiskUsage = widget.fields?.includes('disk');
const showWanIP = widget.fields?.includes('wanIP');
if (systemError || interfaceError) {
const finalError = systemError ?? interfaceError;
return ;
}
if (!systemData || !interfaceData) {
return (
{showDiskUsage && }
{showWanIP && }
);
}
const loadAvg = systemData.data.load_avg[0];
const memory = systemData.data.mem_usage;
const tempC = systemData.data.temp_c
const disk = systemData.data.disk_usage
const wanState = interfaceData.data.filter(l => l.hwif === widget.wan)[0].status
const wanStatus = (wanState == "up") ?
{t("pfsenseapi.up")}:
{t("pfsenseapi.down")};
const wanIP = interfaceData.data.filter(l => l.hwif === widget.wan)[0].ipaddr
return (
{showDiskUsage && }
{showWanIP && }
);
}