- 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
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
// 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();
|