/* ObsiGate — XLSX dashboard renderer (#154-A5). * * Pure string builders for the workbook dashboard inspector (named ranges, KPI * cards). Extracted from frontend/js/viewer.js; the viewer handles the fetch, * the inspector host and the range → grid link. */ import { t } from '../i18n.js'; import { escapeHtml } from '../utils.js'; export function renderDashboardLoading() { return `
…
`; } /** * @param {object} dash - payload of GET …/xlsx/dashboard * @returns {string} the inspector body markup */ export function renderDashboardHtml(dash) { const namedRanges = dash.named_ranges || []; const sheets = dash.sheets || []; const rangeRows = namedRanges.map((r) => `${escapeHtml(r.name)}${escapeHtml(r.scope || "—")}${escapeHtml(r.ref)}`, ).join(""); const kpiCards = sheets.map((s) => { const cards = (s.kpi || []).map((k) => `${escapeHtml(k.label)}${escapeHtml(String(k.value))}`, ).join(""); return `

${escapeHtml(s.name)}

${escapeHtml(t("xlsx.dashboard_stats", { cells: s.cells, rows: s.rows, cols: s.cols, formulas: s.formulas, numeric: s.numeric, }))}

${cards || "—"}
`; }).join(""); return `

${escapeHtml(t("xlsx.dashboard_title"))}

${escapeHtml(t("xlsx.dashboard_charts", { n: dash.objects?.charts ?? 0 }))} · ${escapeHtml(t("xlsx.dashboard_pivots", { n: dash.objects?.pivots ?? 0 }))}
${namedRanges.length || sheets.length ? "" : `

${escapeHtml(t("xlsx.dashboard_empty"))}

`} ${namedRanges.length ? ` ${rangeRows}
${escapeHtml(t("xlsx.dashboard_nr_name"))} ${escapeHtml(t("xlsx.dashboard_nr_scope"))} ${escapeHtml(t("xlsx.dashboard_nr_ref"))}
` : ""}
${kpiCards}

${escapeHtml(t("xlsx.dashboard_hint"))}

`; }