Includes current frontend and backend work in progress and removes generated artifacts from tracking to keep the repository clean for дальнейшая разработка. Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import {
|
|
asns,
|
|
domains,
|
|
filters,
|
|
greTunnels,
|
|
ipRanges,
|
|
pingProbes,
|
|
routerCertificates,
|
|
routerContainers,
|
|
servers,
|
|
} 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}к`
|
|
}
|
|
|
|
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),
|
|
"/filters": formatSidebarBadgeCount(filters.length),
|
|
"/wireguard": formatSidebarBadgeCount(mockWireGuardIfacesCount()),
|
|
"/gre": formatSidebarBadgeCount(greTunnels.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
|
|
}
|