diff --git a/webui/html/assets/js/tabs/volumes.js b/webui/html/assets/js/tabs/volumes.js new file mode 100644 index 0000000..c7181ad --- /dev/null +++ b/webui/html/assets/js/tabs/volumes.js @@ -0,0 +1,202 @@ +let volumesData = []; +let volumeContainersMap = {}; + +async function loadVolumes() { + const tbody = document.getElementById("volumes-tbody"); + try { + const [volumes, containers] = await Promise.all([ + fetch("/api/volumes").then(r => { if (!r.ok) throw new Error(`HTTP ${r.status}`); return r.json(); }), + fetch("/api/containers-dashboard").then(r => r.ok ? r.json() : []).catch(() => []) + ]); + + volumesData = Array.isArray(volumes) ? volumes : []; + + // Bouw volume → containers mapping op basis van Mounts + volumeContainersMap = {}; + for (const c of (Array.isArray(containers) ? containers : [])) { + const cname = (c.Names && c.Names[0]) || ""; + for (const m of (c.Mounts || [])) { + if (m.Name) { + (volumeContainersMap[m.Name] = volumeContainersMap[m.Name] || []).push(cname); + } + } + } + + if (typeof window.updateNavCount === "function") { + window.updateNavCount("countNavVolumes", volumesData.length); + } + renderVolumes(volumesData); + } catch (e) { + volumesData = []; + if (typeof window.updateNavCount === "function") window.updateNavCount("countNavVolumes", 0); + if (tbody) { + const box = typeof window.renderStateBox === "function" + ? window.renderStateBox("error", "Volumes laden mislukt", e.message || String(e)) + : "Volumes laden mislukt."; + tbody.innerHTML = `