fix (ui/volumes): herstel container-koppeling via inspect endpoint
containers-dashboard geeft Mounts als strings (destination paden).
Volledige mount-info (Type + Name) zit alleen in /containers/inspect/{name}.
Fix: voor containers met niet-lege Mounts parallel inspect ophalen,
daarna filteren op Type === "volume" voor named volume koppeling.
Getest: postgresdb_data → postgres-db, n8n_data → n8n.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,12 +11,29 @@ async function loadVolumes() {
|
|||||||
|
|
||||||
volumesData = Array.isArray(volumes) ? volumes : [];
|
volumesData = Array.isArray(volumes) ? volumes : [];
|
||||||
|
|
||||||
// Bouw volume → containers mapping op basis van Mounts
|
// containers-dashboard geeft Mounts als strings (destination paden).
|
||||||
|
// Volledige mount-info (Type + Name) zit alleen in de inspect endpoint.
|
||||||
|
// Haal inspect op voor alle containers met niet-lege Mounts, parallel.
|
||||||
|
const containerList = Array.isArray(containers) ? containers : [];
|
||||||
|
const withMounts = containerList.filter(c => (c.Mounts || []).length > 0);
|
||||||
|
const inspectResults = await Promise.all(
|
||||||
|
withMounts.map(c => {
|
||||||
|
const name = (c.Names && c.Names[0]) || "";
|
||||||
|
if (!name) return Promise.resolve(null);
|
||||||
|
return fetch("/api/containers/inspect/" + encodeURIComponent(name))
|
||||||
|
.then(r => r.ok ? r.json() : null)
|
||||||
|
.catch(() => null);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Bouw volume → containers mapping: filter op Type === "volume"
|
||||||
volumeContainersMap = {};
|
volumeContainersMap = {};
|
||||||
for (const c of (Array.isArray(containers) ? containers : [])) {
|
for (let i = 0; i < withMounts.length; i++) {
|
||||||
const cname = (c.Names && c.Names[0]) || "";
|
const inspect = inspectResults[i];
|
||||||
for (const m of (c.Mounts || [])) {
|
if (!inspect) continue;
|
||||||
if (m.Name) {
|
const cname = (withMounts[i].Names && withMounts[i].Names[0]) || "";
|
||||||
|
for (const m of (inspect.Mounts || [])) {
|
||||||
|
if (m.Type === "volume" && m.Name) {
|
||||||
(volumeContainersMap[m.Name] = volumeContainersMap[m.Name] || []).push(cname);
|
(volumeContainersMap[m.Name] = volumeContainersMap[m.Name] || []).push(cname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user