Add SSH console and log reader workspaces
This commit is contained in:
1 parent
0561fb1596
commit
cd821abb51
68 files changed
+3227
-5
No files matched your search
+38
-3
@@ -1,3 +1,5 @@
|
||||
import { sshScreen, mountSsh } from "../components/ssh-console.js";
|
||||
import { logsScreen, mountLogs } from "../components/log-reader.js";
|
||||
import { iconSvg } from "../icons/icons.js";
|
||||
import { concepts, tokensFor, cssVars } from "../concepts/registry.js";
|
||||
import {
|
||||
@@ -161,6 +163,8 @@ let page = [
|
||||
"auth",
|
||||
"components",
|
||||
"tokens",
|
||||
"ssh",
|
||||
"logs",
|
||||
...accountPageIds,
|
||||
].includes(params.get("page"))
|
||||
? params.get("page")
|
||||
@@ -174,6 +178,8 @@ let query = "",
|
||||
tab = "general",
|
||||
chartRange = "24h";
|
||||
const pageNames = {
|
||||
ssh: t("SSH-консоль", "SSH console"),
|
||||
logs: t("Журнал событий", "Log reader"),
|
||||
dashboard: t("Обзор", "Overview"),
|
||||
users: t("Пользователи", "Users"),
|
||||
settings: t("Настройки", "Settings"),
|
||||
@@ -187,7 +193,10 @@ const pageNames = {
|
||||
appearance: t("Оформление", "Appearance"),
|
||||
identity: t("Состояния входа", "Sign-in states"),
|
||||
};
|
||||
const icon = (id) => iconSvg(id, { className: "nav-icon" });
|
||||
const icon = (id) =>
|
||||
iconSvg({ ssh: "terminal", logs: "document" }[id] || id, {
|
||||
className: "nav-icon",
|
||||
});
|
||||
const wordmark = '<div class="wordmark"><b>a/</b><span>anidev</span></div>';
|
||||
function persist() {
|
||||
try {
|
||||
@@ -225,7 +234,7 @@ function accountInitials() {
|
||||
function navigationPages() {
|
||||
return accountPageIds.includes(page)
|
||||
? ["profile", "security", "sessions", "applications", "appearance"]
|
||||
: ["dashboard", "users", "settings", "components", "tokens"];
|
||||
: ["dashboard", "users", "settings", "ssh", "logs", "components", "tokens"];
|
||||
}
|
||||
function dockAccount() {
|
||||
return `<div class="dock-account-area"><div id="account-menu" class="account-menu" popover="auto" aria-label="${t("Меню аккаунта", "Account menu")}">
|
||||
@@ -319,8 +328,13 @@ function savePreferences() {
|
||||
);
|
||||
} catch {}
|
||||
}
|
||||
let workspaceCleanup = () => {},
|
||||
workspaceRender = 0;
|
||||
let initialRender = true;
|
||||
function render({ preserveDock = false } = {}) {
|
||||
workspaceCleanup();
|
||||
workspaceCleanup = () => {};
|
||||
const workspaceVersion = ++workspaceRender;
|
||||
const dockWasOpen =
|
||||
preserveDock &&
|
||||
document.body.classList.contains("dock-open") &&
|
||||
@@ -352,12 +366,14 @@ function render({ preserveDock = false } = {}) {
|
||||
: identityAdapter.snapshot().status !== "authenticated" &&
|
||||
!["components", "tokens", "auth"].includes(page)
|
||||
? accountUI.gate()
|
||||
: ["dashboard", "users", "settings"].includes(page) &&
|
||||
: ["dashboard", "users", "settings", "ssh", "logs"].includes(page) &&
|
||||
!currentIdentity()?.roles.some((r) =>
|
||||
["Master Admin", "SSO Admin"].includes(r),
|
||||
)
|
||||
? accountUI.gate("access_denied")
|
||||
: {
|
||||
ssh: () => sshScreen({ t, heading }),
|
||||
logs: () => logsScreen({ t, heading }),
|
||||
dashboard,
|
||||
users: userScreen,
|
||||
settings: settingsScreen,
|
||||
@@ -373,6 +389,24 @@ function render({ preserveDock = false } = {}) {
|
||||
bindDockHover();
|
||||
if (dockWasOpen) setDockOpen(true, false);
|
||||
bindCharts();
|
||||
if ($("#log-workspace"))
|
||||
workspaceCleanup = mountLogs($("#log-workspace"), {
|
||||
t,
|
||||
escape,
|
||||
notify: toast,
|
||||
});
|
||||
const sshRoot = $("#ssh-workspace");
|
||||
if (sshRoot)
|
||||
mountSsh(sshRoot, { t, notify: toast })
|
||||
.then((cleanup) => {
|
||||
if (workspaceVersion === workspaceRender) workspaceCleanup = cleanup;
|
||||
else cleanup();
|
||||
})
|
||||
.catch(() => {
|
||||
if (sshRoot.isConnected)
|
||||
sshRoot.querySelector("[data-terminal]").innerHTML =
|
||||
`<div class="error-state"><h2>${t("Терминал не загрузился", "Terminal did not load")}</h2><p>${t("Обновите страницу, чтобы повторить загрузку.", "Reload the page to try again.")}</p></div>`;
|
||||
});
|
||||
if (page === "users" && $("#user-search")) bindUsers();
|
||||
}
|
||||
function chart() {
|
||||
@@ -598,6 +632,7 @@ function componentScreen() {
|
||||
<section class="specimen"><h2>Empty state</h2><div class="empty-state"><h3>${t("Пока нет API-ключей", "No API keys yet")}</h3><p>${t("Создайте ключ для подключения сервиса.", "Create a key to connect your service.")}</p><button data-action="create-key">${t("Создать ключ", "Create key")}</button></div></section>
|
||||
<section class="specimen"><h2>Error & skeleton</h2><div class="error-state" role="status"><p>${t("Не удалось загрузить журнал.", "Could not load the log.")}</p><button data-action="retry">${t("Повторить", "Retry")}</button></div><div aria-label="${t("Загрузка данных", "Loading data")}" aria-busy="true" style="margin-top:20px"><div class="skeleton"></div><div class="skeleton"></div><div class="skeleton"></div></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("Иконки 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>`;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user