bugfix(containers-dashboard): pod blijft in container overzicht staan na stoppen
This commit is contained in:
+35
-13
@@ -626,6 +626,9 @@
|
|||||||
const res = await api(`/pods/actions/${encodeURIComponent(action)}/${encodeURIComponent(name)}`, 'POST');
|
const res = await api(`/pods/actions/${encodeURIComponent(action)}/${encodeURIComponent(name)}`, 'POST');
|
||||||
showModal(`Pod ${action}: ${name}`, JSON.stringify(res, null, 2));
|
showModal(`Pod ${action}: ${name}`, JSON.stringify(res, null, 2));
|
||||||
await fetchPods();
|
await fetchPods();
|
||||||
|
if (currentTab === 'containers') {
|
||||||
|
await fetchContainers();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showModal(`Pod ${action} fout`, e.stack || e.message);
|
showModal(`Pod ${action} fout`, e.stack || e.message);
|
||||||
}
|
}
|
||||||
@@ -681,7 +684,7 @@
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderContainersGrouped(list, tbody) {
|
function renderContainersGrouped(list, tbody, podStatus) {
|
||||||
const groups = new Map();
|
const groups = new Map();
|
||||||
for (const c of (list || [])) {
|
for (const c of (list || [])) {
|
||||||
const k = _podKey(c);
|
const k = _podKey(c);
|
||||||
@@ -689,6 +692,10 @@
|
|||||||
groups.get(k).push(c);
|
groups.get(k).push(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const podName of Object.keys(podStatus || {})) {
|
||||||
|
if (!groups.has(podName)) groups.set(podName, []);
|
||||||
|
}
|
||||||
|
|
||||||
const keys = Array.from(groups.keys()).sort((a, b) => {
|
const keys = Array.from(groups.keys()).sort((a, b) => {
|
||||||
if (a === '(geen pod)' && b !== '(geen pod)') return 1;
|
if (a === '(geen pod)' && b !== '(geen pod)') return 1;
|
||||||
if (b === '(geen pod)' && a !== '(geen pod)') return -1;
|
if (b === '(geen pod)' && a !== '(geen pod)') return -1;
|
||||||
@@ -713,22 +720,24 @@
|
|||||||
const isRealPod = (pod !== '(geen pod)');
|
const isRealPod = (pod !== '(geen pod)');
|
||||||
const total = items.length;
|
const total = items.length;
|
||||||
|
|
||||||
|
let cls = 'muted';
|
||||||
|
let label = '-';
|
||||||
|
|
||||||
|
if (total > 0) {
|
||||||
const running = items.filter(x => {
|
const running = items.filter(x => {
|
||||||
const s = (x.Status || x.State || '').toLowerCase();
|
const s = (x.Status || x.State || '').toLowerCase();
|
||||||
return s === 'running';
|
return s === 'running';
|
||||||
}).length;
|
}).length;
|
||||||
|
|
||||||
let cls = 'warn'; // default
|
label = `${running}/${total}`;
|
||||||
let label = `${running}/${total}`;
|
if (running === total) cls = 'ok';
|
||||||
|
else if (running === 0) cls = 'bad';
|
||||||
if (total === 0) { // edge case
|
else cls = 'warn';
|
||||||
cls = 'muted';
|
|
||||||
} else if (running === total) {
|
|
||||||
cls = 'ok'; // groen
|
|
||||||
} else if (running === 0) {
|
|
||||||
cls = 'bad'; // rood
|
|
||||||
} else {
|
} else {
|
||||||
cls = 'warn'; // oranje
|
const ps = String((podStatus && podStatus[pod]) || '').toLowerCase();
|
||||||
|
if (ps === 'active') { cls = 'ok'; label = 'active'; }
|
||||||
|
else if (ps === 'inactive') { cls = 'bad'; label = 'inactive'; }
|
||||||
|
else { cls = 'muted'; label = ps || 'unknown'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
@@ -796,12 +805,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchContainers() {
|
async function fetchContainers() {
|
||||||
const containers = await api('/containers-dashboard', 'GET');
|
|
||||||
|
const [containers, pods] = await Promise.all([
|
||||||
|
api('/containers-dashboard', 'GET'),
|
||||||
|
api('/pods-dashboard', 'GET')
|
||||||
|
]);
|
||||||
|
|
||||||
const list = Array.isArray(containers) ? containers : (containers?.containers || []);
|
const list = Array.isArray(containers) ? containers : (containers?.containers || []);
|
||||||
document.getElementById('countContainers').textContent = list.length;
|
document.getElementById('countContainers').textContent = list.length;
|
||||||
|
|
||||||
|
const podsList = Array.isArray(pods) ? pods : [];
|
||||||
|
const podStatus = {};
|
||||||
|
for (const p of podsList) {
|
||||||
|
const n = p?.Name || p?.name;
|
||||||
|
if (!n) continue;
|
||||||
|
podStatus[n] = (p?.Status || p?.status || '').toLowerCase(); // "active"/"inactive"/...
|
||||||
|
}
|
||||||
|
|
||||||
const tbody = document.getElementById('containersTbody');
|
const tbody = document.getElementById('containersTbody');
|
||||||
renderContainersGrouped(list, tbody);
|
renderContainersGrouped(list, tbody, podStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
let containersStatsES = null;
|
let containersStatsES = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user