Этап 0 и пилот интеграции макета v3: - оболочка: inset-сайдбар, крошки «Главная / … /», индикатор свежести, заголовок страницы PageTitle; - общие блоки reui-kit/ops-blocks: SectionFrame, CapacityGrid, SparkKpiGrid, ToneBadge; - дашборд: ёмкость, показатели со спарклайнами, сводка источников, вкладки «Обзор / Источники и время получения / История RTT», здоровье сети, лента инцидентов, схема Internet path, сводка маршрута, таблица «Требует внимания», настройка видимости виджетов; - статистика: вкладки «Обзор / Сводная (куб) / Срезы», доли объёма; - трафик: вкладки разделов со счётчиками, рамки списка и деталей, кнопка «Месячный отчёт». Co-Authored-By: Claude Opus 5.5 <[email protected]>
96 lines
5.1 KiB
TypeScript
96 lines
5.1 KiB
TypeScript
"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<ServerStatus, Tone> = { 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 <p className="text-muted-foreground flex h-[300px] items-center justify-center text-sm">Нет полного набора узлов для схемы пути</p>
|
|
}
|
|
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 (
|
|
<div className="relative h-[300px]" role="img" aria-label={`Путь: ${nodes.map((n) => n.label).join(" → ")}`}>
|
|
<svg className="absolute inset-0 size-full" aria-hidden="true">
|
|
{links.map((link, i) => (
|
|
<line key={i} x1={`${X[i]}%`} y1="50%" x2={`${X[i + 1]}%`} y2="50%" stroke={link.dashed ? "var(--warning)" : "var(--success)"} strokeWidth="1.5" strokeDasharray={link.dashed ? "5 5" : undefined} />
|
|
))}
|
|
</svg>
|
|
{links.map((link, i) => link.label ? (
|
|
<span key={i} className="bg-card absolute -translate-1/2 rounded-[5px] border px-2 py-0.5 font-mono text-xs" style={{ left: `${(X[i] + X[i + 1]) / 2}%`, top: "50%" }}>{link.label}</span>
|
|
) : null)}
|
|
{nodes.map((node, i) => (
|
|
<div key={i} className="bg-card absolute flex min-w-[132px] -translate-1/2 items-center gap-2 rounded-[9px] border-[1.5px] py-1.5 pr-3 pl-2.5" style={{ left: `${X[i]}%`, top: "50%", borderColor: TONE_COLOR[node.tone] }}>
|
|
<span className="size-2 shrink-0 rounded-full" style={{ background: TONE_COLOR[node.tone] }} />
|
|
<span className="min-w-0">
|
|
<b className="block text-[13px] font-semibold whitespace-nowrap">{node.label}</b>
|
|
<span className="text-muted-foreground block text-xs whitespace-nowrap">{node.sub}</span>
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** Internet path и Сводка маршрута — два блока макета v3 (topo и kv). */
|
|
export function InternetPathPanel({
|
|
model,
|
|
loading,
|
|
error,
|
|
}: {
|
|
model: InternetPathViewModel | null
|
|
loading?: boolean
|
|
error?: string | null
|
|
}) {
|
|
return (
|
|
<>
|
|
<SectionFrame
|
|
title="Internet path"
|
|
description="Home → WAN → JH → Exit · пунктир WAN→JH — модель связности, маршрут не подтверждён"
|
|
actions={<Link href="/network-map" className={buttonVariants({ variant: "outline", size: "sm" })}>Карта сети →</Link>}
|
|
panelClassName="overflow-x-auto bg-[radial-gradient(var(--border)_1px,transparent_1px)] bg-size-[20px_20px]"
|
|
>
|
|
{error ? (
|
|
<Alert variant="destructive" className="m-3 w-auto">
|
|
<AlertTitle>Не удалось загрузить путь</AlertTitle>
|
|
<AlertDescription>{error}</AlertDescription>
|
|
</Alert>
|
|
) : null}
|
|
<div className="min-w-[720px]">
|
|
{loading && !model ? <div className="bg-muted/40 m-4 h-[268px] animate-pulse rounded-md" /> : <InternetPathTopo model={model} />}
|
|
</div>
|
|
</SectionFrame>
|
|
<SectionFrame
|
|
title="Сводка маршрута"
|
|
description={`Модель связности; маршрут не подтверждён. ${model?.currentPath?.reason ?? "Текущий маршрут не подтверждён"}`}
|
|
>
|
|
{loading && !model ? <div className="bg-muted/40 m-4 h-20 animate-pulse rounded-md" /> : <InternetPathSummary model={model} />}
|
|
</SectionFrame>
|
|
</>
|
|
)
|
|
}
|