--- title: UI Feedback --- ```js import {API, POLL} from "./components/config.js"; ``` ```js const feedbackState = (async function*() { while (true) { let data = [], ok = false; try { const r = await fetch(`${API}/technical-debt/?debt_type=dashboard-improvement`); ok = r.ok; if (ok) { const items = await r.json(); data = items .filter(t => t.debt_type === "dashboard-improvement") .sort((a, b) => { const st = {open: 0, in_progress: 1, deferred: 2, resolved: 3, wont_fix: 4}; return (st[a.status] ?? 9) - (st[b.status] ?? 9); }); } } catch {} yield {data, ok, ts: new Date()}; await new Promise(res => setTimeout(res, POLL)); } })(); ``` ```js const data = feedbackState.data ?? []; const _ok = feedbackState.ok ?? false; const _ts = feedbackState.ts; ``` # UI Feedback ```js import {injectTocTop} from "./components/toc-sidebar.js"; import {withDocHelp} from "./components/doc-overlay.js"; const _open = data.filter(t => t.status === "open" || t.status === "in_progress"); const _resolved = data.filter(t => t.status === "resolved"); const _wontFix = data.filter(t => t.status === "wont_fix"); const _kpiBox = html`
UI Feedback
open
${_open.length}
resolved
${_resolved.length}
won't fix
${_wontFix.length}
total
${data.length}
`; const _liveEl = html`
${_ok ? `Live · updated ${_ts?.toLocaleTimeString()}` : html`Offline — run: make api`}
`; withDocHelp(_liveEl, "/docs/live-data"); injectTocTop("fb-kpi-box", _kpiBox); injectTocTop("live-indicator", _liveEl); ``` > Right-click any widget or section on any dashboard page to submit a suggestion. > Items appear here for review and can be resolved or dismissed. ## Open Suggestions ```js async function _setStatus(td_id, status) { try { const r = await fetch(`${API}/technical-debt/${td_id}`, { method: "PATCH", headers: {"Content-Type": "application/json"}, body: JSON.stringify({status}), }); if (!r.ok) alert(`Failed to update status (HTTP ${r.status})`); } catch { alert("API unreachable"); } } ``` ```js const _openItems = data.filter(t => t.status === "open" || t.status === "in_progress"); if (_openItems.length === 0) { display(html`

No open suggestions. Right-click any dashboard widget to submit one.

`); } else { display(html`
${_openItems.map(t => { const card = html`
${t.td_id ? html`${t.td_id}` : ""} ${t.status.replace("_", " ")} ${t.location ?? ""}
${t.status === "open" ? html`` : ""}
${t.description}
`; return card; })}
`); } ``` ## Resolved / Won't Fix ```js const _doneItems = data.filter(t => t.status === "resolved" || t.status === "wont_fix"); if (_doneItems.length === 0) { display(html`

Nothing resolved yet.

`); } else { display(html`
${_doneItems.map(t => html`
${t.td_id ? html`${t.td_id}` : ""} ${t.status.replace("_", " ")} ${t.location ?? ""}
${t.description}
`)}
`); } ```