From e75dcdb486f4e42cdd51d4dc0a65aafc8178dee7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 21:08:30 +0000 Subject: [PATCH] fix(admin-web): measure which table columns fit instead of guessing breakpoints Long translations (German row actions) overflowed fixed container breakpoints; tables now drop secondary columns level by level until their rows fit the panel. Charts set direction in CSS, which SVG honours. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- src/Titano.Server/Admin/web/admin.css | 44 ++++++++----------- .../Admin/web/pages/dashboard.js | 5 ++- src/Titano.Server/Admin/web/pages/jobs.js | 7 +-- src/Titano.Server/Admin/web/pages/logs.js | 5 ++- src/Titano.Server/Admin/web/pages/users.js | 8 +++- src/Titano.Server/Admin/web/ui.js | 17 ++++++- 6 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/Titano.Server/Admin/web/admin.css b/src/Titano.Server/Admin/web/admin.css index 1e48cf7e..61f8d1ad 100644 --- a/src/Titano.Server/Admin/web/admin.css +++ b/src/Titano.Server/Admin/web/admin.css @@ -120,8 +120,8 @@ input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margi .segmented .btn:last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); } .segmented .btn[aria-pressed="true"] { position: relative; } -/* Panels and tiles. Panels are size containers: tables inside drop secondary columns when the panel is narrow. */ -.panel { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-card); padding: 16px 18px; display: grid; gap: 10px; align-content: start; min-width: 0; container-type: inline-size; } +/* Panels and tiles */ +.panel { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-card); padding: 16px 18px; display: grid; gap: 10px; align-content: start; min-width: 0; } .panel.flush { padding: 0; gap: 0; overflow-x: auto; } .panel-head { display: flex; align-items: center; gap: 12px; min-width: 0; } .panel-head h2 { flex: 1; } @@ -145,7 +145,8 @@ svg.bar .track { fill: var(--stroke); } svg.bar .fill { fill: var(--accent); } svg.bar.muted .fill { fill: var(--text-faint); } [dir="rtl"] svg.bar { transform: scaleX(-1); } -svg.chart { width: 100%; height: auto; max-height: 220px; } +/* Charts keep a left-to-right axis in right-to-left pages (SVG ignores the HTML dir attribute). */ +svg.chart { width: 100%; height: auto; max-height: 220px; direction: ltr; } svg.chart .axis { stroke: var(--stroke); } svg.chart .column { fill: var(--accent); } svg.chart.sun .column { fill: var(--sun); } @@ -182,28 +183,21 @@ svg.chart .label { fill: var(--text-muted); } .table.compact .row:hover { background: none; } .table.compact.stats { grid-template-columns: minmax(0, 1fr) max-content max-content; } .table.compact.files { grid-template-columns: minmax(0, 1fr) max-content max-content max-content; } -@container (max-width: 900px) { - .table.users { grid-template-columns: minmax(140px, 1.4fr) max-content minmax(120px, 1.3fr) max-content max-content; } - .table.users .col-seen, .table.users .col-uploads { display: none; } - .table.jobs { grid-template-columns: minmax(70px, max-content) minmax(100px, 1.6fr) minmax(80px, 1fr) max-content max-content; } - .table.jobs .col-node, .table.jobs .col-created { display: none; } - .table.nodes { grid-template-columns: minmax(100px, 1fr) minmax(100px, 1.2fr) max-content max-content; } - .table.nodes .col-owner, .table.nodes .col-heartbeat { display: none; } - .table.audit { grid-template-columns: max-content minmax(70px, .8fr) minmax(90px, max-content) minmax(100px, 2fr); } - .table.audit .col-from { display: none; } -} -@container (max-width: 700px) { - .table.users { grid-template-columns: minmax(110px, 1fr) max-content max-content max-content; } - .table.users .col-quota { display: none; } -} -@container (max-width: 620px) { - .table.users { grid-template-columns: minmax(100px, 1fr) max-content max-content; } - .table.users .col-status { display: none; } -} -@container (max-width: 560px) { - .table.jobs-mini { grid-template-columns: minmax(60px, max-content) minmax(80px, 1.5fr) minmax(60px, 1fr) max-content max-content; } - .table.jobs-mini .col-node { display: none; } -} +/* Narrow panels or long translations: fitColumns() (ui.js) hides secondary columns level by level until the rows fit. */ +.table.users.fit-1 { grid-template-columns: minmax(120px, 1.4fr) max-content minmax(100px, 1.3fr) max-content max-content; } +.table.users.fit-1 .col-seen, .table.users.fit-1 .col-uploads { display: none; } +.table.users.fit-2 { grid-template-columns: minmax(110px, 1fr) max-content max-content max-content; } +.table.users.fit-2 .col-quota { display: none; } +.table.users.fit-3 { grid-template-columns: minmax(100px, 1fr) max-content max-content; } +.table.users.fit-3 .col-status { display: none; } +.table.jobs.fit-1 { grid-template-columns: minmax(70px, max-content) minmax(100px, 1.6fr) minmax(80px, 1fr) max-content max-content; } +.table.jobs.fit-1 .col-node, .table.jobs.fit-1 .col-created { display: none; } +.table.jobs-mini.fit-1 { grid-template-columns: minmax(60px, max-content) minmax(80px, 1.5fr) minmax(60px, 1fr) max-content max-content; } +.table.jobs-mini.fit-1 .col-node { display: none; } +.table.nodes.fit-1 { grid-template-columns: minmax(100px, 1fr) minmax(100px, 1.2fr) max-content max-content; } +.table.nodes.fit-1 .col-owner, .table.nodes.fit-1 .col-heartbeat { display: none; } +.table.audit.fit-1 { grid-template-columns: max-content minmax(70px, .8fr) minmax(90px, max-content) minmax(100px, 2fr); } +.table.audit.fit-1 .col-from { display: none; } .table-foot { display: flex; align-items: center; gap: 16px; padding: 10px 18px; font-size: 12px; } .table-foot a { white-space: nowrap; } .row-actions { display: flex; gap: 6px; justify-content: flex-end; } diff --git a/src/Titano.Server/Admin/web/pages/dashboard.js b/src/Titano.Server/Admin/web/pages/dashboard.js index 6707d50f..8ef19fe9 100644 --- a/src/Titano.Server/Admin/web/pages/dashboard.js +++ b/src/Titano.Server/Admin/web/pages/dashboard.js @@ -1,6 +1,6 @@ // Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs. import { t, plural, applyStrings, culture } from "../i18n.js"; -import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, columns, toast, errorText, emptyState, redraw } from "../ui.js"; +import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, columns, toast, errorText, emptyState, redraw, fitColumns } from "../ui.js"; import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js"; import { activityText } from "../audit.js"; @@ -84,7 +84,7 @@ export async function render(root, { api, setMeta, onEvent }) {

${d.activeJobs.length === 0 ? emptyState("Admin.Jobs.Empty", SCAN_BUTTON) : ` -
+
@@ -120,6 +120,7 @@ export async function render(root, { api, setMeta, onEvent }) { } })); root.querySelector("#reload")?.addEventListener("click", load); + root.querySelectorAll(".table[data-levels]").forEach(fitColumns); } onEvent((e) => { diff --git a/src/Titano.Server/Admin/web/pages/jobs.js b/src/Titano.Server/Admin/web/pages/jobs.js index 79f47492..b799ab62 100644 --- a/src/Titano.Server/Admin/web/pages/jobs.js +++ b/src/Titano.Server/Admin/web/pages/jobs.js @@ -1,6 +1,6 @@ // Jobs (BRIEF §14.8): queue and history with cancel/pause/resume/retry/priority, log tails, render nodes. import { t, plural, applyStrings } from "../i18n.js"; -import { escapeHtml, attr, formatTime, formatDateTime, toast, errorText, confirmDialog, emptyState, redraw } from "../ui.js"; +import { escapeHtml, attr, formatTime, formatDateTime, toast, errorText, confirmDialog, emptyState, redraw, fitColumns } from "../ui.js"; import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, logText } from "../jobs.js"; const FILTERS = ["all", "running", "queued", "paused", "failed", "done", "cancelled"]; @@ -18,7 +18,7 @@ export async function render(root, { api, setMeta, onEvent }) { root.innerHTML = `
${FILTERS.map((f) => ``).join("")}
-
+
@@ -29,7 +29,7 @@ export async function render(root, { api, setMeta, onEvent }) {

-
+
@@ -113,6 +113,7 @@ export async function render(root, { api, setMeta, onEvent }) { applyStrings(nodeHost); }); nodeHost.querySelectorAll("[data-forget]").forEach((b) => b.addEventListener("click", () => forget(nodes.find((n) => n.id === b.dataset.forget)))); + root.querySelectorAll(".table[data-levels]").forEach(fitColumns); } function buttons(job) { diff --git a/src/Titano.Server/Admin/web/pages/logs.js b/src/Titano.Server/Admin/web/pages/logs.js index 0d8c3d5d..db0b51e4 100644 --- a/src/Titano.Server/Admin/web/pages/logs.js +++ b/src/Titano.Server/Admin/web/pages/logs.js @@ -1,6 +1,6 @@ // Logs (BRIEF §14.8): server log tail and downloads, diagnostics bundle, sign-in log (with failed attempts), audit log. import { t, plural, applyStrings } from "../i18n.js"; -import { escapeHtml, attr, formatBytes, formatDateTime, toast, errorText, routeParams, emptyState } from "../ui.js"; +import { escapeHtml, attr, formatBytes, formatDateTime, toast, errorText, routeParams, emptyState, fitColumns } from "../ui.js"; import { actionLabel, detailText } from "../audit.js"; const VIEWS = ["server", "signins", "audit"]; @@ -82,7 +82,7 @@ export async function render(root, { api, setMeta, actions }) { } root.innerHTML = `
-
+
@@ -100,6 +100,7 @@ export async function render(root, { api, setMeta, actions }) { ${cursor ? `
` : ""}
`; applyStrings(root); + fitColumns(root.querySelector(".table.audit")); root.querySelector("#more")?.addEventListener("click", async () => { await showAudit(true); root.querySelector("#more")?.focus(); diff --git a/src/Titano.Server/Admin/web/pages/users.js b/src/Titano.Server/Admin/web/pages/users.js index 756d425e..41a8bdd8 100644 --- a/src/Titano.Server/Admin/web/pages/users.js +++ b/src/Titano.Server/Admin/web/pages/users.js @@ -1,7 +1,7 @@ // Users (mockup AdminUsers.html, BRIEF §14.8): accounts table and a side panel to create, edit and reset accounts, or to // change one's own password (a reset of one's own account would end this session and lose the temporary password). import { t, plural, applyStrings } from "../i18n.js"; -import { escapeHtml, attr, formatBytes, formatNumber, formatTime, bar, toast, confirmDialog, errorText, emptyState, markInvalid, clearInvalid, redraw, focusPlace, restoreFocus } from "../ui.js"; +import { escapeHtml, attr, formatBytes, formatNumber, formatTime, bar, toast, confirmDialog, errorText, emptyState, markInvalid, clearInvalid, redraw, focusPlace, restoreFocus, fitColumns } from "../ui.js"; import { icons } from "../icons.js"; const ROLES = ["viewer", "uploader", "editor", "admin"]; @@ -31,7 +31,7 @@ export async function render(root, { api, info, setMeta, actions }) { root.innerHTML = `
-
+
@@ -45,6 +45,7 @@ export async function render(root, { api, info, setMeta, actions }) {
`; applyStrings(root); + const table = root.querySelector(".table"); const side = root.querySelector("#side"); side.addEventListener("keydown", (e) => { if (e.key === "Escape") { @@ -92,6 +93,7 @@ export async function render(root, { api, info, setMeta, actions }) { drawTable(); search.focus(); }); + fitColumns(table); } function rowHtml(row) { @@ -159,12 +161,14 @@ export async function render(root, { api, info, setMeta, actions }) { side.hidden = false; side.innerHTML = html; applyStrings(side); + fitColumns(table); side.querySelector("#close").addEventListener("click", closeSide); } function closeSide() { side.hidden = true; side.innerHTML = ""; + fitColumns(table); if (opener) restoreFocus(opener.scope, opener.place); opener = null; } diff --git a/src/Titano.Server/Admin/web/ui.js b/src/Titano.Server/Admin/web/ui.js index a9187f4c..6aad30cc 100644 --- a/src/Titano.Server/Admin/web/ui.js +++ b/src/Titano.Server/Admin/web/ui.js @@ -67,7 +67,7 @@ export function columns(items, { label, sun = false, valueLabel = null, edgeLabe const max = Math.max(1, ...items.map((i) => i.value)); const step = width / Math.max(1, items.length); const barWidth = Math.max(2, Math.min(32, step * 0.65)); - let svg = ``; + let svg = ``; svg += ``; items.forEach((item, i) => { const h = item.value > 0 ? Math.max(2, (item.value / max) * (base - 18)) : 0; @@ -83,6 +83,21 @@ export function columns(items, { label, sun = false, valueLabel = null, edgeLabe return svg + ""; } +/** + * Hides a table's secondary columns level by level (fit-1 … fit-n in admin.css, n = data-levels) until its rows fit + * the panel: the widths depend on the language and on the side panel, so they are measured rather than guessed. + */ +export function fitColumns(table) { + const host = table.parentElement; + const levels = Number(table.dataset.levels); + for (let level = 0; level <= levels; level++) { + for (let i = 1; i <= levels; i++) table.classList.toggle(`fit-${i}`, i <= level); + if (host.scrollWidth <= host.clientWidth) return; + } +} + +window.addEventListener("resize", () => document.querySelectorAll(".table[data-levels]").forEach(fitColumns)); + /** An empty state: one sentence and one button (BRIEF §0.2). */ export function emptyState(sentenceKey, button = "") { return `
${button}
`;