From fadb03ad27bf9a7a89586d0149808aca6f8a69ad Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 17 Mar 2026 09:12:01 -0700 Subject: [PATCH] Enhancement: better support for raw values in block highlighting (#6434) --- src/components/services/widget/block.jsx | 6 +-- src/components/services/widget/block.test.jsx | 23 +++++++++ src/widgets/adguard/component.jsx | 1 + src/widgets/beszel/component.jsx | 19 ++++++-- src/widgets/deluge/component.jsx | 4 +- src/widgets/docker/component.jsx | 10 ++-- src/widgets/dockhand/component.jsx | 12 ++++- src/widgets/downloadstation/component.jsx | 4 +- src/widgets/filebrowser/component.jsx | 15 ++++-- src/widgets/flood/component.jsx | 4 +- src/widgets/fritzbox/component.jsx | 36 +++++++++++--- src/widgets/gamedig/component.jsx | 2 +- src/widgets/gatus/component.jsx | 2 +- src/widgets/jdownloader/component.jsx | 13 ++++- src/widgets/kubernetes/component.jsx | 13 ++++- src/widgets/mikrotik/component.jsx | 12 ++++- src/widgets/myspeed/component.jsx | 1 + src/widgets/nextcloud/component.jsx | 15 +++++- src/widgets/nzbget/component.jsx | 13 ++++- src/widgets/openwrt/methods/interface.jsx | 4 +- src/widgets/opnsense/component.jsx | 18 +++++-- src/widgets/peanut/component.jsx | 12 ++++- src/widgets/pfsense/component.jsx | 15 +++++- src/widgets/proxmox/component.jsx | 12 ++++- src/widgets/proxmoxbackupserver/component.jsx | 18 +++++-- src/widgets/proxmoxvm/component.jsx | 8 +++- src/widgets/pyload/component.jsx | 6 ++- src/widgets/qbittorrent/component.jsx | 12 ++++- src/widgets/rutorrent/component.jsx | 4 +- src/widgets/speedtest/component.jsx | 1 + src/widgets/strelaysrv/component.jsx | 7 ++- src/widgets/tdarr/component.jsx | 2 +- src/widgets/transmission/component.jsx | 4 +- src/widgets/unraid/component.jsx | 48 ++++++++++++++----- src/widgets/uptimekuma/component.jsx | 2 +- 35 files changed, 300 insertions(+), 78 deletions(-) diff --git a/src/components/services/widget/block.jsx b/src/components/services/widget/block.jsx index c61dd5d54..e78123ea8 100644 --- a/src/components/services/widget/block.jsx +++ b/src/components/services/widget/block.jsx @@ -6,7 +6,7 @@ import { BlockHighlightContext } from "./highlight-context"; import { evaluateHighlight, getHighlightClass } from "utils/highlights"; -export default function Block({ value, label, field }) { +export default function Block({ value, highlightValue, label, field }) { const { t } = useTranslation(); const highlightConfig = useContext(BlockHighlightContext); @@ -20,12 +20,12 @@ export default function Block({ value, label, field }) { } for (const candidate of candidates) { - const result = evaluateHighlight(candidate, value, highlightConfig); + const result = evaluateHighlight(candidate, highlightValue ?? value, highlightConfig); if (result) return result; } return null; - }, [field, label, value, highlightConfig]); + }, [field, label, value, highlightValue, highlightConfig]); const highlightClass = useMemo(() => { if (!highlight?.level) return undefined; diff --git a/src/components/services/widget/block.test.jsx b/src/components/services/widget/block.test.jsx index ece7518a7..38ee0d137 100644 --- a/src/components/services/widget/block.test.jsx +++ b/src/components/services/widget/block.test.jsx @@ -38,4 +38,27 @@ describe("components/services/widget/block", () => { expect(el.getAttribute("data-highlight-level")).toBe("danger"); expect(el.className).toContain("danger-class"); }); + + it("prefers highlightValue over the rendered value for numeric highlighting", () => { + const highlightConfig = { + levels: { warn: "warn-class" }, + fields: { + foo: { + numeric: { when: "gt", value: 5, level: "warn" }, + }, + }, + }; + + const { container } = renderWithProviders( + + + , + { settings: {} }, + ); + + const el = container.querySelector(".service-block"); + expect(el).not.toBeNull(); + expect(el.getAttribute("data-highlight-level")).toBe("warn"); + expect(el.className).toContain("warn-class"); + }); }); diff --git a/src/widgets/adguard/component.jsx b/src/widgets/adguard/component.jsx index e5a7670a5..47980e11b 100644 --- a/src/widgets/adguard/component.jsx +++ b/src/widgets/adguard/component.jsx @@ -37,6 +37,7 @@ export default function Component({ service }) { ); diff --git a/src/widgets/beszel/component.jsx b/src/widgets/beszel/component.jsx index bbcaeb0b7..18ed67d27 100644 --- a/src/widgets/beszel/component.jsx +++ b/src/widgets/beszel/component.jsx @@ -51,12 +51,25 @@ export default function Component({ service }) { - - - + + + ); diff --git a/src/widgets/deluge/component.jsx b/src/widgets/deluge/component.jsx index eb6ddfaa1..1707eb6ce 100644 --- a/src/widgets/deluge/component.jsx +++ b/src/widgets/deluge/component.jsx @@ -52,9 +52,9 @@ export default function Component({ service }) { <> - + - + {widget?.enableLeechProgress && leechTorrents.map((queueEntry) => ( diff --git a/src/widgets/docker/component.jsx b/src/widgets/docker/component.jsx index 6e05454f8..b1d8e1255 100644 --- a/src/widgets/docker/component.jsx +++ b/src/widgets/docker/component.jsx @@ -41,17 +41,19 @@ export default function Component({ service }) { } const { rxBytes, txBytes } = calculateThroughput(statsData.stats); + const cpuPercent = calculateCPUPercent(statsData.stats); + const usedMemory = calculateUsedMemory(statsData.stats); return ( - + {statsData.stats.memory_stats.usage && ( - + )} {statsData.stats.networks && ( <> - - + + )} diff --git a/src/widgets/dockhand/component.jsx b/src/widgets/dockhand/component.jsx index 50ccff180..d3c97bd01 100644 --- a/src/widgets/dockhand/component.jsx +++ b/src/widgets/dockhand/component.jsx @@ -105,8 +105,16 @@ export default function Component({ service }) { - - + + - + - + ); } diff --git a/src/widgets/filebrowser/component.jsx b/src/widgets/filebrowser/component.jsx index cf5a28000..53b6d89b9 100644 --- a/src/widgets/filebrowser/component.jsx +++ b/src/widgets/filebrowser/component.jsx @@ -25,14 +25,21 @@ export default function Component({ service }) { ); } + const available = (usage?.total ?? 0) - (usage?.used ?? 0); + return ( + + - - ); } diff --git a/src/widgets/flood/component.jsx b/src/widgets/flood/component.jsx index 92a2b61a0..973f8a6fd 100644 --- a/src/widgets/flood/component.jsx +++ b/src/widgets/flood/component.jsx @@ -45,9 +45,9 @@ export default function Component({ service }) { return ( - + - + ); } diff --git a/src/widgets/fritzbox/component.jsx b/src/widgets/fritzbox/component.jsx index d7928c20b..405975059 100644 --- a/src/widgets/fritzbox/component.jsx +++ b/src/widgets/fritzbox/component.jsx @@ -47,12 +47,36 @@ export default function Component({ service }) { - - - - - - + + + + + + diff --git a/src/widgets/gamedig/component.jsx b/src/widgets/gamedig/component.jsx index b76002b51..2efea5631 100644 --- a/src/widgets/gamedig/component.jsx +++ b/src/widgets/gamedig/component.jsx @@ -58,7 +58,7 @@ export default function Component({ service }) { - + ); } diff --git a/src/widgets/gatus/component.jsx b/src/widgets/gatus/component.jsx index 25aae239e..3a30b7e2b 100644 --- a/src/widgets/gatus/component.jsx +++ b/src/widgets/gatus/component.jsx @@ -45,7 +45,7 @@ export default function Component({ service }) { - + ); } diff --git a/src/widgets/jdownloader/component.jsx b/src/widgets/jdownloader/component.jsx index a7722c7c4..c352902e4 100644 --- a/src/widgets/jdownloader/component.jsx +++ b/src/widgets/jdownloader/component.jsx @@ -31,12 +31,21 @@ export default function Component({ service }) { return ( - + + - ); } diff --git a/src/widgets/kubernetes/component.jsx b/src/widgets/kubernetes/component.jsx index d3587a59a..e008411ec 100644 --- a/src/widgets/kubernetes/component.jsx +++ b/src/widgets/kubernetes/component.jsx @@ -43,14 +43,23 @@ export default function Component({ service }) { return ( {(statsData.stats.cpuLimit && ( - + )) || ( )} - + ); } diff --git a/src/widgets/mikrotik/component.jsx b/src/widgets/mikrotik/component.jsx index 4bab67926..fd7365d80 100644 --- a/src/widgets/mikrotik/component.jsx +++ b/src/widgets/mikrotik/component.jsx @@ -35,8 +35,16 @@ export default function Component({ service }) { return ( - - + + ); diff --git a/src/widgets/myspeed/component.jsx b/src/widgets/myspeed/component.jsx index e0967d471..8db5ecd0e 100644 --- a/src/widgets/myspeed/component.jsx +++ b/src/widgets/myspeed/component.jsx @@ -54,6 +54,7 @@ export default function Component({ service }) { style: "unit", unit: "millisecond", })} + highlightValue={data[0].ping} /> ); diff --git a/src/widgets/nextcloud/component.jsx b/src/widgets/nextcloud/component.jsx index d1f1cac9b..fe78bf3db 100755 --- a/src/widgets/nextcloud/component.jsx +++ b/src/widgets/nextcloud/component.jsx @@ -56,12 +56,23 @@ export default function Component({ service }) { return ( {showCpuLoad && ( - + + )} + {showMemoryUsage && ( + )} - {showMemoryUsage && } diff --git a/src/widgets/nzbget/component.jsx b/src/widgets/nzbget/component.jsx index a11ac9da1..401010f8d 100644 --- a/src/widgets/nzbget/component.jsx +++ b/src/widgets/nzbget/component.jsx @@ -27,11 +27,20 @@ export default function Component({ service }) { return ( - - + + ); diff --git a/src/widgets/openwrt/methods/interface.jsx b/src/widgets/openwrt/methods/interface.jsx index b746bc7e4..99e66ea2d 100644 --- a/src/widgets/openwrt/methods/interface.jsx +++ b/src/widgets/openwrt/methods/interface.jsx @@ -21,8 +21,8 @@ export default function Component({ service }) { return ( - - + + ); } diff --git a/src/widgets/opnsense/component.jsx b/src/widgets/opnsense/component.jsx index 1caaab472..17c765fc9 100644 --- a/src/widgets/opnsense/component.jsx +++ b/src/widgets/opnsense/component.jsx @@ -36,10 +36,22 @@ export default function Component({ service }) { return ( - + - {wan && } - {wan && } + {wan && ( + + )} + {wan && ( + + )} ); } diff --git a/src/widgets/peanut/component.jsx b/src/widgets/peanut/component.jsx index 54a293adb..f2c8491dd 100644 --- a/src/widgets/peanut/component.jsx +++ b/src/widgets/peanut/component.jsx @@ -52,8 +52,16 @@ export default function Component({ service }) { return ( - - + + ); diff --git a/src/widgets/pfsense/component.jsx b/src/widgets/pfsense/component.jsx index 69a862b44..06285ed78 100644 --- a/src/widgets/pfsense/component.jsx +++ b/src/widgets/pfsense/component.jsx @@ -51,14 +51,25 @@ export default function Component({ service }) { label="pfsense.load" value={version === 1 ? systemData.data.load_avg[0] : systemData.data.cpu_load_avg[0]} /> - + {showWanIP && } - {showDiskUsage && } + {showDiskUsage && ( + + )} ); } diff --git a/src/widgets/proxmox/component.jsx b/src/widgets/proxmox/component.jsx index 51762a737..ddab5bc51 100644 --- a/src/widgets/proxmox/component.jsx +++ b/src/widgets/proxmox/component.jsx @@ -67,8 +67,16 @@ export default function Component({ service }) { - - + + ); } diff --git a/src/widgets/proxmoxbackupserver/component.jsx b/src/widgets/proxmoxbackupserver/component.jsx index b13f87565..0af1134be 100644 --- a/src/widgets/proxmoxbackupserver/component.jsx +++ b/src/widgets/proxmoxbackupserver/component.jsx @@ -47,10 +47,22 @@ export default function Component({ service }) { return ( - + - - + + ); } diff --git a/src/widgets/proxmoxvm/component.jsx b/src/widgets/proxmoxvm/component.jsx index 75593642c..4cc0f8730 100644 --- a/src/widgets/proxmoxvm/component.jsx +++ b/src/widgets/proxmoxvm/component.jsx @@ -25,8 +25,12 @@ export default function ProxmoxVM({ service }) { return ( - - + + ); } diff --git a/src/widgets/pyload/component.jsx b/src/widgets/pyload/component.jsx index f618f75e5..13ee32a92 100644 --- a/src/widgets/pyload/component.jsx +++ b/src/widgets/pyload/component.jsx @@ -26,7 +26,11 @@ export default function Component({ service }) { return ( - + diff --git a/src/widgets/qbittorrent/component.jsx b/src/widgets/qbittorrent/component.jsx index 73dfacb5c..0f0fa3af3 100644 --- a/src/widgets/qbittorrent/component.jsx +++ b/src/widgets/qbittorrent/component.jsx @@ -74,9 +74,17 @@ export default function Component({ service }) { <> - + - + {widget?.enableLeechProgress && leechTorrents.map((queueEntry) => ( diff --git a/src/widgets/rutorrent/component.jsx b/src/widgets/rutorrent/component.jsx index 245a786cb..8f744b520 100644 --- a/src/widgets/rutorrent/component.jsx +++ b/src/widgets/rutorrent/component.jsx @@ -34,8 +34,8 @@ export default function Component({ service }) { return ( - - + + ); } diff --git a/src/widgets/speedtest/component.jsx b/src/widgets/speedtest/component.jsx index 7be00aa22..bc579b76a 100644 --- a/src/widgets/speedtest/component.jsx +++ b/src/widgets/speedtest/component.jsx @@ -54,6 +54,7 @@ export default function Component({ service }) { style: "unit", unit: "millisecond", })} + highlightValue={speedtestData.data.ping} /> ); diff --git a/src/widgets/strelaysrv/component.jsx b/src/widgets/strelaysrv/component.jsx index 026e19b70..e79345c42 100644 --- a/src/widgets/strelaysrv/component.jsx +++ b/src/widgets/strelaysrv/component.jsx @@ -29,10 +29,15 @@ export default function Component({ service }) { - + ); diff --git a/src/widgets/tdarr/component.jsx b/src/widgets/tdarr/component.jsx index 824a56b34..9dbc7e4de 100644 --- a/src/widgets/tdarr/component.jsx +++ b/src/widgets/tdarr/component.jsx @@ -46,7 +46,7 @@ export default function Component({ service }) { - + ); } diff --git a/src/widgets/transmission/component.jsx b/src/widgets/transmission/component.jsx index 474fe69f8..06b549513 100644 --- a/src/widgets/transmission/component.jsx +++ b/src/widgets/transmission/component.jsx @@ -36,9 +36,9 @@ export default function Component({ service }) { return ( - + - + ); } diff --git a/src/widgets/unraid/component.jsx b/src/widgets/unraid/component.jsx index f7b8dc5ca..1d90f34bc 100644 --- a/src/widgets/unraid/component.jsx +++ b/src/widgets/unraid/component.jsx @@ -58,35 +58,59 @@ export default function Component({ service }) { return ( - - + + + - + - {...POOLS.flatMap((pool) => - POOL_FIELDS.map(({ param, label, valueKey, valueType }) => ( - - )), + POOL_FIELDS.map(({ param, label, valueKey, valueType }) => { + const poolValue = data.caches?.[widget?.[pool]]?.[valueKey] || "-"; + + return ( + + ); + }), )} ); diff --git a/src/widgets/uptimekuma/component.jsx b/src/widgets/uptimekuma/component.jsx index e8a42e48f..a660a417d 100644 --- a/src/widgets/uptimekuma/component.jsx +++ b/src/widgets/uptimekuma/component.jsx @@ -50,7 +50,7 @@ export default function Component({ service }) { - + {incidentTime && (