Skip to content

Commit 6d71a05

Browse files
author
wlanboy
committed
format context
1 parent ea41b98 commit 6d71a05

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

src/main/resources/static/js/k8s-client.js

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,48 @@ const K8sClient = (() => {
4242

4343
// --- TAB C: POD KONTEXT (Dynamisch) ---
4444
const contextRows = Object.entries(context).map(([key, val]) => {
45+
let displayVal = val;
4546
let badgeClass = "bg-light text-dark border";
46-
if (val === true) badgeClass = "bg-success text-white";
47-
if (val === false) badgeClass = "bg-danger text-white";
47+
48+
// 1. Behandlung von Booleans (true/false)
49+
if (typeof val === 'boolean') {
50+
badgeClass = val ? "bg-success text-white" : "bg-danger text-white";
51+
displayVal = val ? "JA" : "NEIN";
52+
}
53+
// 2. Behandlung von komplexen Objekten (wie deine istioDetails)
54+
else if (typeof val === 'object' && val !== null) {
55+
// Wir zeigen in der Tabelle nur einen Hinweis, die Details sind im JSON-Button
56+
displayVal = `<i class="bi bi-diagram-3 me-1"></i> Objekt (siehe Details)`;
57+
badgeClass = "bg-info text-dark border";
58+
}
4859

4960
return `
50-
<tr>
51-
<td class="bg-light fw-bold small text-muted w-25">${key}</td>
52-
<td><span class="badge ${badgeClass} font-monospace">${val}</span></td>
53-
</tr>`;
61+
<tr>
62+
<td class="bg-light fw-bold small text-muted w-25">${key}</td>
63+
<td><span class="badge ${badgeClass} font-monospace">${displayVal}</span></td>
64+
</tr>`;
5465
}).join('');
5566

5667
resourceDiv.innerHTML = `
57-
<div class="p-2">
58-
<div class="d-flex justify-content-between align-items-center border-bottom pb-2 mb-3">
59-
<h6 class="x-small fw-bold text-uppercase text-muted mb-0">Identität & Kontext</h6>
60-
<button class="btn btn-xs btn-outline-primary" onclick="this.parentElement.nextElementSibling.nextElementSibling.classList.toggle('d-none')">
61-
<i class="bi bi-eye me-1"></i> Details (JSON)
62-
</button>
63-
</div>
64-
65-
<table class="table table-sm border shadow-sm">
66-
<tbody>${contextRows}</tbody>
67-
</table>
68-
69-
<div class="d-none mt-3">
70-
<label class="x-small fw-bold text-muted mb-1">RAW CONTEXT RESPONSE:</label>
71-
<pre class="x-small p-3 shadow-inner"
72-
style="background-color: #1e1e1e; color: #4af626; border-radius: 6px; border: 1px solid #333; overflow: auto; max-height: 400px; font-family: 'Fira Code', 'Courier New', monospace;"
73-
>${JSON.stringify(context, null, 4)}</pre>
74-
</div>
75-
</div>`;
68+
<div class="p-2">
69+
<div class="d-flex justify-content-between align-items-center border-bottom pb-2 mb-3">
70+
<h6 class="x-small fw-bold text-uppercase text-muted mb-0">Identität & Kontext</h6>
71+
<button class="btn btn-xs btn-outline-primary" onclick="this.parentElement.nextElementSibling.nextElementSibling.classList.toggle('d-none')">
72+
<i class="bi bi-eye me-1"></i> Details (JSON)
73+
</button>
74+
</div>
75+
76+
<table class="table table-sm border shadow-sm">
77+
<tbody>${contextRows}</tbody>
78+
</table>
79+
80+
<div class="d-none mt-3">
81+
<label class="x-small fw-bold text-muted mb-1">KOMPLETTER KONTEXT (RAW):</label>
82+
<pre class="x-small p-3 shadow-inner"
83+
style="background-color: #1e1e1e; color: #4af626; border-radius: 6px; border: 1px solid #333; overflow: auto; max-height: 500px; font-family: 'Fira Code', monospace;"
84+
>${JSON.stringify(context, null, 4)}</pre>
85+
</div>
86+
</div>`;
7687

7788
} catch (err) {
7889
const msg = `<div class="alert alert-danger m-2 small">Fehler: ${err.message}</div>`;

0 commit comments

Comments
 (0)