From c36d04d99c5ddc4871b4566a738abd52c172bd1a Mon Sep 17 00:00:00 2001 From: "Memoria (Noblistic)" Date: Mon, 2 Nov 2026 16:54:10 +0000 Subject: [PATCH] dashboard: move the JSON export to the Requests header as a download icon The history summary row had grown crowded -- the figures, then a "json" button and a "clear" button -- and the operator asked for the export to live in the Requests panel header instead, top-left by the title, as a download icon with a "Download JSON file" tooltip. The Requests header already carries running/waiting on the right, so the export sits opposite it on the left rather than lumped in with the history figures. The button is an inline SVG download glyph (a
@@ -1240,7 +1254,6 @@ nav button.on { color:var(--fg); background:var(--track); }
history - json clear
@@ -2265,6 +2278,10 @@ function histRender(missed) { const hsum = $("hsum"); hsum.textContent = ""; parts.forEach((p, i) => { + /* The zero-width space is the line's ONLY break opportunity. The groups are nowrap so they + * cannot split, and with no break point here a long summary overflows the row and clips + * whatever follows it -- which is what the padded separators did to this line. */ + if (i) hsum.appendChild(document.createTextNode("\u200b")); const g = el("span", "hgrp"); /* The dot travels WITH the category it introduces: as a sibling it could be left stranded * at the end of a line when the category wrapped, which is the orphan this avoids. */ @@ -2308,8 +2325,13 @@ $("hclr").addEventListener("click", () => { lsSet(HK, "[]"); lsSet(HKN, "0"); lsSet(HKC, String(Date.now())); hDrawn = null; histRender(0); }); -$("hjson").addEventListener("click", () => { - try { navigator.clipboard.writeText(JSON.stringify(hRows)); } catch (e) {} +$("reqjson").addEventListener("click", () => { + const url = URL.createObjectURL(new Blob([JSON.stringify(hRows, null, 2)], + { type: "application/json" })); + const a = el("a"); + a.href = url; a.download = "radiance-history.json"; + document.body.appendChild(a); a.click(); a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 1000); }); histLoad(); histRender(0); diff --git a/tests/js/download.test.js b/tests/js/download.test.js new file mode 100644 index 00000000..fd7906e9 --- /dev/null +++ b/tests/js/download.test.js @@ -0,0 +1,95 @@ +/* The Requests-header JSON export. It used to be a "json" text button in the history row that + * copied to the clipboard; it is now a download icon that saves a file. A button that looks + * clickable and silently does nothing is the failure this guards: so drive the SHIPPED handler + * against stubs and assert it actually builds a file, names it, clicks it, and cleans up. */ +const fs = require("fs"); +const path = require("path"); +const src = require("./page.js"); // the