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 | 58f04105de0e0ac0f2a97696151c7e727f5d6d29 (patch) | |
| tree | 151e27013f89b0fd63fd8ca3c1e60e92925998dc /src/api/dashboard | |
| parent | 1d54050fc232b2a26d75877da3bdcdd0fed96652 (diff) | |
dashboard: empty items are't collapsible
Diffstat (limited to 'src/api/dashboard')
| -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)); |
