Keep account controls permanent and add system error pages

This commit is contained in:
SantaSpeen committed 2026-12-01 15:24:13 +03:00
1 parent 61b05abe44
commit 60b584b7c1
50 files changed
+1287 -56

No files matched your search

+49 -3
View File
@@ -5,6 +5,11 @@ import {
} from "../components/search-select.js";
import { createNotifier } from "../components/toast.js";
import { mountCopyField } from "../components/copy-field.js";
import {
errorPageMarkup,
errorStatuses,
mountErrorPage,
} from "../components/error-page.js";
import { sshScreen, mountSsh } from "../components/ssh-console.js";
import { logsScreen, mountLogs } from "../components/log-reader.js";
import { iconSvg } from "../icons/icons.js";
@@ -172,6 +177,7 @@ let page = [
"tokens",
"ssh",
"logs",
"errors",
...accountPageIds,
].includes(params.get("page"))
? params.get("page")
@@ -185,6 +191,7 @@ let query = "",
tab = "general",
chartRange = "24h";
const pageNames = {
errors: t("Страницы ошибок", "Error pages"),
ssh: t("SSH-консоль", "SSH console"),
logs: t("Журнал событий", "Log reader"),
dashboard: t("Обзор", "Overview"),
@@ -202,7 +209,12 @@ const pageNames = {
};
const icon = (id) =>
iconSvg(
{ ssh: "terminal", logs: "document", administration: "server" }[id] || id,
{
ssh: "terminal",
logs: "document",
administration: "server",
errors: "warning",
}[id] || id,
{
className: "nav-icon",
},
@@ -406,7 +418,7 @@ function render({ preserveDock = false } = {}) {
const content = accountPageIds.includes(page)
? accountUI.renderPage(page)
: identityAdapter.snapshot().status !== "authenticated" &&
!["components", "tokens", "auth"].includes(page)
!["components", "tokens", "auth", "errors"].includes(page)
? accountUI.gate()
: ["dashboard", "users", "settings", "ssh", "logs"].includes(page) &&
!currentIdentity()?.roles.some((r) =>
@@ -420,6 +432,7 @@ function render({ preserveDock = false } = {}) {
users: userScreen,
settings: settingsScreen,
components: componentScreen,
errors: errorScreen,
tokens: tokenScreen,
}[page]?.() || "";
$("#app").innerHTML =
@@ -431,6 +444,33 @@ function render({ preserveDock = false } = {}) {
bindDockHover();
if (dockWasOpen) setDockOpen(true, false);
bindCharts();
if (page === "errors") {
selectCleanups.push(
mountErrorPage($("[data-error-status]"), {
onRetry: () =>
toast(
t(
"Это пример страницы ошибки. Реальный запрос не выполняется.",
"This is an error page preview. No request is sent.",
),
),
onHome: () => {
page = "components";
render();
},
onAccount: () => {
page = "profile";
render();
},
}),
);
$("#error-preview-status").addEventListener("change", (event) => {
const url = new URL(location.href);
url.searchParams.set("status", event.target.value);
history.replaceState({}, "", url);
render();
});
}
document
.querySelectorAll(".copy-input")
.forEach((root) =>
@@ -677,8 +717,14 @@ function settingsScreen() {
function auth() {
return `<main id="content" class="auth-layout" style="max-width:none;padding:0"><section class="auth-brand">${wordmark}<div class="auth-statement">${t("Ваша инфраструктура.<br>Под вашим контролем.", "Your infrastructure.<br>Under your control.")}</div><small>ANIDEV IDENTITY / ${t("ДЕМОНСТРАЦИЯ", "DEMONSTRATION")}</small></section><section class="auth-main"><form id="auth-form" class="auth-form"><h1>${t("Вход в Anidev", "Sign in to Anidev")}</h1><p>${t("Продолжите работу с вашим пространством.", "Continue to your workspace.")}</p><label class="field">${t("Username или email", "Username or email")}<input name="email" type="text" autocomplete="username" placeholder="anna.volkova" required></label><label class="field">${t("Пароль", "Password")}<input name="password" type="password" autocomplete="current-password" minlength="8" required aria-describedby="password-hint"><small id="password-hint">${t("Демо: anna.volkova или mikhail.orlov; пароль от 8 символов.", "Demo: anna.volkova or mikhail.orlov; password of 8+ characters.")}</small></label><div class="form-row"><input id="remember" type="checkbox"><label for="remember">${t("Запомнить меня", "Remember me")}</label><button class="row-action" type="button" data-action="recover">${t("Забыли пароль?", "Forgot password?")}</button></div><p class="error-text" id="auth-error" role="alert"></p><button class="primary" type="submit">${t("Войти", "Sign in")}</button><div class="auth-divider">${t("или корпоративный аккаунт", "or your company account")}</div><button type="button" class="sso" data-action="sso">${t("Войти через SSO", "Continue with SSO")}</button><div class="auth-foot"><span>© Anidev 2026</span><button class="row-action" type="button" data-page="dashboard">${t("Вернуться к обзору", "Back to overview")}</button></div></form></section></main>`;
}
function errorScreen() {
const requested = new URL(location.href).searchParams.get("status") || "404";
const status =
errorStatuses.find((value) => String(value) === requested) ?? 500;
return `<div class="error-preview-controls"><label for="error-preview-status">${t("Состояние", "State")}</label><select id="error-preview-status">${errorStatuses.map((value) => `<option value="${value}" ${value === status ? "selected" : ""}>${value === "banned" ? t("Аккаунт заблокирован", "Account suspended") : value === "offline" ? t("Нет соединения", "Connection unavailable") : value}</option>`).join("")}</select><button data-page="components">${t("К компонентам", "Components")}</button></div>${errorPageMarkup({ status, t, reason: t("Повторное нарушение правил сервиса.\nЭто демонстрационный пример причины блокировки.", "Repeated violations of service rules.\nThis is a sample suspension reason."), requestId: "demo-7f2c" })}`;
}
function componentScreen() {
return `${heading(t("Библиотека компонентов", "Component library"), t("Единые компоненты и состояния Dock.", "Shared Dock components and states."), `<button data-action="command">${t("Команды", "Commands")} ${commandShortcut}</button>`)}<div class="page-body"><div class="library">
return `${heading(t("Библиотека компонентов", "Component library"), t("Единые компоненты и состояния Dock.", "Shared Dock components and states."), `<button data-page="errors">${t("Страницы ошибок", "Error pages")}</button><button data-action="command">${t("Команды", "Commands")} ${commandShortcut}</button>`)}<div class="page-body"><div class="library">
<section class="specimen"><h2>Buttons</h2><div class="component-row"><button class="primary" data-action="demo-save">${t("Сохранить", "Save")}</button><button data-action="toast">${t("Вторичная", "Secondary")}</button><button class="danger" data-action="delete">${t("Удалить", "Delete")}</button><button disabled>Disabled</button><button aria-busy="true" disabled>${t("Загрузка…", "Loading…")}</button></div><small>Hover · active · focus · disabled · loading</small></section>
<section class="specimen"><h2>Inputs & selects</h2><label class="field">${t("Имя проекта", "Project name")}<input placeholder="Anidev Production"></label><label class="field">Email<input aria-invalid="true" aria-describedby="sample-error" value="invalid-email"><small class="error-text" id="sample-error">${t("Введите корректный email", "Enter a valid email")}</small></label><div class="sample-control-row"><select aria-label="${t("Окружение", "Environment")}"><option>Production</option><option>Staging</option></select><input aria-label="${t("Только для чтения", "Read-only field")}" readonly value="Read only"></div><div class="search-select-example">${searchSelectMarkup({ id: "environment-search", name: "searchEnvironment", label: t("Окружение — с поиском", "Environment — searchable"), options: environmentOptions, value: "production", t })}</div><div class="field copy-field-example"><label for="copy-input-example">${t("Строка с копированием", "Field with copy action")}</label><div class="copy-input"><button type="button" class="input-copy-action" data-copy-input aria-label="${t("Скопировать значение", "Copy field value")}" title="${t("Скопировать значение", "Copy field value")}">${iconSvg("copy", { size: 16 })}</button><input id="copy-input-example" name="copyExample" value="anidev-production" autocomplete="off"></div></div></section>
<section class="specimen selection-specimen"><h2>Selection controls</h2><div class="form-row"><label class="choice-pill" for="check-demo"><input id="check-demo" type="checkbox" checked><span>${t("Email-уведомления", "Email notifications")}</span></label></div><fieldset style="border:0;padding:0"><legend>${t("Период хранения", "Retention period")}</legend><div class="component-row"><label class="choice-pill"><input type="radio" name="retention" value="30" checked><span>30 ${t("дней", "days")}</span></label><label class="choice-pill"><input type="radio" name="retention" value="90"><span>90 ${t("дней", "days")}</span></label></div></fieldset><div class="form-row"><label for="switch-demo">${t("Автообновление", "Auto refresh")}</label><input id="switch-demo" class="switch" role="switch" type="checkbox" checked></div></section>