chore(ui): add module file and main stub

- chore(ui): add module file and main stub
- feat(ui): add layout, pages and partials
- feat(ui): add stylesheet and scripts
- feat(ui): add page renderer and static file handler
- test(ui): cover rendering, escaping and static serving
This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 7089a6f408
commit 5ac8f98f10
26 files changed
+3921

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2026 Bryan Joshua Pedini
import { $, api, bindPasswordForm, clear, h, handleError, toast, zoneLink } from "./common.js";
async function load() {
const list = $("#account-zones");
try {
const { data } = await api("GET", "/account");
$("#account-username").textContent = data.username;
$("#account-role").textContent = data.role;
if (list) {
const zones = data.zones || [];
clear(list);
for (const zone of zones) list.append(h("li", null, zoneLink(zone)));
$("#account-zones-status").textContent = zones.length === 0 ? "No zone is delegated to you." : "";
}
} catch (err) {
if (list) $("#account-zones-status").textContent = "The account could not be loaded.";
handleError(err);
}
}
bindPasswordForm($("#password-form"), async (form) => {
await api("PUT", "/account/password", { body: { current: form.elements.current.value, password: form.elements.password.value } });
toast("Password changed. Your other sessions ended.");
});
load();