Allow specifying wan interface on opnsense widget

This commit is contained in:
Michael Shamoon 2023-01-22 09:03:56 -08:00
parent cdbdb86c9e
commit ca4b5b131d
2 changed files with 8 additions and 6 deletions

View file

@ -33,16 +33,14 @@ export default function Component({ service }) {
const cpu = 100 - parseFloat(cpuIdle);
const memory = activityData.headers[3].match(/Mem: (.+) Active,/)[1];
const wanUpload = interfaceData.interfaces.wan['bytes transmitted'];
const wanDownload = interfaceData.interfaces.wan['bytes received'];
const wan = widget.wan ? interfaceData.interfaces[widget.wan] : interfaceData.interfaces.wan;
return (
<Container service={service}>
<Block label="opnsense.cpu" value={t("common.percent", { value: cpu.toFixed(2) })} />
<Block label="opnsense.memory" value={memory} />
<Block label="opnsense.wanUpload" value={t("common.bytes", { value: wanUpload })} />
<Block label="opnsense.wanDownload" value={t("common.bytes", { value: wanDownload })} />
{wan && <Block label="opnsense.wanUpload" value={t("common.bytes", { value: wan['bytes transmitted'] })} />}
{wan && <Block label="opnsense.wanDownload" value={t("common.bytes", { value: wan['bytes received'] })} />}
</Container>
);
}