feat(mcp): подготовить сервер и доступ к приёмке
This commit is contained in:
commit
bf3d50e1ff
3835 files changed
+537122
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { INIT_USERS } from "@/lib/users"
|
||||
import {
|
||||
asns,
|
||||
domains,
|
||||
filters,
|
||||
greTunnels,
|
||||
ipRanges,
|
||||
pingProbes,
|
||||
routerCertificates,
|
||||
routerContainers,
|
||||
servers,
|
||||
vxlanTunnels,
|
||||
} from "@/lib/data"
|
||||
|
||||
/** Число мок-сессий BGP (см. `SESSIONS` в `app/(main)/bgp/page.tsx`). */
|
||||
export const MOCK_BGP_SESSION_COUNT = 12
|
||||
|
||||
/** Компактная подпись: тысячи как «1.8к» (кириллица), как в старом меню. */
|
||||
export function formatSidebarBadgeCount(n: number): string {
|
||||
if (!Number.isFinite(n) || n < 0) return "0"
|
||||
if (n < 1000) return String(Math.round(n))
|
||||
const k = n / 1000
|
||||
const s = k >= 10 ? String(Math.round(k)) : k.toFixed(1).replace(/\.0$/, "")
|
||||
return `${s}к`
|
||||
}
|
||||
|
||||
/** Мок-клиенты IKEv2 для демо-режима (см. MOCK_IPSEC_CLIENTS на странице /ipsec). */
|
||||
export const MOCK_IPSEC_CLIENTS_COUNT = 3
|
||||
|
||||
function mockWireGuardIfacesCount(): number {
|
||||
let n = 0
|
||||
for (const s of servers) n += s.wireGuardIfaces?.length ?? 0
|
||||
return n
|
||||
}
|
||||
|
||||
/** Счётчики из `lib/data` для режима mock. */
|
||||
export function mockSidebarBadgesByUrl(): Record<string, string> {
|
||||
return {
|
||||
"/uptime": formatSidebarBadgeCount(pingProbes.length),
|
||||
"/domains": formatSidebarBadgeCount(domains.length),
|
||||
"/ip-ranges": formatSidebarBadgeCount(ipRanges.length),
|
||||
"/asns": formatSidebarBadgeCount(asns.length),
|
||||
"/servers": formatSidebarBadgeCount(servers.length),
|
||||
"/users": formatSidebarBadgeCount(INIT_USERS.length),
|
||||
"/filters": formatSidebarBadgeCount(filters.length),
|
||||
"/wireguard": formatSidebarBadgeCount(mockWireGuardIfacesCount()),
|
||||
"/ipsec": formatSidebarBadgeCount(MOCK_IPSEC_CLIENTS_COUNT),
|
||||
"/gre": formatSidebarBadgeCount(greTunnels.length),
|
||||
"/vxlan": formatSidebarBadgeCount(vxlanTunnels.length),
|
||||
"/containers": formatSidebarBadgeCount(routerContainers.length),
|
||||
"/certificates": formatSidebarBadgeCount(routerCertificates.length),
|
||||
"/bgp": formatSidebarBadgeCount(MOCK_BGP_SESSION_COUNT),
|
||||
}
|
||||
}
|
||||
|
||||
export interface SidebarCountsDto {
|
||||
servers: number
|
||||
filterRules: number
|
||||
uptimeProbes: number
|
||||
uptimeSpeedProbes: number
|
||||
monitoringItems: number
|
||||
recursiveRoutes: number
|
||||
certificates?: number
|
||||
wireguard?: number
|
||||
ipsec?: number
|
||||
users?: number
|
||||
bgpSessions?: number
|
||||
vxlan?: number
|
||||
containers?: number
|
||||
}
|
||||
Reference in new issue
Block a user