From 85505586acc9dd3d55880f39ab5b6c4312dcfe78 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Sat, 20 Sep 2025 22:41:40 +0200 Subject: [PATCH] feat: always sort nodes by hostname in monitoring view --- .../scripts/components/MonitoringViewComponent.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/public/scripts/components/MonitoringViewComponent.js b/public/scripts/components/MonitoringViewComponent.js index 32b2c4a..23023ea 100644 --- a/public/scripts/components/MonitoringViewComponent.js +++ b/public/scripts/components/MonitoringViewComponent.js @@ -343,9 +343,16 @@ class MonitoringViewComponent extends Component { return; } - const nodesHtml = Array.from(nodeResources.values()).map(nodeData => { - return this.renderNodeCard(nodeData); - }).join(''); + const nodesHtml = Array.from(nodeResources.values()) + .sort((a, b) => { + // Sort by hostname, fallback to IP if hostname is not available + const hostnameA = a.hostname || a.ip || ''; + const hostnameB = b.hostname || b.ip || ''; + return hostnameA.localeCompare(hostnameB); + }) + .map(nodeData => { + return this.renderNodeCard(nodeData); + }).join(''); container.innerHTML = `