diff options
| author | tv <tv@krebsco.de> | 2026-10-30 19:47:47 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-30 19:47:47 +0100 |
| commit | ab541c53d320f5120a43e963e2a3bc46e0d8aeda (patch) | |
| tree | 0b11032ba4c1ed500563497719a5491cd26c5bb9 | |
| parent | 8e3ca379b90e4797006cc9c54b26185e2c998815 (diff) | |
dashboard: empty items are't collapsible
| -rw-r--r-- | src/api/dashboard/dashboard.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html index 7feb8c3..d0d637d 100644 --- a/src/api/dashboard/dashboard.html +++ b/src/api/dashboard/dashboard.html @@ -243,6 +243,11 @@ function renderPeers() { // --- Figures: a tree, its open branches kept across renders --- const open = new Set(["stats", "peer", "links", "from", "to"]); function tree(key, value, path) { + // Empty: nothing to open. + if (value !== null && typeof value === "object" && Object.keys(value).length === 0) { + return el("div", { class: "leaf" }, el("span", { class: "key" }, key + ": "), + Array.isArray(value) ? "[]" : "{}"); + } if (value !== null && typeof value === "object") { const details = el("details", {}); if (open.has(path)) details.open = true; @@ -570,7 +575,13 @@ async function readStore(path, shallow) { } // One entry: a short scalar as it is; anything else a branch read when opened. A // branch's entries are kept across reads, so what's open inside stays open. +// An empty map, list or text: shown as it is, nothing to open. +const EMPTY = { map: "{}", list: "[]", text: "\"\"" }; function documentEntry(key, summary, path) { + if (summary.size === 0 && summary.type in EMPTY) { + return el("div", { class: "leaf" }, el("span", { class: "key" }, key + ": "), + EMPTY[summary.type]); + } if ("value" in summary) { return el("div", { class: "leaf" }, el("span", { class: "key" }, key + ": "), JSON.stringify(summary.value)); |
