diff --git a/src/webui/static/app.js b/src/webui/static/app.js index 0444adcf..4a370874 100644 --- a/src/webui/static/app.js +++ b/src/webui/static/app.js @@ -3,9 +3,9 @@ * Integrates admin API with the user interface */ -// Global state -let nodeInfo = null; -let peersData = null; +// Global state - expose to window for access from other scripts +window.nodeInfo = null; +window.peersData = null; let isLoading = false; /** @@ -14,7 +14,7 @@ let isLoading = false; async function loadNodeInfo() { try { const info = await window.yggAPI.getSelf(); - nodeInfo = info; + window.nodeInfo = info; updateNodeInfoDisplay(info); return info; } catch (error) { @@ -30,7 +30,7 @@ async function loadNodeInfo() { async function loadPeers() { try { const data = await window.yggAPI.getPeers(); - peersData = data; + window.peersData = data; updatePeersDisplay(data); return data; } catch (error) { @@ -64,6 +64,13 @@ function updatePeersDisplay(data) { peersContainer.innerHTML = ''; + // Always update peer counts, even if no peers + const peersCount = data.peers ? data.peers.length : 0; + const onlineCount = data.peers ? data.peers.filter(p => p.up).length : 0; + + updateElementText('peers-count', peersCount.toString()); + updateElementText('peers-online', onlineCount.toString()); + if (!data.peers || data.peers.length === 0) { peersContainer.innerHTML = '