From 001b745e2fa0b283c7168dd622350ea68b5ed53b Mon Sep 17 00:00:00 2001 From: kodi Date: Mon, 23 Feb 2026 14:04:29 +0100 Subject: [PATCH] feat (ui): functionaliteit knoppen auto-layout en reset-view toegevoegd --- webui/html/assets/js/tabs/networks.js | 39 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/webui/html/assets/js/tabs/networks.js b/webui/html/assets/js/tabs/networks.js index f467492..9d8c913 100644 --- a/webui/html/assets/js/tabs/networks.js +++ b/webui/html/assets/js/tabs/networks.js @@ -742,7 +742,21 @@ const btn = document.getElementById('networksRefreshBtn'); if (btn && !btn.dataset.bound) { btn.dataset.bound = '1'; - btn.addEventListener('click', refresh); + resetBtn.addEventListener('click', () => { + if (!graphCtx) return; + + // reset zoom + graphCtx.svg + .transition() + .duration(400) + .call( + d3.zoom().transform, + d3.zoomIdentity + ); + + // restart simulation + graphCtx.sim.alpha(0.6).restart(); + }); } // View toggle (Tabel/Kaart) @@ -773,10 +787,19 @@ if (resetBtn && !resetBtn.dataset.bound) { resetBtn.dataset.bound = '1'; resetBtn.addEventListener('click', () => { - // In 3C koppelen we dit aan zoom reset + simulation reset - const s = document.getElementById('networksMapStatus'); - if (s) s.textContent = 'Reset view (placeholder)'; - setTimeout(() => { if (s) s.textContent = 'Kaartweergave (placeholder)'; }, 900); + if (!graphCtx) return; + + // reset zoom + graphCtx.svg + .transition() + .duration(400) + .call( + d3.zoom().transform, + d3.zoomIdentity + ); + + // restart simulation + graphCtx.sim.alpha(0.6).restart(); }); } @@ -784,10 +807,8 @@ if (layoutBtn && !layoutBtn.dataset.bound) { layoutBtn.dataset.bound = '1'; layoutBtn.addEventListener('click', () => { - // In 3C koppelen we dit aan simulation.restart() - const s = document.getElementById('networksMapStatus'); - if (s) s.textContent = 'Auto-layout (placeholder)'; - setTimeout(() => { if (s) s.textContent = 'Kaartweergave (placeholder)'; }, 900); + if (!graphCtx) return; + graphCtx.sim.alpha(1).restart(); }); }