From 594d1dc644ceddde0d8bee8edeff9b94214a9224 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Fri, 30 May 2025 14:10:22 +0100 Subject: [PATCH] fix: resolve additional PVE/PBS server functionality in settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix indexing logic to correctly count existing endpoints - Add support for loading existing additional endpoints from config - Implement proper form population for saved additional servers - Ensure empty state management works correctly - Fix dynamic endpoint addition and removal functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/public/js/ui/settings.js | 158 ++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 4 deletions(-) diff --git a/src/public/js/ui/settings.js b/src/public/js/ui/settings.js index 49f020a3e..43bd567c6 100644 --- a/src/public/js/ui/settings.js +++ b/src/public/js/ui/settings.js @@ -373,8 +373,154 @@ PulseApp.ui.settings = (() => { } function renderAdditionalEndpoints() { - // This will be populated based on what additional endpoints exist in config - // For now, we'll support dynamic addition + const safeConfig = currentConfig || {}; + + // Find all additional PVE endpoints (those with _2, _3, etc suffixes) + const pveContainer = document.getElementById('pve-endpoints-container'); + const pbsContainer = document.getElementById('pbs-endpoints-container'); + + if (pveContainer) { + // Look for existing additional PVE endpoints in config + Object.keys(safeConfig).forEach(key => { + if (key.startsWith('PROXMOX_HOST_') && key !== 'PROXMOX_HOST') { + const suffix = key.replace('PROXMOX_HOST_', ''); + if (suffix && !isNaN(suffix)) { + addExistingPveEndpoint(parseInt(suffix), safeConfig); + } + } + }); + } + + if (pbsContainer) { + // Look for existing additional PBS endpoints in config + Object.keys(safeConfig).forEach(key => { + if (key.startsWith('PBS_HOST_') && key !== 'PBS_HOST') { + const suffix = key.replace('PBS_HOST_', ''); + if (suffix && !isNaN(suffix)) { + addExistingPbsEndpoint(parseInt(suffix), safeConfig); + } + } + }); + } + } + + function addExistingPveEndpoint(index, config) { + const container = document.getElementById('pve-endpoints-container'); + if (!container) return; + + // Hide empty state if this is the first endpoint + const emptyState = container.querySelector('.border-dashed'); + if (emptyState) { + emptyState.style.display = 'none'; + } + + const endpointHtml = ` +
+ +

PVE Server #${index}

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+ `; + + container.insertAdjacentHTML('beforeend', endpointHtml); + } + + function addExistingPbsEndpoint(index, config) { + const container = document.getElementById('pbs-endpoints-container'); + if (!container) return; + + // Hide empty state if this is the first endpoint + const emptyState = container.querySelector('.border-dashed'); + if (emptyState) { + emptyState.style.display = 'none'; + } + + const endpointHtml = ` +
+ +

PBS Server #${index}

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ `; + + container.insertAdjacentHTML('beforeend', endpointHtml); } function addPveEndpoint() { @@ -387,7 +533,9 @@ PulseApp.ui.settings = (() => { emptyState.style.display = 'none'; } - const index = container.children.length + 1; // Start from _2 (but adjust for hidden empty state) + // Count only actual endpoint divs (not the empty state) + const existingEndpoints = container.querySelectorAll('.border:not(.border-dashed)'); + const index = existingEndpoints.length + 2; // Start from _2 for additional endpoints const endpointHtml = `