Add Markdown editor, server statistics and content navigation
This commit is contained in:
1 parent
03c590e172
commit
1819f35f91
52 files changed
+7190
-28
No files matched your search
+154
-13
@@ -5,6 +5,18 @@ import {
|
||||
} from "../components/search-select.js";
|
||||
import { createNotifier } from "../components/toast.js";
|
||||
import { mountCopyField } from "../components/copy-field.js";
|
||||
import {
|
||||
breadcrumbsMarkup,
|
||||
mountBreadcrumbs,
|
||||
} from "../components/breadcrumbs.js";
|
||||
import {
|
||||
contentDemoPages,
|
||||
contentDemoMarkup,
|
||||
mountContentDemo,
|
||||
contentBreadcrumbs,
|
||||
contentHref,
|
||||
createDemoDocuments,
|
||||
} from "../components/content-demo.js";
|
||||
import {
|
||||
mountMobileDock,
|
||||
createMobileHistory,
|
||||
@@ -38,6 +50,8 @@ import {
|
||||
import { exportSystem } from "../components/export-system.js";
|
||||
const identityAdapter = createDemoIdentityAdapter();
|
||||
const mobileHistory = createMobileHistory();
|
||||
const documentFiles = createDemoDocuments();
|
||||
let documentOwner = null;
|
||||
let preferences = {};
|
||||
try {
|
||||
preferences =
|
||||
@@ -192,6 +206,10 @@ let page = [
|
||||
"ssh",
|
||||
"logs",
|
||||
"errors",
|
||||
"documents",
|
||||
"servers",
|
||||
"server",
|
||||
"statistics",
|
||||
...accountPageIds,
|
||||
].includes(params.get("page"))
|
||||
? params.get("page")
|
||||
@@ -209,6 +227,10 @@ let query = "",
|
||||
tab = "general",
|
||||
chartRange = "24h";
|
||||
const pageNames = {
|
||||
documents: t("Документы", "Documents"),
|
||||
servers: t("Серверы", "Servers"),
|
||||
server: t("Сервер", "Server"),
|
||||
statistics: t("Статистика сервера", "Server statistics"),
|
||||
errors: t("Страницы ошибок", "Error pages"),
|
||||
ssh: t("SSH-консоль", "SSH console"),
|
||||
logs: t("Журнал событий", "Log reader"),
|
||||
@@ -232,6 +254,10 @@ const icon = (id) =>
|
||||
logs: "document",
|
||||
administration: "server",
|
||||
errors: "warning",
|
||||
documents: "document",
|
||||
statistics: "server",
|
||||
servers: "server",
|
||||
server: "server",
|
||||
}[id] || id,
|
||||
{
|
||||
className: "nav-icon",
|
||||
@@ -262,11 +288,12 @@ function accountInitials() {
|
||||
}
|
||||
function navigationPages() {
|
||||
return panel === "user"
|
||||
? ["dashboard"]
|
||||
? ["dashboard", "documents"]
|
||||
: [
|
||||
"dashboard",
|
||||
"users",
|
||||
"settings",
|
||||
"documents",
|
||||
"administration",
|
||||
"components",
|
||||
"tokens",
|
||||
@@ -302,13 +329,21 @@ ${currentIdentity()?.roles.some((r) => ["Master Admin", "SSO Admin"].includes(r)
|
||||
<button class="account-separator" data-identity="logout">${icon("logout")}<span>${t("Выйти из SSO", "Sign out of SSO")}</span></button>${themeControlMarkup({ theme, t })}</div>
|
||||
<button class="dock-account" popovertarget="account-menu" aria-label="${escape(t("Меню аккаунта ", "Account menu ") + accountName())}"><span class="avatar">${currentIdentity()?.avatar ? `<img src="${escape(currentIdentity().avatar)}" alt="">` : escape(accountInitials())}</span><span class="account-identity"><b>${escape(accountName())}</b><small>${escape(currentIdentity()?.username || "Anidev Identity")}</small></span><span class="account-more" aria-hidden="true">···</span></button></div>`;
|
||||
}
|
||||
let administrationOpen = ["ssh", "logs"].includes(page);
|
||||
let administrationOpen = [
|
||||
"ssh",
|
||||
"logs",
|
||||
"statistics",
|
||||
"servers",
|
||||
"server",
|
||||
].includes(page);
|
||||
function navPage(id, label = pageNames[id]) {
|
||||
return `<button data-page="${id}" ${page === id ? 'aria-current="page"' : ""} title="${label}" aria-label="${label}">${icon(id)}<span>${label}</span></button>`;
|
||||
}
|
||||
function administrationNav() {
|
||||
const active = ["ssh", "logs"].includes(page);
|
||||
return `<div class="nav-group" data-nav-group="administration"><button type="button" class="nav-group-toggle" data-action="administration-toggle" aria-expanded="false" aria-controls="administration-submenu" data-active="${active}" title="${t("Администрирование", "Administration")}" aria-label="${t("Администрирование", "Administration")}">${icon("administration")}<span class="nav-group-label">${t("Администрирование", "Administration")}${iconSvg("chevron-down", { size: 16, className: "nav-chevron" })}</span></button><div class="nav-submenu-container" id="administration-submenu" aria-hidden="true" inert><div class="nav-submenu-clip"><div class="nav-submenu-list">${navPage("ssh")}${navPage("logs", t("Логи", "Logs"))}</div></div></div></div>`;
|
||||
const active = ["ssh", "logs", "statistics", "servers", "server"].includes(
|
||||
page,
|
||||
);
|
||||
return `<div class="nav-group" data-nav-group="administration"><button type="button" class="nav-group-toggle" data-action="administration-toggle" aria-expanded="false" aria-controls="administration-submenu" data-active="${active}" title="${t("Администрирование", "Administration")}" aria-label="${t("Администрирование", "Administration")}">${icon("administration")}<span class="nav-group-label">${t("Администрирование", "Administration")}${iconSvg("chevron-down", { size: 16, className: "nav-chevron" })}</span></button><div class="nav-submenu-container" id="administration-submenu" aria-hidden="true" inert><div class="nav-submenu-clip"><div class="nav-submenu-list">${navPage("ssh")}${navPage("logs", t("Логи", "Logs"))}${navPage("statistics")}</div></div></div></div>`;
|
||||
}
|
||||
function syncAdministration() {
|
||||
const group = $("[data-nav-group=administration]");
|
||||
@@ -345,7 +380,40 @@ const commandShortcut = /Mac|iPhone|iPad/.test(navigator.platform)
|
||||
? "⌘ K"
|
||||
: "Ctrl K";
|
||||
function header() {
|
||||
return `<header class="app-header"><button class="mobile-menu" data-action="mobile-menu" aria-label="${t("Открыть навигацию", "Open navigation")}" aria-expanded="false">☰</button><div class="breadcrumb">Anidev <span aria-hidden="true">/</span> ${accountPageIds.includes(page) ? t("Личный кабинет", "My account") : "Production"} <span aria-hidden="true">/</span> ${pageNames[page]}</div><div class="header-actions"><button class="command-trigger" data-action="command" data-shortcut="${commandShortcut}" aria-label="${t("Найти команду", "Find a command")} (${commandShortcut})">${t("Найти команду", "Find a command")} <kbd>${commandShortcut}</kbd></button><button class="avatar" data-action="profile" aria-label="${escape(accountName())}">${escape(accountInitials())}</button></div></header>`;
|
||||
const route = new URL(location.href),
|
||||
personal = panel === "user",
|
||||
root = {
|
||||
label: "anidev",
|
||||
href: contentHref({
|
||||
page: "dashboard",
|
||||
panel: personal ? "user" : "admin",
|
||||
}),
|
||||
};
|
||||
const items = contentDemoPages.includes(page)
|
||||
? contentBreadcrumbs(page, {
|
||||
server: route.searchParams.get("server") || "edge-01",
|
||||
path: route.searchParams.get("path") || "/",
|
||||
t,
|
||||
})
|
||||
: [
|
||||
root,
|
||||
...(page !== "dashboard" && page !== "profile"
|
||||
? [
|
||||
{
|
||||
label: personal
|
||||
? t("Аккаунт", "Account")
|
||||
: t("Панель управления", "Control panel"),
|
||||
href: contentHref({
|
||||
page: personal ? "profile" : "dashboard",
|
||||
panel,
|
||||
}),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ label: pageNames[page] },
|
||||
];
|
||||
const breadcrumb = breadcrumbsMarkup({ items, t });
|
||||
return `<header class="app-header"><button class="mobile-menu" data-action="mobile-menu" aria-label="${t("Открыть навигацию", "Open navigation")}" aria-expanded="false">☰</button>${breadcrumb}<div class="header-actions"><button class="command-trigger" data-action="command" data-shortcut="${commandShortcut}" aria-label="${t("Найти команду", "Find a command")} (${commandShortcut})">${t("Найти команду", "Find a command")} <kbd>${commandShortcut}</kbd></button><button class="avatar" data-action="profile" aria-label="${escape(accountName())}">${escape(accountInitials())}</button></div></header>`;
|
||||
}
|
||||
const heading = (title, desc, actions = "") =>
|
||||
`<div class="page-heading"><div><div class="overline">ANIDEV://PRODUCTION/${page.toUpperCase()}</div><h1>${title}</h1><p>${desc}</p></div><div class="heading-actions">${actions}</div></div>`;
|
||||
@@ -431,6 +499,13 @@ function render({ preserveDock = false } = {}) {
|
||||
workspaceCleanup = () => {};
|
||||
const workspaceVersion = ++workspaceRender;
|
||||
const signedIn = identityAdapter.snapshot().status === "authenticated";
|
||||
const owner = signedIn ? currentIdentity()?.sub : null;
|
||||
if (owner !== documentOwner) {
|
||||
documentFiles.clear();
|
||||
for (const [path, file] of createDemoDocuments())
|
||||
documentFiles.set(path, file);
|
||||
documentOwner = owner;
|
||||
}
|
||||
if (
|
||||
accountPageIds.includes(page) ||
|
||||
!currentIdentity()?.roles.some((role) =>
|
||||
@@ -473,7 +548,15 @@ function render({ preserveDock = false } = {}) {
|
||||
: identityAdapter.snapshot().status !== "authenticated" &&
|
||||
!["components", "tokens", "auth", "errors"].includes(page)
|
||||
? accountUI.gate()
|
||||
: ["users", "settings", "ssh", "logs"].includes(page) &&
|
||||
: [
|
||||
"users",
|
||||
"settings",
|
||||
"ssh",
|
||||
"logs",
|
||||
"statistics",
|
||||
"servers",
|
||||
"server",
|
||||
].includes(page) &&
|
||||
!currentIdentity()?.roles.some((r) =>
|
||||
["Master Admin", "SSO Admin"].includes(r),
|
||||
)
|
||||
@@ -484,6 +567,24 @@ function render({ preserveDock = false } = {}) {
|
||||
dashboard: panel === "admin" ? dashboard : userOverview,
|
||||
users: userScreen,
|
||||
settings: settingsScreen,
|
||||
documents: () => contentDemoMarkup("documents", { heading, t }),
|
||||
servers: () => contentDemoMarkup("servers", { heading, t }),
|
||||
server: () =>
|
||||
contentDemoMarkup("server", {
|
||||
heading,
|
||||
t,
|
||||
server:
|
||||
new URL(location.href).searchParams.get("server") ||
|
||||
"edge-01",
|
||||
}),
|
||||
statistics: () =>
|
||||
contentDemoMarkup("statistics", {
|
||||
heading,
|
||||
t,
|
||||
server:
|
||||
new URL(location.href).searchParams.get("server") ||
|
||||
"edge-01",
|
||||
}),
|
||||
components: componentScreen,
|
||||
errors: errorScreen,
|
||||
tokens: tokenScreen,
|
||||
@@ -499,6 +600,20 @@ function render({ preserveDock = false } = {}) {
|
||||
bindDockHover();
|
||||
if (dockWasOpen) setDockOpen(true, false);
|
||||
bindCharts();
|
||||
if ($(".breadcrumbs"))
|
||||
selectCleanups.push(
|
||||
mountBreadcrumbs($(".breadcrumbs"), { onNavigate: visitContentURL }),
|
||||
);
|
||||
if (contentDemoPages.includes(page) && $("[data-content-demo]"))
|
||||
workspaceCleanup = mountContentDemo($("[data-content-demo]"), {
|
||||
page,
|
||||
server: new URL(location.href).searchParams.get("server") || "edge-01",
|
||||
path: new URL(location.href).searchParams.get("path") || "/",
|
||||
files: documentFiles,
|
||||
onNavigate: visitContentURL,
|
||||
notify: toast,
|
||||
t,
|
||||
});
|
||||
if ($(".navigation")) {
|
||||
const mobile = mountMobileDock($(".navigation"), {
|
||||
trigger: $(".dock-brand"),
|
||||
@@ -507,19 +622,37 @@ function render({ preserveDock = false } = {}) {
|
||||
getPage: (id) => {
|
||||
const allowed = [
|
||||
"dashboard",
|
||||
"documents",
|
||||
...accountPageIds,
|
||||
"components",
|
||||
"tokens",
|
||||
"errors",
|
||||
...(panel === "admin" ? ["users", "settings", "ssh", "logs"] : []),
|
||||
...(panel === "admin"
|
||||
? [
|
||||
"users",
|
||||
"settings",
|
||||
"ssh",
|
||||
"logs",
|
||||
"statistics",
|
||||
"servers",
|
||||
"server",
|
||||
]
|
||||
: []),
|
||||
];
|
||||
return allowed.includes(id) && pageNames[id]
|
||||
? {
|
||||
id,
|
||||
label: pageNames[id],
|
||||
icon:
|
||||
{ ssh: "terminal", logs: "document", errors: "warning" }[id] ||
|
||||
id,
|
||||
{
|
||||
ssh: "terminal",
|
||||
logs: "document",
|
||||
errors: "warning",
|
||||
documents: "document",
|
||||
statistics: "server",
|
||||
servers: "server",
|
||||
server: "server",
|
||||
}[id] || id,
|
||||
}
|
||||
: null;
|
||||
},
|
||||
@@ -838,6 +971,11 @@ 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 visitContentURL(url) {
|
||||
history.pushState({}, "", url);
|
||||
dispatchEvent(new PopStateEvent("popstate"));
|
||||
$("#content")?.focus({ preventScroll: true });
|
||||
}
|
||||
function userOverview() {
|
||||
return (
|
||||
heading(
|
||||
@@ -893,7 +1031,7 @@ function componentScreen() {
|
||||
)
|
||||
.join("")}</div></section>
|
||||
<section class="specimen status-specimen"><h2>${t("Статусы", "Status indicators")}</h2><div class="component-row status-examples"><span class="status-badge status-badge--success">${iconSvg("check", { size: 16 })}${t("Работает", "Operational")}</span><span class="status-badge status-badge--danger">${iconSvg("close", { size: 16 })}${t("Недоступен", "Unavailable")}</span><span class="status-badge status-badge--pending">${iconSvg("more-horizontal", { size: 16 })}${t("Ожидает", "Pending")}</span></div><p class="muted" style="font-size:13px">${t("Состояние выражено текстом, а не только цветом.", "Status uses text as well as color.")}</p></section>
|
||||
<section class="specimen"><h2>${t("Рабочие области", "Workspaces")}</h2><p class="muted">${t("SSH-терминал и ридер логов в стиле Dock.", "SSH terminal and log reader in Dock style.")}</p><div class="component-row"><button data-page="ssh">${t("SSH-консоль", "SSH console")}</button><button data-page="logs">${t("Log-ридер", "Log reader")}</button></div></section>
|
||||
<section class="specimen"><h2>${t("Рабочие области", "Workspaces")}</h2><p class="muted">${t("SSH-терминал и ридер логов в стиле Dock.", "SSH terminal and log reader in Dock style.")}</p><div class="component-row"><button data-page="ssh">${t("SSH-консоль", "SSH console")}</button><button data-page="logs">${t("Log-ридер", "Log reader")}</button><button data-page="statistics">${t("Статистика сервера", "Server statistics")}</button><button data-page="documents">${t("Markdown и редактор", "Markdown and editor")}</button></div></section>
|
||||
<section class="specimen"><h2>${t("Иконки Anidev", "Anidev icons")}</h2><div class="component-row icon-specimen">${["profile", "security", "sessions", "applications", "settings", "copy", "key", "bell"].map(icon).join("")}</div><p class="muted">${t("64 SVG · сетка 24×24 · контур 1.5px", "64 SVGs · 24×24 grid · 1.5px stroke")}</p><a href="${new URL("../icons/", import.meta.url).pathname}" data-icon-catalog>${t("Открыть пак иконок →", "Open icon pack →")}</a></section>
|
||||
<section class="specimen"><h2>Chart</h2>${chart()}</section></div><p class="compact-note">${t("Таблицы, пагинация и фильтры — на экране «Пользователи»; вкладки — в настройках; форма входа — в авторизации.", "Tables, pagination and filters: Users. Tabs: Settings. Sign-in form: Authentication.")}</p></div>`;
|
||||
}
|
||||
@@ -1115,7 +1253,8 @@ document.addEventListener("click", async (e) => {
|
||||
return;
|
||||
}
|
||||
page = pageButton.dataset.page;
|
||||
if (["ssh", "logs"].includes(page)) administrationOpen = true;
|
||||
if (["ssh", "logs", "statistics", "servers", "server"].includes(page))
|
||||
administrationOpen = true;
|
||||
$("#dialog").close();
|
||||
render({ preserveDock: fromDock && !matchMedia(mobileDockQuery).matches });
|
||||
if (fromDock && document.body.classList.contains("dock-open")) {
|
||||
@@ -1552,7 +1691,8 @@ addEventListener("storage", (e) => {
|
||||
});
|
||||
function navigate(next) {
|
||||
page = next;
|
||||
if (["ssh", "logs"].includes(page)) administrationOpen = true;
|
||||
if (["ssh", "logs", "statistics", "servers", "server"].includes(page))
|
||||
administrationOpen = true;
|
||||
$("#dialog").close();
|
||||
render();
|
||||
$("#content")?.focus();
|
||||
@@ -1590,7 +1730,8 @@ addEventListener("popstate", () => {
|
||||
page = Object.keys(pageNames).includes(route.searchParams.get("page"))
|
||||
? route.searchParams.get("page")
|
||||
: "dashboard";
|
||||
if (["ssh", "logs"].includes(page)) administrationOpen = true;
|
||||
if (["ssh", "logs", "statistics", "servers", "server"].includes(page))
|
||||
administrationOpen = true;
|
||||
theme = route.searchParams.get("theme") === "dark" ? "dark" : "light";
|
||||
tokens = tokensFor("dock", theme, rawAccent || undefined, density);
|
||||
document.documentElement.style.cssText = cssVars(tokens);
|
||||
|
||||
Reference in new issue
Block a user