From 8d838bb26eb575d3dab2d964cfd96af619c2124c Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Sat, 31 May 2025 22:56:56 +0100 Subject: [PATCH] fix: prioritize display names in node link resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When custom node names are configured, the dashboard shows display names but node links were failing because getHostUrl was checking actual node names first. This fix reorders the lookup to check display names first, ensuring that custom-named nodes have working links. - Check display names before actual node names in getHostUrl - Maintains backward compatibility for non-custom setups - Fixes issue where clicking custom node names didn't open web interface 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/public/js/utils.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/public/js/utils.js b/src/public/js/utils.js index 83aa666f3..8c5d95bf0 100644 --- a/src/public/js/utils.js +++ b/src/public/js/utils.js @@ -326,6 +326,7 @@ PulseApp.utils = (() => { function getHostUrl(nodeName) { const endpoints = PulseApp.state.get('endpoints') || []; const pbsConfigs = PulseApp.state.get('pbsConfigs') || []; + const nodesData = PulseApp.state.get('nodesData') || []; // First check PBS configs for exact name match for (const config of pbsConfigs) { @@ -336,9 +337,18 @@ PulseApp.utils = (() => { // For Proxmox nodes, we need to find which endpoint this node belongs to // by looking at the nodes data from the API - const nodesData = PulseApp.state.get('nodesData') || []; - // Find the node in the API data to get its endpointId + // First check if nodeName matches a displayName (for nodes with custom names) + // This needs to be checked first because the UI shows displayName in headers + const nodeByDisplayName = nodesData.find(node => node.displayName === nodeName); + if (nodeByDisplayName && nodeByDisplayName.endpointId) { + const endpoint = endpoints.find(ep => ep.id === nodeByDisplayName.endpointId); + if (endpoint) { + return endpoint.host; + } + } + + // Then find the node in the API data by actual node name const nodeInfo = nodesData.find(node => node.node === nodeName); if (nodeInfo && nodeInfo.endpointId) { @@ -356,6 +366,15 @@ PulseApp.utils = (() => { } } + // Additional fallback: for standalone nodes, check if the endpoint name matches + // and there's only one node for that endpoint + for (const endpoint of endpoints) { + const endpointNodes = nodesData.filter(node => node.endpointId === endpoint.id); + if (endpointNodes.length === 1 && endpoint.name === nodeName) { + return endpoint.host; + } + } + return null; }