"use client" import Link from "next/link" import { buttonVariants } from "@/components/ui/button" import { Alert, AlertDescription, AlertTitle } from "@/components/reui/alert" import { SectionFrame, TONE_COLOR, type Tone } from "@/components/reui-kit/ops-blocks" import type { InternetPathViewModel } from "@/lib/dashboard-internet-path" import type { ServerStatus } from "@/lib/data" import { InternetPathSummary } from "@/components/dashboard/internet-path-summary" const STATUS_TONE: Record = { online: "ok", degraded: "wn", offline: "er", unknown: "mu" } const X = [13, 37, 62, 86] type TopoNode = { label: string; sub: string; tone: Tone } /** Схема пути Home → WAN → JH → Exit (блок topo макета v3); участок WAN→JH — модель связности, пунктиром. */ function InternetPathTopo({ model }: { model: InternetPathViewModel | null }) { const hop = model?.currentHop ?? model?.primaryHop ?? null const wan = hop?.wan ?? model?.activeWanUplink ?? null const jh = hop?.jumpHost ?? model?.fallbackJumpHost ?? null const exit = hop?.exitNode ?? model?.fallbackExitNode ?? null if (!model || !jh || !exit) { return

Нет полного набора узлов для схемы пути

} const nodes: TopoNode[] = [ { label: model.homeRouter.name, sub: "Home Router", tone: STATUS_TONE[model.homeRouter.status] }, { label: wan ? wan.isp || wan.name : "WAN", sub: wan ? `WAN-аплинк ${wan.iface}` : "WAN не определён", tone: wan ? "ok" : "mu" }, { label: jh.name, sub: "JumpHost", tone: STATUS_TONE[jh.status] }, { label: exit.name, sub: `Exit Node${exit.country ? ` · ${exit.country}` : ""}`, tone: STATUS_TONE[exit.status] }, ] const links: Array<{ label: string | null; dashed: boolean }> = [ { label: null, dashed: false }, { label: hop?.wanJhMetrics.pingMs != null ? String(hop.wanJhMetrics.pingMs) : null, dashed: true }, { label: hop?.jhExitMetrics.pingMs != null ? String(hop.jhExitMetrics.pingMs) : null, dashed: false }, ] return (
n.label).join(" → ")}`}> {links.map((link, i) => link.label ? ( {link.label} ) : null)} {nodes.map((node, i) => (
{node.label} {node.sub}
))}
) } /** Internet path и Сводка маршрута — два блока макета v3 (topo и kv). */ export function InternetPathPanel({ model, loading, error, }: { model: InternetPathViewModel | null loading?: boolean error?: string | null }) { return ( <> Карта сети →} panelClassName="overflow-x-auto bg-[radial-gradient(var(--border)_1px,transparent_1px)] bg-size-[20px_20px]" > {error ? ( Не удалось загрузить путь {error} ) : null}
{loading && !model ?
: }
{loading && !model ?
: } ) }