Docker images / prepare-release (push) Successful in 10s
Docker images / backend-image (push) Successful in 1m57s
Docker images / frontend-image (push) Successful in 4m8s
Docker images / notify-webhook (push) Skipped
Docker images / updater-image (push) Successful in 44s
Docker images / publish-release (push) Successful in 11s
Added user management functionality, including the creation of app_users and user_interface_bindings tables in the database. Implemented API routes for user data retrieval and permissions handling. Enhanced the traffic monitoring system to include user traffic statistics and interface bindings. Updated relevant components and services to support the new user features, improving overall application functionality and user experience.
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { INIT_USERS } from "@/lib/users"
|
|
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),
|
|
"/users": formatSidebarBadgeCount(INIT_USERS.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
|
|
certificates?: number
|
|
wireguard?: number
|
|
users?: number
|
|
}
|