Add four-icon mobile bottom Dock with recent sections

This commit is contained in:
SantaSpeen committed 2026-12-02 14:56:04 +03:00
1 parent c3257a0f4d
commit 03c590e172
20 files changed
+547 -5

No files matched your search

+46
View File
@@ -4,6 +4,7 @@ import {
createNotifier,
mountCopyField,
mountDock,
mountMobileDock,
mountNavigation,
mountAccountMenu,
errorPageMarkup,
@@ -23,6 +24,7 @@ let syncAccountTheme = () => {};
const pageIds = new Set(["overview", "projects", "logs"]);
let allowedIds = new Set(),
serviceHome = null;
let mobilePages = new Map();
const fixedIds = new Set([
"account",
"account-security",
@@ -102,6 +104,7 @@ function showSession(error = { status: 401 }) {
sessionCleanup();
sessionCleanup = () => {};
dock.close();
mobileDock.reset();
accountMenu.close();
notify.dismiss();
document.querySelectorAll("[popover]:popover-open").forEach((popup) => {
@@ -114,6 +117,7 @@ function showSession(error = { status: 401 }) {
navigation.setItems([]);
changingMenu = false;
allowedIds.clear();
mobilePages.clear();
serviceHome = null;
accountMenu.update({});
$("#page-data").replaceChildren();
@@ -243,6 +247,7 @@ async function showPage(id) {
$(".page-heading").hidden = false;
$(".integration-form").hidden = true;
accountMenu.setActive(id);
mobileDock.update(id, `${identity.panel}:${identity.id || "account"}`);
if (["account", "account-settings"].includes(id)) {
renderAccount(id);
return;
@@ -359,6 +364,13 @@ async function showPage(id) {
}
if (error.status === 403 && error.code === "ACCOUNT_BANNED") {
accountError = null;
mobilePages.clear();
allowedIds.clear();
mobileDock.reset();
mobileDock.update(
"account-banned",
`${identity?.panel || "user"}:${identity?.id || "account"}`,
);
identity = {
...identity,
status: "banned",
@@ -398,6 +410,24 @@ const accountMenu = mountAccountMenu($("#persistent-account"), {
},
});
syncAccountTheme = () => accountMenu.setTheme(theme);
const mobileDock = mountMobileDock($(".navigation"), {
trigger: $(".dock-brand"),
t,
onNavigate: go,
onCloseMenu: () => dock.close(),
getPage: (id) => {
const personal = {
account: ["Управление", "profile"],
"account-security": ["Безопасность", "security"],
"account-sessions": ["Устройства и сеансы", "sessions"],
"account-settings": ["Настройки", "settings"],
};
if (personal[id])
return { id, label: personal[id][0], icon: personal[id][1] };
if (preview(id)) return { id, label: "Состояние", icon: "warning" };
return mobilePages.get(id) || null;
},
});
const navigation = mountNavigation($(".nav-links"), {
t,
onActiveChange: (id) => {
@@ -507,6 +537,15 @@ async function refreshNavigation() {
.filter((item) => !item.disabled)
.map((item) => item.id),
);
mobilePages = new Map(
(identity?.status === "banned" ? [] : data.items)
.flatMap((item) => (item.disabled ? [] : item.children || [item]))
.filter((item) => !item.disabled)
.map((item) => [
item.id,
{ id: item.id, label: item.label, icon: item.icon },
]),
);
if (
fixed(requested) ||
(firstMenuLoad && requested && requested !== navigation.activeId)
@@ -544,6 +583,12 @@ async function refreshNavigation() {
navigation.setItems([]);
changingMenu = false;
allowedIds.clear();
mobilePages.clear();
mobileDock.reset();
mobileDock.update(
"account-banned",
`${identity?.panel || "user"}:${identity?.id || "account"}`,
);
serviceHome = null;
if (fixedIds.has(current)) showPage(current);
else
@@ -617,6 +662,7 @@ function dispose() {
cleanups.forEach((cleanup) => cleanup());
navigation.dispose();
accountMenu.dispose();
mobileDock.dispose();
dock.dispose();
notify.dispose();
}