From ca4b5b131da082a19f4e94e49b827f2a5d558e72 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 22 Jan 2023 09:03:56 -0800 Subject: [PATCH] Allow specifying wan interface on opnsense widget --- src/utils/config/service-helpers.js | 6 +++++- src/widgets/opnsense/component.jsx | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index 28f4d76d4..2024e10d7 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -214,7 +214,8 @@ export function cleanServiceGroups(groups) { defaultinterval, namespace, // kubernetes widget app, - podSelector + podSelector, + wan // opnsense widget } = cleanedService.widget; cleanedService.widget = { @@ -237,6 +238,9 @@ export function cleanServiceGroups(groups) { if (app) cleanedService.widget.app = app; if (podSelector) cleanedService.widget.podSelector = podSelector; } + if (type === "opnsense") { + if (wan) cleanedService.widget.wan = wan; + } } return cleanedService; diff --git a/src/widgets/opnsense/component.jsx b/src/widgets/opnsense/component.jsx index 53396b31e..61753b472 100644 --- a/src/widgets/opnsense/component.jsx +++ b/src/widgets/opnsense/component.jsx @@ -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 ( - - - + {wan && } + {wan && } ); }