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,325 @@
|
||||
// Chronos Server admin panel — vanilla ES modules, no build step (BRIEF §14.8).
|
||||
import { api, ApiFailure } from "./api.js";
|
||||
import { t, plural, loadStrings, applyStrings, setLanguage, languages, culture } from "./i18n.js";
|
||||
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"];
|
||||
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. */
|
||||
const NARROW = window.matchMedia("(max-width: 900px)");
|
||||
|
||||
let info = null;
|
||||
let events = null;
|
||||
const listeners = new Set();
|
||||
/** The sidebar choice made on this page, kept here too: a browser that refuses storage still keeps it across pages. */
|
||||
let sidebarChoice = null;
|
||||
|
||||
applyTheme(storedTheme());
|
||||
|
||||
async function start() {
|
||||
await loadStrings();
|
||||
info = await api.get("/api/v1/server/info").catch(() => null);
|
||||
await api.resume();
|
||||
window.addEventListener("hashchange", () => render("title"));
|
||||
// The menu's names or its icons alone, as on the desktop (owner review 1). A layout whose B key types another letter
|
||||
// (Cyrillic, Greek, Hebrew, Arabic) is matched on the physical key, so the tooltips' Ctrl+B holds in every language. In the
|
||||
// narrow layout the menu is the top bar with no toggle: the browser keeps its own Ctrl+B there.
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (!(e.ctrlKey || e.metaKey) || e.shiftKey || e.altKey || e.repeat || !app.querySelector(".shell") || NARROW.matches) return;
|
||||
const key = e.key.toLowerCase();
|
||||
if (key !== "b" && !(e.code === "KeyB" && !/^[a-z]$/.test(key))) return;
|
||||
e.preventDefault();
|
||||
toggleSidebar();
|
||||
});
|
||||
window.addEventListener("chronos:signed-out", () => {
|
||||
events?.stop();
|
||||
events = null;
|
||||
render();
|
||||
});
|
||||
render();
|
||||
}
|
||||
|
||||
function currentPage() {
|
||||
const p = location.hash.replace(/^#\/?/, "").split("?")[0];
|
||||
return pages.includes(p) ? p : "dashboard";
|
||||
}
|
||||
|
||||
/** Draws the page for the session state; focus names the shell element that gets the keyboard focus. */
|
||||
function render(focus = null) {
|
||||
const user = api.user();
|
||||
if (!user) return renderLogin();
|
||||
if (user.mustChangePassword) return renderPasswordChange();
|
||||
renderShell(currentPage(), focus);
|
||||
}
|
||||
|
||||
function brand() {
|
||||
return `<div class="brand"><img src="favicon.svg" alt=""><div><strong>Chronos Server</strong><span class="num">${escapeHtml(info?.name ?? "")} · v${escapeHtml(info?.version ?? "")}</span></div></div>`;
|
||||
}
|
||||
|
||||
function renderLogin(message = "") {
|
||||
document.title = `${t("Admin.Login.SignIn")} · Chronos Server`;
|
||||
app.innerHTML = `
|
||||
<main class="login">
|
||||
<form novalidate>
|
||||
${brand()}
|
||||
<label><span data-i18n="Admin.Login.User"></span><input class="input" name="username" autocomplete="username" required dir="auto" data-i18n-title="Admin.Login.User.Tip"></label>
|
||||
<label><span data-i18n="Admin.Login.Password"></span><input class="input" name="password" type="password" autocomplete="current-password" required data-i18n-title="Admin.Login.Password.Tip"></label>
|
||||
<div class="error" role="alert">${escapeHtml(message)}</div>
|
||||
<button class="btn primary" type="submit" data-i18n="Admin.Login.SignIn" data-i18n-title="Admin.Login.SignIn.Tip"></button>
|
||||
</form>
|
||||
</main>`;
|
||||
applyStrings(app);
|
||||
const form = app.querySelector("form");
|
||||
const error = form.querySelector(".error");
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
error.textContent = "";
|
||||
const data = new FormData(form);
|
||||
try {
|
||||
const r = await api.signIn(String(data.get("username")), String(data.get("password")));
|
||||
if (r.user.role !== "admin") {
|
||||
await api.signOut();
|
||||
error.textContent = t("Admin.Login.NotAdmin");
|
||||
return;
|
||||
}
|
||||
render();
|
||||
} catch (err) {
|
||||
error.textContent = err instanceof ApiFailure && err.status === 401 ? t("Admin.Login.Failed") : errorText(err);
|
||||
}
|
||||
});
|
||||
form.querySelector("input").focus();
|
||||
}
|
||||
|
||||
function renderPasswordChange() {
|
||||
document.title = `${t("Admin.Password.Title")} · Chronos Server`;
|
||||
app.innerHTML = `
|
||||
<main class="login">
|
||||
<form novalidate>
|
||||
${brand()}
|
||||
<h1 data-i18n="Admin.Password.Title"></h1>
|
||||
<label><span data-i18n="Admin.Password.Current"></span><input class="input" name="current" type="password" autocomplete="current-password" required data-i18n-title="Admin.Password.Current.Tip"></label>
|
||||
<label><span data-i18n="Admin.Password.New"></span><input class="input" name="next" type="password" autocomplete="new-password" required data-i18n-title="Admin.Password.New.Tip"></label>
|
||||
<label><span data-i18n="Admin.Password.Repeat"></span><input class="input" name="repeat" type="password" autocomplete="new-password" required data-i18n-title="Admin.Password.Repeat.Tip"></label>
|
||||
<div class="error" role="alert"></div>
|
||||
<div class="row">
|
||||
<button class="btn" type="button" id="cancel" data-i18n="Admin.SignOut" data-i18n-title="Admin.SignOut.Tip"></button>
|
||||
<span class="spacer"></span>
|
||||
<button class="btn primary" type="submit" data-i18n="Admin.Password.Save" data-i18n-title="Admin.Password.Save.Tip"></button>
|
||||
</div>
|
||||
</form>
|
||||
</main>`;
|
||||
applyStrings(app);
|
||||
const form = app.querySelector("form");
|
||||
const error = form.querySelector(".error");
|
||||
app.querySelector("#cancel").addEventListener("click", async () => {
|
||||
await api.signOut();
|
||||
render();
|
||||
});
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const data = new FormData(form);
|
||||
if (data.get("next") !== data.get("repeat")) {
|
||||
error.textContent = t("Admin.Password.Mismatch");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await api.changePassword(String(data.get("current")), String(data.get("next")));
|
||||
render();
|
||||
} catch (err) {
|
||||
error.textContent = errorText(err);
|
||||
}
|
||||
});
|
||||
form.querySelector("input").focus();
|
||||
}
|
||||
|
||||
function renderShell(page, focus) {
|
||||
const nav = pages.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();
|
||||
const options = languages().map((code) => `<option value="${attr(code)}" ${code === culture() ? "selected" : ""}>${escapeHtml(nativeName(code))}</option>`).join("");
|
||||
app.innerHTML = `
|
||||
<div class="shell">
|
||||
<aside class="sidebar">
|
||||
<button class="btn icon sidebar-toggle" id="sidebar-toggle">${icons.menu}</button>
|
||||
${brand()}
|
||||
<nav class="nav">${nav}</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>
|
||||
<button class="btn icon" id="signout" data-i18n-title="Admin.SignOut.Tip">${icons.power}</button>
|
||||
</div>
|
||||
</aside>
|
||||
<div class="main">
|
||||
<header class="header">
|
||||
<h1 id="title" tabindex="-1" data-i18n="Admin.Nav.${cap(page)}"></h1>
|
||||
<span class="meta" id="meta"></span>
|
||||
<span class="spacer"></span>
|
||||
<span class="actions" id="actions"></span>
|
||||
<select class="input language" id="language" data-i18n-title="Admin.Language.Tip">${options}</select>
|
||||
<button class="btn icon" id="theme" aria-pressed="${isDark()}" data-i18n-title="Admin.Theme.Tip">${icons.moon}</button>
|
||||
</header>
|
||||
<main class="content" id="content"></main>
|
||||
</div>
|
||||
</div>`;
|
||||
applyStrings(app);
|
||||
applySidebar(sidebarCollapsed());
|
||||
app.querySelector("#sidebar-toggle").addEventListener("click", toggleSidebar);
|
||||
document.title = `${t(`Admin.Nav.${cap(page)}`)} · Chronos Server`;
|
||||
app.querySelector("#signout").addEventListener("click", async () => {
|
||||
events?.stop();
|
||||
events = null;
|
||||
await api.signOut();
|
||||
render();
|
||||
});
|
||||
app.querySelector("#language").addEventListener("change", async (e) => {
|
||||
await setLanguage(e.target.value);
|
||||
render("language");
|
||||
});
|
||||
app.querySelector("#theme").addEventListener("click", (e) => {
|
||||
const theme = isDark() ? "light" : "dark";
|
||||
applyTheme(theme);
|
||||
try {
|
||||
localStorage.setItem(THEME_KEY, theme);
|
||||
} catch {
|
||||
// Only this page keeps the theme then.
|
||||
}
|
||||
e.currentTarget.setAttribute("aria-pressed", String(theme === "dark"));
|
||||
});
|
||||
if (focus) app.querySelector(`#${focus}`)?.focus();
|
||||
|
||||
events ??= api.events((e) => listeners.forEach((fn) => fn(e)));
|
||||
listeners.clear();
|
||||
pages.forEach(showBadge);
|
||||
updateBadges();
|
||||
listeners.add((e) => {
|
||||
if (e.type === "jobState") updateBadges();
|
||||
});
|
||||
|
||||
const meta = app.querySelector("#meta");
|
||||
const content = app.querySelector("#content");
|
||||
const context = {
|
||||
api,
|
||||
info,
|
||||
/** Header text after the title (one line, full text in the tooltip); paths and file names stay left to right. */
|
||||
setMeta(text, { ltr = false } = {}) {
|
||||
meta.textContent = text;
|
||||
meta.title = text;
|
||||
meta.dir = ltr ? "ltr" : "auto";
|
||||
},
|
||||
actions: app.querySelector("#actions"),
|
||||
onEvent: (fn) => listeners.add(fn),
|
||||
};
|
||||
import(`./pages/${page}.js`)
|
||||
.then((m) => m.render(content, context))
|
||||
.catch((err) => {
|
||||
content.innerHTML = `<div class="panel empty"><span>${escapeHtml(errorText(err))}</span></div>`;
|
||||
});
|
||||
}
|
||||
|
||||
/** The menu shows icons alone: their tooltips then name the page, and the choice is kept in this browser. */
|
||||
function applySidebar(collapsed) {
|
||||
const shell = app.querySelector(".shell");
|
||||
if (!shell) return;
|
||||
shell.classList.toggle("collapsed", collapsed);
|
||||
const toggle = shell.querySelector("#sidebar-toggle");
|
||||
const tip = t(collapsed ? "Admin.Nav.Expand.Tip" : "Admin.Nav.Collapse.Tip");
|
||||
toggle.title = tip;
|
||||
toggle.setAttribute("aria-label", tip);
|
||||
toggle.setAttribute("aria-expanded", String(!collapsed));
|
||||
shell.querySelectorAll(".nav a").forEach((a) => {
|
||||
const page = a.getAttribute("href").replace("#/", "");
|
||||
const tip = t(`Admin.Nav.${cap(page)}.Tip`);
|
||||
a.title = collapsed ? t("Admin.Nav.Collapsed", t(`Admin.Nav.${cap(page)}`), tip) : tip;
|
||||
// Screen readers already have the name (the hidden label): their description stays the tip alone.
|
||||
if (collapsed) a.setAttribute("aria-description", tip);
|
||||
else a.removeAttribute("aria-description");
|
||||
});
|
||||
}
|
||||
|
||||
function sidebarCollapsed() {
|
||||
if (sidebarChoice !== null) return sidebarChoice;
|
||||
try {
|
||||
return localStorage.getItem(SIDEBAR_KEY) === "collapsed";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
const collapsed = !app.querySelector(".shell")?.classList.contains("collapsed");
|
||||
sidebarChoice = collapsed;
|
||||
applySidebar(collapsed);
|
||||
// The page's width changed by 200 px without a window resize: the tables fit their columns again.
|
||||
document.querySelectorAll(".table[data-levels]").forEach(fitColumns);
|
||||
try {
|
||||
localStorage.setItem(SIDEBAR_KEY, collapsed ? "collapsed" : "expanded");
|
||||
} catch {
|
||||
// Only this page keeps the choice then (sidebarChoice).
|
||||
}
|
||||
}
|
||||
|
||||
const badgeCounts = new Map();
|
||||
let badgeTimer = null;
|
||||
let badgeAgain = false;
|
||||
|
||||
/** Running jobs and accounts as nav badges: fetched at most every two seconds (then once more if asked meanwhile). */
|
||||
function updateBadges() {
|
||||
if (badgeTimer) {
|
||||
badgeAgain = true;
|
||||
return;
|
||||
}
|
||||
badgeTimer = setTimeout(() => {
|
||||
badgeTimer = null;
|
||||
if (badgeAgain) {
|
||||
badgeAgain = false;
|
||||
updateBadges();
|
||||
}
|
||||
}, 2000);
|
||||
api.get("/api/v1/jobs?state=running&limit=100").then((page) => setBadge("jobs", page.items.length)).catch(() => {});
|
||||
api.get("/api/v1/users").then((users) => setBadge("users", users.length)).catch(() => {});
|
||||
}
|
||||
|
||||
function setBadge(page, count) {
|
||||
badgeCounts.set(page, count);
|
||||
showBadge(page);
|
||||
}
|
||||
|
||||
/** The last known count on the page's nav link: a pill for the eye, a phrase for screen readers. */
|
||||
function showBadge(page) {
|
||||
const badge = document.getElementById(`badge-${page}`);
|
||||
const count = badgeCounts.get(page);
|
||||
if (!badge || count === undefined) return;
|
||||
badge.hidden = count === 0;
|
||||
badge.textContent = formatNumber(count);
|
||||
badge.classList.toggle("quiet", page !== "jobs");
|
||||
document.getElementById(`badge-text-${page}`).textContent =
|
||||
count === 0 ? "" : plural(page === "jobs" ? "Admin.Jobs.RunningCount" : "Admin.Users.Accounts", count);
|
||||
}
|
||||
|
||||
function storedTheme() {
|
||||
try {
|
||||
return localStorage.getItem(THEME_KEY);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Light or dark as chosen in this browser; without a choice the operating system's setting applies (admin.css). */
|
||||
function applyTheme(theme) {
|
||||
if (theme === "light" || theme === "dark") document.documentElement.dataset.theme = theme;
|
||||
}
|
||||
|
||||
function isDark() {
|
||||
const chosen = document.documentElement.dataset.theme;
|
||||
return chosen ? chosen === "dark" : matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
}
|
||||
|
||||
function cap(s) {
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
}
|
||||
|
||||
start();
|
||||
Reference in new issue
Block a user