Merge branch 'review2-p1-panel' into claude/owner-review-2-p1

This commit is contained in:
Alby96 committed 2026-10-26 22:12:33 +01:00
commit a9c04cf79e
50 files changed
+136 -204

No files matched your search

+12 -4
View File
@@ -61,8 +61,11 @@ h2 { font-size: 14px; font-weight: 600; }
.brand strong { display: block; font-size: 14px; }
.brand span { display: block; font-size: 11px; color: var(--text-muted); }
.brand.large img { width: 40px; height: 40px; }
.brand.large h2 { font-size: 18px; }
.nav { display: grid; gap: 2px; }
.brand.large strong { font-size: 18px; }
/* The menu fills the sidebar: its pages from the top, Settings docked at its foot above the account (owner review 2). */
.nav { flex: 1 0 auto; display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: grid; gap: 2px; }
.nav-group.bottom { margin-block: auto 8px; padding-block-start: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--card-hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-selected); color: var(--accent); font-weight: 600; }
@@ -264,7 +267,10 @@ dialog.dialog p { margin: 0; color: var(--text-muted); }
.toast { width: 420px; max-width: calc(100vw - 48px); padding: 12px 14px; color: var(--text); background: var(--card); border: 1px solid var(--stroke); border-inline-start: 3px solid var(--accent); border-radius: var(--radius-card); box-shadow: 0 4px 16px var(--shadow); }
.toast.error { border-inline-start-color: var(--error); }
/* About */
/* About: the last group of Settings (owner review 2); #/about scrolls to it below the sticky header and focuses its heading. */
.about { scroll-margin-block-start: 84px; }
.about h2:focus { outline: none; }
.about .brand { padding: 0; }
.about dl { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.about dt { color: var(--text-muted); }
.about dd { margin: 0; overflow-wrap: anywhere; }
@@ -291,7 +297,9 @@ dialog.dialog p { margin: 0; color: var(--text-muted); }
.sidebar { flex-direction: row; overflow-x: auto; padding: 8px; position: static; height: auto; border-bottom: 1px solid var(--stroke); }
.main { border-inline-start: 0; }
.sidebar .brand, .sidebar .user, .sidebar-toggle { display: none; }
.nav { display: flex; gap: 4px; }
.nav { flex-direction: row; gap: 4px; }
.nav-group { display: flex; gap: 4px; }
.nav-group.bottom { margin: 0; margin-inline-start: auto; padding: 0; }
.nav a > span:not(.badge) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.header { position: static; flex-wrap: wrap; padding-block: 10px; }
.tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+14 -4
View File
@@ -5,7 +5,12 @@ import { icons } from "./icons.js";
import { escapeHtml, attr, errorText, nativeName, formatNumber, fitColumns } from "./ui.js";
const app = document.getElementById("app");
const pages = ["dashboard", "users", "archive", "jobs", "settings", "logs", "about"];
// The menu: its pages from the top, then the ones docked at its foot above the account (owner review 2).
const topPages = ["dashboard", "users", "archive", "jobs", "logs"];
const bottomPages = ["settings"];
const pages = [...topPages, ...bottomPages];
/** Routes of old bookmarks and where they open now: About is the last group of Settings (owner review 2). */
const MOVED = { about: "settings?group=about" };
const THEME_KEY = "chronos.admin.theme";
const SIDEBAR_KEY = "chronos.admin.sidebar";
/** The narrow layout of admin.css, where the menu is the top bar and does not collapse. */
@@ -43,7 +48,12 @@ async function start() {
}
function currentPage() {
const p = location.hash.replace(/^#\/?/, "").split("?")[0];
let p = location.hash.replace(/^#\/?/, "").split("?")[0];
if (Object.hasOwn(MOVED, p)) {
// The address shows the new route; replaceState fires no hashchange.
history.replaceState(null, "", `#/${MOVED[p]}`);
p = MOVED[p].split("?")[0];
}
return pages.includes(p) ? p : "dashboard";
}
@@ -136,7 +146,7 @@ function renderPasswordChange() {
}
function renderShell(page, focus) {
const nav = pages.map((p) => `
const links = (group) => group.map((p) => `
<a href="#/${p}" ${p === page ? 'aria-current="page"' : ""} data-i18n-title="Admin.Nav.${cap(p)}.Tip">${icons[p]}<span data-i18n="Admin.Nav.${cap(p)}"></span>
<span class="sr-only" id="badge-text-${p}"></span><span class="badge" id="badge-${p}" aria-hidden="true" hidden></span></a>`).join("");
const user = api.user();
@@ -146,7 +156,7 @@ function renderShell(page, focus) {
<aside class="sidebar">
<button class="btn icon sidebar-toggle" id="sidebar-toggle">${icons.menu}</button>
${brand()}
<nav class="nav">${nav}</nav>
<nav class="nav"><div class="nav-group">${links(topPages)}</div><div class="nav-group bottom">${links(bottomPages)}</div></nav>
<div class="user">
<div class="avatar" aria-hidden="true">${escapeHtml(user.username.slice(0, 1).toUpperCase())}</div>
<div class="who"><strong class="ellipsis" dir="auto" title="${attr(user.username)}">${escapeHtml(user.username)}</strong><span data-i18n="Admin.Role.Admin"></span></div>
+2 -3
View File
@@ -1,12 +1,11 @@
// Generated from branding/ui-icons/icons.py (same 16-px set as the desktop apps).
// Generated by branding/ui-icons/icons.py (same 16-px set as the desktop apps). Do not edit by hand.
export const icons = {
dashboard: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M2.5 1.5 H6.0 A1 1 0 0 1 7.0 2.5 V6.0 A1 1 0 0 1 6.0 7.0 H2.5 A1 1 0 0 1 1.5 6.0 V2.5 A1 1 0 0 1 2.5 1.5 ZM10 1.5 H13.5 A1 1 0 0 1 14.5 2.5 V6.0 A1 1 0 0 1 13.5 7.0 H10 A1 1 0 0 1 9 6.0 V2.5 A1 1 0 0 1 10 1.5 ZM2.5 9 H6.0 A1 1 0 0 1 7.0 10 V13.5 A1 1 0 0 1 6.0 14.5 H2.5 A1 1 0 0 1 1.5 13.5 V10 A1 1 0 0 1 2.5 9 ZM10 9 H13.5 A1 1 0 0 1 14.5 10 V13.5 A1 1 0 0 1 13.5 14.5 H10 A1 1 0 0 1 9 13.5 V10 A1 1 0 0 1 10 9 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
users: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M5 5 A3 3 0 1 0 11 5 A3 3 0 1 0 5 5 Z M2.5 14 A5.5 5.5 0 0 1 13.5 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
archive: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M2 4.5 H14 V13.5 H2 Z M2 2 H14 V4.5 H2 Z M6 8 H10" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
jobs: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M3 8 H13 M3 4 H13 M3 12 H9" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
settings: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M5.8 8 A2.2 2.2 0 1 0 10.2 8 A2.2 2.2 0 1 0 5.8 8 Z M8 1.5 V3.5 M8 12.5 V14.5 M1.5 8 H3.5 M12.5 8 H14.5 M3.4 3.4 L4.8 4.8 M11.2 11.2 L12.6 12.6 M3.4 12.6 L4.8 11.2 M11.2 4.8 L12.6 3.4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
settings: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M7.15 3.48 L7.4 1.53 A6.5 6.5 0 0 1 8.6 1.53 L8.85 3.48 A4.6 4.6 0 0 1 10.6 4.2 L12.15 3 A6.5 6.5 0 0 1 13 3.85 L11.8 5.4 A4.6 4.6 0 0 1 12.52 7.15 L14.47 7.4 A6.5 6.5 0 0 1 14.47 8.6 L12.52 8.85 A4.6 4.6 0 0 1 11.8 10.6 L13 12.15 A6.5 6.5 0 0 1 12.15 13 L10.6 11.8 A4.6 4.6 0 0 1 8.85 12.52 L8.6 14.47 A6.5 6.5 0 0 1 7.4 14.47 L7.15 12.52 A4.6 4.6 0 0 1 5.4 11.8 L3.85 13 A6.5 6.5 0 0 1 3 12.15 L4.2 10.6 A4.6 4.6 0 0 1 3.48 8.85 L1.53 8.6 A6.5 6.5 0 0 1 1.53 7.4 L3.48 7.15 A4.6 4.6 0 0 1 4.2 5.4 L3 3.85 A6.5 6.5 0 0 1 3.85 3 L5.4 4.2 A4.6 4.6 0 0 1 7.15 3.48 Z M6.3 8 A1.7 1.7 0 1 0 9.7 8 A1.7 1.7 0 1 0 6.3 8 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
logs: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M3.5 1.5 H9.5 L12.5 4.5 V14.5 H3.5 Z M5.5 7 H10.5 M5.5 9.5 H10.5 M5.5 12 H8.5" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
about: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M8 7 V11 M8 4.8 V5.2" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
menu: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M2.5 4 H13.5 M2.5 8 H13.5 M2.5 12 H13.5" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
power: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 1.8 V7.5 M11.54 4.59 A5.5 5.5 0 1 1 4.46 4.59" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
moon: `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M9.5 1.8 A6.5 6.5 0 1 0 14.2 11.2 A5.5 5.5 0 0 1 9.5 1.8 Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,
@@ -1,22 +0,0 @@
// About: version, API, database, uptime and the certificate fingerprint clients are asked to trust.
import { applyStrings } from "../i18n.js";
import { escapeHtml, formatDuration, fingerprint } from "../ui.js";
export async function render(root, { api, info, setMeta }) {
setMeta("");
const dashboard = await api.get("/api/v1/server/dashboard").catch(() => null);
const rows = [
["Admin.About.Name", `<span dir="auto">${escapeHtml(info?.name ?? "—")}</span>`],
["Admin.About.Version", `<span class="num" dir="ltr">${escapeHtml(info?.version ?? "—")}</span>`],
["Admin.About.Api", `<span class="num">${escapeHtml(info?.apiVersion ?? "—")}</span>`],
["Admin.About.Database", `<span dir="ltr">${escapeHtml(dashboard?.database ?? "—")}</span>`],
["Admin.About.Uptime", escapeHtml(dashboard ? formatDuration(dashboard.uptimeSeconds) : "—")],
["Admin.About.Fingerprint", fingerprint(info?.tlsFingerprint)],
];
root.innerHTML = `
<section class="panel about" aria-labelledby="about-title">
<div class="brand large"><img src="favicon.svg" alt=""><h2 id="about-title" data-i18n="Admin.About.Title"></h2></div>
<dl>${rows.map(([key, value]) => `<dt data-i18n="${key}"></dt><dd>${value}</dd>`).join("")}</dl>
</section>`;
applyStrings(root);
}
+34 -3
View File
@@ -1,8 +1,9 @@
// Settings (BRIEF §14.8): server name, ports, TLS, discovery, jobs, limits, language, retention. Values fixed by environment
// variables are read-only here; ports, TLS, chunk size and job history apply at the next restart. Jobs run one at a time
// (owner review 1): the parallelism (photos at once) and the priority queue apply at once.
// (owner review 1): the parallelism (photos at once) and the priority queue apply at once. About (version, API, database,
// uptime) is the last group, read-only (owner review 2); #/about opens here on it.
import { t, applyStrings, languages } from "../i18n.js";
import { escapeHtml, attr, toast, errorText, nativeName, fingerprint, markInvalid, clearInvalid, invalidText, escapeReverts, PROXY_WARNING } from "../ui.js";
import { escapeHtml, attr, toast, errorText, nativeName, fingerprint, formatDuration, markInvalid, clearInvalid, invalidText, escapeReverts, routeParams, PROXY_WARNING } from "../ui.js";
import { kindLabel } from "../jobs.js";
/** Setting → environment variable that can fix it (BRIEF §14.9). */
@@ -20,6 +21,8 @@ const MB = 1e6;
const MIB = 1024 * 1024;
export async function render(root, { api, info, setMeta, actions }) {
// Only the About group's database and uptime: without them those rows show a dash.
const status = api.get("/api/v1/server/dashboard").then((d) => ({ ...d, at: Date.now() }), () => null);
let settings;
try {
settings = await api.get("/api/v1/server/settings");
@@ -27,6 +30,7 @@ export async function render(root, { api, info, setMeta, actions }) {
root.innerHTML = `<div class="panel empty">${escapeHtml(errorText(err))}</div>`;
return;
}
const dashboard = await status;
setMeta("");
// In the header, like the other pages' main action, so toasts never cover it.
actions.innerHTML = `<button class="btn primary" type="submit" form="settings-form" data-i18n="Admin.Common.Save" data-i18n-title="Admin.Common.Save.Tip"></button>`;
@@ -78,7 +82,8 @@ export async function render(root, { api, info, setMeta, actions }) {
${number("uploadRetentionHours", settings.uploadRetentionHours, 'min="1" max="8760"')}
${number("jobHistoryDays", settings.jobHistoryDays, 'min="1" max="3650"')}
</section>
</form>`;
</form>
${about()}`;
applyStrings(root);
const form = root.querySelector("form");
escapeReverts(form);
@@ -89,6 +94,26 @@ export async function render(root, { api, info, setMeta, actions }) {
form.elements.priorityQueue.addEventListener("change", () => { root.querySelector(".priorities").hidden = !form.elements.priorityQueue.checked; });
}
/**
* About, outside the form: nothing to save. The server name and the certificate fingerprint are left to the Server
* and Network groups above; the uptime counts on from when it was read.
*/
function about() {
const uptime = dashboard ? formatDuration(dashboard.uptimeSeconds + (Date.now() - dashboard.at) / 1000) : "—";
const rows = [
["Admin.About.Version", `<span class="num" dir="ltr">${escapeHtml(info?.version ?? "—")}</span>`],
["Admin.About.Api", `<span class="num">${escapeHtml(info?.apiVersion ?? "—")}</span>`],
["Admin.About.Database", `<span dir="ltr">${escapeHtml(dashboard?.database ?? "—")}</span>`],
["Admin.About.Uptime", escapeHtml(uptime)],
];
return `
<section class="panel about" aria-labelledby="about-title">
<h2 id="about-title" tabindex="-1" data-i18n="Admin.Settings.About"></h2>
<div class="brand large"><img src="favicon.svg" alt=""><strong data-i18n="Admin.About.Title"></strong></div>
<dl>${rows.map(([key, value]) => `<dt data-i18n="${key}"></dt><dd>${value}</dd>`).join("")}</dl>
</section>`;
}
/** The certificate and key files are used only in Own certificate mode; elsewhere they are off and say so. */
function pemFiles(form) {
const pem = form.elements.tlsMode.value === "pem";
@@ -143,6 +168,12 @@ export async function render(root, { api, info, setMeta, actions }) {
}
draw();
// Once: the route drops the group, so a later redraw (a language change) leaves the focus where it is.
if (routeParams().get("group") === "about") {
history.replaceState(null, "", "#/settings");
root.querySelector(".about").scrollIntoView({ block: "start" });
root.querySelector("#about-title").focus({ preventScroll: true });
}
}
function cap(s) {
+1 -1
View File
@@ -78,7 +78,7 @@
<ui:IconData x:Key="Icon.Search" Stroke="M2.5 7 A4.5 4.5 0 1 0 11.5 7 A4.5 4.5 0 1 0 2.5 7 Z M10.4 10.4 L14 14" />
<ui:IconData x:Key="Icon.Sequence" Stroke="M2 12.5 L11.5 3 L13 4.5 L3.5 14 H2 Z" />
<ui:IconData x:Key="Icon.Server" Stroke="M4.5 12.5 A3 3 0 0 1 4.2 6.5 A4 4 0 0 1 11.9 5.5 A3.5 3.5 0 0 1 12.2 12.5 Z" />
<ui:IconData x:Key="Icon.Settings" Stroke="M5.8 8 A2.2 2.2 0 1 0 10.2 8 A2.2 2.2 0 1 0 5.8 8 Z M8 1.5 V3.5 M8 12.5 V14.5 M1.5 8 H3.5 M12.5 8 H14.5 M3.4 3.4 L4.8 4.8 M11.2 11.2 L12.6 12.6 M3.4 12.6 L4.8 11.2 M11.2 4.8 L12.6 3.4" />
<ui:IconData x:Key="Icon.Settings" Stroke="M7.15 3.48 L7.4 1.53 A6.5 6.5 0 0 1 8.6 1.53 L8.85 3.48 A4.6 4.6 0 0 1 10.6 4.2 L12.15 3 A6.5 6.5 0 0 1 13 3.85 L11.8 5.4 A4.6 4.6 0 0 1 12.52 7.15 L14.47 7.4 A6.5 6.5 0 0 1 14.47 8.6 L12.52 8.85 A4.6 4.6 0 0 1 11.8 10.6 L13 12.15 A6.5 6.5 0 0 1 12.15 13 L10.6 11.8 A4.6 4.6 0 0 1 8.85 12.52 L8.6 14.47 A6.5 6.5 0 0 1 7.4 14.47 L7.15 12.52 A4.6 4.6 0 0 1 5.4 11.8 L3.85 13 A6.5 6.5 0 0 1 3 12.15 L4.2 10.6 A4.6 4.6 0 0 1 3.48 8.85 L1.53 8.6 A6.5 6.5 0 0 1 1.53 7.4 L3.48 7.15 A4.6 4.6 0 0 1 4.2 5.4 L3 3.85 A6.5 6.5 0 0 1 3.85 3 L5.4 4.2 A4.6 4.6 0 0 1 7.15 3.48 Z M6.3 8 A1.7 1.7 0 1 0 9.7 8 A1.7 1.7 0 1 0 6.3 8 Z" />
<ui:IconData x:Key="Icon.Sort" Stroke="M5 2.5 V13.5 M2.5 11 L5 13.5 L7.5 11 M11 13.5 V2.5 M8.5 5 L11 2.5 L13.5 5" />
<ui:IconData x:Key="Icon.Spline" Stroke="M2 13 C5 13 5 3 8 8 C11 13 11 3 14 3" Fill="M0.8 13 A1.2 1.2 0 1 0 3.2 13 A1.2 1.2 0 1 0 0.8 13 ZM12.8 3 A1.2 1.2 0 1 0 15.2 3 A1.2 1.2 0 1 0 12.8 3 Z" />
<ui:IconData x:Key="Icon.Stack" Stroke="M8 1.8 L14.5 5.2 L8 8.6 L1.5 5.2 Z M1.5 8.2 L8 11.6 L14.5 8.2 M1.5 11 L8 14.4 L14.5 11" />