refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
1 parent
c99842cc86
commit
f2b58522b9
1801 files changed
+11804
-10676
No files matched your search
@@ -0,0 +1,272 @@
|
||||
// Small DOM and formatting helpers shared by the admin pages. No inline styles: the panel runs under a strict CSP.
|
||||
import { t, culture } from "./i18n.js";
|
||||
|
||||
export function escapeHtml(s) {
|
||||
return String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
||||
}
|
||||
|
||||
/** Escaped attribute value for title="…" tooltips. */
|
||||
export const attr = escapeHtml;
|
||||
|
||||
export function formatNumber(n) {
|
||||
return new Intl.NumberFormat(culture()).format(n ?? 0);
|
||||
}
|
||||
|
||||
/** 9.4 TB, 610 GB … (decimal units, like disk vendors and the desktop client). */
|
||||
export function formatBytes(bytes) {
|
||||
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
||||
let value = Number(bytes ?? 0);
|
||||
let unit = 0;
|
||||
while (value >= 1000 && unit < units.length - 1) {
|
||||
value /= 1000;
|
||||
unit++;
|
||||
}
|
||||
const digits = value >= 100 || unit === 0 ? 0 : 1;
|
||||
return `${new Intl.NumberFormat(culture(), { maximumFractionDigits: digits }).format(value)} ${units[unit]}`;
|
||||
}
|
||||
|
||||
export function formatTime(iso) {
|
||||
if (!iso) return "—";
|
||||
const date = new Date(iso);
|
||||
const sameDay = new Date().toDateString() === date.toDateString();
|
||||
return new Intl.DateTimeFormat(culture(), sameDay ? { timeStyle: "short" } : { dateStyle: "medium" }).format(date);
|
||||
}
|
||||
|
||||
export function formatDateTime(iso) {
|
||||
return iso ? new Intl.DateTimeFormat(culture(), { dateStyle: "short", timeStyle: "medium" }).format(new Date(iso)) : "—";
|
||||
}
|
||||
|
||||
export function formatDuration(seconds) {
|
||||
const s = Math.max(0, Math.round(seconds ?? 0));
|
||||
if (s >= 86400) return t("Common.Duration.Days", Math.floor(s / 86400), Math.floor((s % 86400) / 3600));
|
||||
if (s >= 3600) return t("Common.Duration.Hours", Math.floor(s / 3600), Math.floor((s % 3600) / 60));
|
||||
if (s >= 60) return t("Common.Duration.Minutes", Math.floor(s / 60));
|
||||
return t("Common.Duration.Seconds", s);
|
||||
}
|
||||
|
||||
/** A certificate fingerprint that wraps only between its byte pairs, always left to right. */
|
||||
export function fingerprint(value) {
|
||||
return value ? `<span class="fingerprint" dir="ltr">${String(value).split(":").map(escapeHtml).join(":<wbr>")}</span>` : "—";
|
||||
}
|
||||
|
||||
/** 6 px progress bar drawn as SVG (attributes, not inline styles). */
|
||||
export function bar(fraction, muted = false) {
|
||||
const width = Math.max(0, Math.min(100, Math.round((fraction ?? 0) * 100)));
|
||||
return `<svg class="bar${muted ? " muted" : ""}" viewBox="0 0 100 6" preserveAspectRatio="none" aria-hidden="true">` +
|
||||
`<rect class="track" width="100" height="6" rx="3"/><rect class="fill" width="${width}" height="6" rx="3"/></svg>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Column chart named by label: values with labels under the bars and, when given, the value above each bar. Bars use
|
||||
* the accent colour, or the sun colour for upload activity. With edgeLabels the first and last labels align with the
|
||||
* chart edges (a time axis labelled only at its ends). Charts keep their left-to-right axis in right-to-left pages.
|
||||
*/
|
||||
export function columns(items, { label, sun = false, valueLabel = null, edgeLabels = false, height = 190 } = {}) {
|
||||
const width = 400;
|
||||
const base = height - 30;
|
||||
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 = `<svg class="chart${sun ? " sun" : ""}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${attr(label)}">`;
|
||||
svg += `<line class="axis" x1="0" y1="${base}" x2="${width}" y2="${base}"/>`;
|
||||
items.forEach((item, i) => {
|
||||
const h = item.value > 0 ? Math.max(2, (item.value / max) * (base - 18)) : 0;
|
||||
const x = i * step + (step - barWidth) / 2;
|
||||
const middle = (x + barWidth / 2).toFixed(1);
|
||||
svg += `<rect class="column" x="${x.toFixed(1)}" y="${(base - h).toFixed(1)}" width="${barWidth.toFixed(1)}" height="${h.toFixed(1)}" rx="2"><title>${escapeHtml(item.title ?? "")}</title></rect>`;
|
||||
if (valueLabel) svg += `<text class="value" x="${middle}" y="${(base - h - 5).toFixed(1)}">${escapeHtml(valueLabel(item))}</text>`;
|
||||
if (!item.label) return;
|
||||
const edge = !edgeLabels ? "" : i === 0 ? "start" : i === items.length - 1 ? "end" : "";
|
||||
const at = edge === "start" ? 0 : edge === "end" ? width : middle;
|
||||
svg += `<text class="label${edge ? " " + edge : ""}" x="${at}" y="${base + 16}">${escapeHtml(item.label)}</text>`;
|
||||
});
|
||||
return svg + "</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 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 (table.scrollWidth <= table.clientWidth) return;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("resize", () => document.querySelectorAll(".table[data-levels]").forEach(fitColumns));
|
||||
|
||||
/** Chip of the Dashboard and Settings: TLS mode is proxy, but this page did not come through a trusted proxy over HTTPS (BRIEF §14.2). */
|
||||
export const PROXY_WARNING = `<span class="chip warn" data-i18n="Admin.Settings.ProxyBypassed" data-i18n-title="Admin.Settings.ProxyBypassed.Tip"></span>`;
|
||||
|
||||
/** An empty state: one sentence and one button (BRIEF §0.2). */
|
||||
export function emptyState(sentenceKey, button = "") {
|
||||
return `<div class="empty"><span data-i18n="${attr(sentenceKey)}"></span>${button}</div>`;
|
||||
}
|
||||
|
||||
/** Shows a toast at the bottom (inline end) for 8 s (hover pauses). */
|
||||
export function toast(message, isError = false) {
|
||||
const host = document.getElementById("toasts") ?? document.body.appendChild(Object.assign(document.createElement("div"), { id: "toasts" }));
|
||||
const item = document.createElement("div");
|
||||
item.className = `toast${isError ? " error" : ""}`;
|
||||
item.setAttribute("role", isError ? "alert" : "status");
|
||||
item.textContent = message;
|
||||
host.appendChild(item);
|
||||
let remaining = 8000;
|
||||
let started = Date.now();
|
||||
let timer = setTimeout(() => item.remove(), remaining);
|
||||
item.addEventListener("mouseenter", () => {
|
||||
clearTimeout(timer);
|
||||
remaining -= Date.now() - started;
|
||||
});
|
||||
item.addEventListener("mouseleave", () => {
|
||||
started = Date.now();
|
||||
timer = setTimeout(() => item.remove(), remaining);
|
||||
});
|
||||
}
|
||||
|
||||
let dialogs = 0;
|
||||
|
||||
/**
|
||||
* Two-button confirmation dialog (safe action left and default, Esc keeps). Resolves true when the destructive action
|
||||
* is chosen; with `typed`, that button stays disabled until the text is typed into the labelled field.
|
||||
*/
|
||||
export function confirmDialog({ title, body, confirm, confirmTip, cancel, cancelTip, typed }) {
|
||||
return new Promise((resolve) => {
|
||||
const id = `dialog-${++dialogs}`;
|
||||
const dialog = document.createElement("dialog");
|
||||
dialog.className = "dialog";
|
||||
dialog.setAttribute("aria-labelledby", `${id}-title`);
|
||||
if (body) dialog.setAttribute("aria-describedby", `${id}-body`);
|
||||
dialog.innerHTML = `
|
||||
<form method="dialog">
|
||||
<h2 id="${id}-title" dir="auto">${escapeHtml(title)}</h2>
|
||||
${body ? `<p id="${id}-body">${escapeHtml(body)}</p>` : ""}
|
||||
${typed ? `<label class="field-label"><span>${escapeHtml(t("Admin.Common.TypeToConfirm", typed))}</span>
|
||||
<input class="input" name="typed" autocomplete="off" spellcheck="false" dir="auto" title="${attr(t("Admin.Common.TypeToConfirm.Tip"))}"></label>` : ""}
|
||||
<div class="buttons">
|
||||
<button class="btn" value="cancel" title="${attr(cancelTip)}" autofocus>${escapeHtml(cancel)}</button>
|
||||
<button class="btn destructive" value="ok" title="${attr(typed ? t("Admin.Common.TypeFirst.Tip") : confirmTip)}" ${typed ? "disabled" : ""}>${escapeHtml(confirm)}</button>
|
||||
</div>
|
||||
</form>`;
|
||||
document.body.appendChild(dialog);
|
||||
const ok = dialog.querySelector('button[value="ok"]');
|
||||
dialog.querySelector('input[name="typed"]')?.addEventListener("input", (e) => {
|
||||
ok.disabled = e.target.value !== typed;
|
||||
ok.title = ok.disabled ? t("Admin.Common.TypeFirst.Tip") : confirmTip;
|
||||
});
|
||||
dialog.addEventListener("close", () => {
|
||||
resolve(dialog.returnValue === "ok");
|
||||
dialog.remove();
|
||||
});
|
||||
dialog.showModal();
|
||||
});
|
||||
}
|
||||
|
||||
/** The localised message of an API failure, or the generic one when the server was not reached. */
|
||||
export function errorText(err) {
|
||||
return err?.message && err.status ? err.message : t("Admin.Error.Unreachable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a form field invalid (DESIGN §4): error border and the message as its tooltip, until the value changes and
|
||||
* the field's own tooltip comes back.
|
||||
*/
|
||||
export function markInvalid(field, message) {
|
||||
if (field.getAttribute("aria-invalid") !== "true") field.dataset.tip = field.title;
|
||||
field.setAttribute("aria-invalid", "true");
|
||||
field.title = message;
|
||||
field.addEventListener("input", () => clearInvalid(field), { once: true });
|
||||
}
|
||||
|
||||
/** "The value of Folder template is not valid; …": a field the server refused, named by its label. */
|
||||
export function invalidText(field) {
|
||||
return t("Admin.Common.Invalid", field.closest("label")?.querySelector("span")?.textContent ?? field.name);
|
||||
}
|
||||
|
||||
export function clearInvalid(field) {
|
||||
if (field.getAttribute("aria-invalid") !== "true") return;
|
||||
field.removeAttribute("aria-invalid");
|
||||
field.title = field.dataset.tip ?? "";
|
||||
}
|
||||
|
||||
/** Esc in a field of the form puts back the value the page was drawn with (DESIGN §4: Esc reverts). */
|
||||
export function escapeReverts(form) {
|
||||
form.addEventListener("keydown", (e) => {
|
||||
const field = e.target;
|
||||
if (e.key !== "Escape" || !(field instanceof HTMLInputElement || field instanceof HTMLSelectElement) || field.type === "search") return;
|
||||
const checkable = field.type === "checkbox" || field.type === "radio";
|
||||
const before = checkable ? field.checked : field.value;
|
||||
if (field instanceof HTMLSelectElement) {
|
||||
[...field.options].forEach((o) => {
|
||||
o.selected = o.defaultSelected;
|
||||
});
|
||||
} else if (field.type === "checkbox" || field.type === "radio") {
|
||||
field.checked = field.defaultChecked;
|
||||
} else {
|
||||
field.value = field.defaultValue;
|
||||
}
|
||||
clearInvalid(field);
|
||||
// What follows the value (the certificate files of a TLS mode, the levels of the priority queue) follows it back.
|
||||
if ((checkable ? field.checked : field.value) !== before) field.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
});
|
||||
}
|
||||
|
||||
const FOCUSABLE = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex='-1'])";
|
||||
|
||||
/**
|
||||
* Where the keyboard focus is inside root, in terms that survive a re-render: the row (data-key), the control
|
||||
* (data-act, data-toggle, id or name) and positions as fallbacks.
|
||||
*/
|
||||
export function focusPlace(root) {
|
||||
const el = document.activeElement;
|
||||
if (!el || el === document.body || !root.contains(el)) return null;
|
||||
const row = el.closest("[data-key]");
|
||||
const rows = [...root.querySelectorAll("[data-key]")];
|
||||
return { row: row?.dataset.key ?? null, rowIndex: rows.indexOf(row), control: controlKey(el), index: [...(row ?? root).querySelectorAll(FOCUSABLE)].indexOf(el) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Focuses the same control after a re-render, else the control at the same place in the same (or same-position) row,
|
||||
* else the first control left (an empty state's button).
|
||||
*/
|
||||
export function restoreFocus(root, place) {
|
||||
if (!place) return;
|
||||
let scope = root;
|
||||
let index = place.index;
|
||||
if (place.row !== null) {
|
||||
const rows = [...root.querySelectorAll("[data-key]")];
|
||||
const row = rows.find((r) => r.dataset.key === place.row) ?? rows[Math.min(place.rowIndex, rows.length - 1)];
|
||||
if (row) scope = row;
|
||||
else index = 0;
|
||||
}
|
||||
const controls = [...scope.querySelectorAll(FOCUSABLE)];
|
||||
(controls.find((c) => controlKey(c) === place.control) ?? controls[Math.min(Math.max(index, 0), controls.length - 1)])?.focus();
|
||||
}
|
||||
|
||||
/** Redraws with draw() and puts the keyboard focus back where it was. */
|
||||
export function redraw(root, draw) {
|
||||
const place = focusPlace(root);
|
||||
draw();
|
||||
restoreFocus(root, place);
|
||||
}
|
||||
|
||||
function controlKey(el) {
|
||||
return el.dataset.act ?? el.dataset.toggle ?? el.dataset.cancel ?? el.dataset.forget ?? (el.id || el.name || "");
|
||||
}
|
||||
|
||||
/** Query parameters of the hash route (#/logs?view=signins). */
|
||||
export function routeParams() {
|
||||
return new URLSearchParams(location.hash.split("?")[1] ?? "");
|
||||
}
|
||||
|
||||
/** A language's own name ("Italiano"), for language menus. */
|
||||
export function nativeName(code) {
|
||||
try {
|
||||
const name = new Intl.DisplayNames([code], { type: "language" }).of(code) ?? code;
|
||||
return name.charAt(0).toLocaleUpperCase(code) + name.slice(1);
|
||||
} catch {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user