feat(ui): перенести трафик и карту сети на макет v3
Трафик: шапка деталей с названием, статусом и сегментным периодом; текущие и пиковые скорости двумя колонками; блоки «Доля RX» и «Интерфейсы сервера»; сегментная сортировка и поле поиска как в макете; в карточках списка нет текста мельче text-xs. Карта сети: KPI-полоса над картой (узлы со статусами-фильтрами, GRE-туннели, NetFlow за окно, узлы, требующие внимания), прокручиваемая страница с картой фиксированной высоты, поиск в стиле макета. На узких экранах KPI-полоса уходит под карту, чтобы карта помещалась в экран и работал жест панорамирования. Скриншоты docs/ux-ui обновлены прогоном e2e пилота. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8781f68674
commit
67b1d9cde2
19 files changed
+244
-91
No files matched your search
@@ -0,0 +1,102 @@
|
||||
"use client"
|
||||
|
||||
import type { Server } from "@/lib/data"
|
||||
import { fmtRate } from "@/lib/fmt-rate"
|
||||
import { TONE_COLOR, type Tone } from "@/components/reui-kit/ops-blocks"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
type StatusFilter = "online" | "degraded" | "offline"
|
||||
|
||||
const STATUS: Array<{ key: StatusFilter; label: string; tone: Tone }> = [
|
||||
{ key: "online", label: "Онлайн", tone: "ok" },
|
||||
{ key: "degraded", label: "Внимание", tone: "wn" },
|
||||
{ key: "offline", label: "Оффлайн", tone: "er" },
|
||||
]
|
||||
|
||||
function Seg({ parts }: { parts: Array<{ n: number; color: string }> }) {
|
||||
const shown = parts.filter((part) => part.n > 0)
|
||||
return (
|
||||
<div aria-hidden="true" className="flex h-1.5 gap-0.5">
|
||||
{shown.length ? shown.map((part, i) => <i key={i} className="block h-full min-w-1.5 rounded-full" style={{ flex: part.n, background: part.color }} />) : <i className="bg-muted block h-full flex-1 rounded-full" />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Card({ title, value, unit, children }: { title: string; value: string; unit: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="bg-card flex min-w-0 flex-col gap-2 rounded-xl border px-4 py-3.5">
|
||||
<small className="text-muted-foreground text-xs font-medium">{title}</small>
|
||||
<div className="flex items-baseline gap-1.5 text-2xl leading-tight font-semibold tracking-tight tabular-nums">
|
||||
{value}
|
||||
<em className="text-muted-foreground text-[13px] font-normal tracking-normal not-italic">{unit}</em>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* KPI-полоса над картой (макет v3): узлы, GRE-туннели, NetFlow и узлы, требующие внимания.
|
||||
* Счётчики статусов фильтруют карту, строки проблем открывают узел.
|
||||
*/
|
||||
export function MapKpiStrip({ servers, tunnels, netflowBytes, windowSec, filter, onFilter, onSelect, className }: {
|
||||
servers: Server[]
|
||||
tunnels: Array<{ status: "up" | "down" | "degraded" }>
|
||||
/** Байты NetFlow за окно; null — потоки не загружены. */
|
||||
netflowBytes: number | null
|
||||
windowSec: number
|
||||
filter: string
|
||||
onFilter: (key: StatusFilter | "all") => void
|
||||
onSelect: (server: Server) => void
|
||||
className?: string
|
||||
}) {
|
||||
const count = (status: Server["status"]) => servers.filter((server) => server.status === status).length
|
||||
const up = tunnels.filter((tunnel) => tunnel.status === "up").length
|
||||
const degraded = tunnels.filter((tunnel) => tunnel.status === "degraded").length
|
||||
const problems = servers.filter((server) => server.enabled !== false && server.status !== "online")
|
||||
const minutes = Math.max(1, Math.round(windowSec / 60))
|
||||
return (
|
||||
<div className={cn("grid grid-cols-[repeat(auto-fit,minmax(min(240px,100%),1fr))] gap-3", className)}>
|
||||
<Card title="Узлы на карте" value={String(servers.length)} unit="устройств">
|
||||
<Seg parts={STATUS.map((s) => ({ n: count(s.key), color: TONE_COLOR[s.tone] }))} />
|
||||
<div className="-mx-1.5 -mb-1 flex flex-wrap gap-0.5">
|
||||
{STATUS.map((s) => (
|
||||
<button
|
||||
key={s.key}
|
||||
type="button"
|
||||
aria-pressed={filter === s.key}
|
||||
onClick={() => onFilter(filter === s.key ? "all" : s.key)}
|
||||
className={cn("text-muted-foreground hover:bg-muted/70 inline-flex h-[26px] items-center gap-1.5 rounded-md border border-transparent px-1.5 text-[12.5px] transition-colors", filter === s.key && "bg-muted border-border text-foreground")}
|
||||
>
|
||||
<span aria-hidden="true" className="size-2 rounded-full" style={{ background: TONE_COLOR[s.tone] }} />
|
||||
{s.label}
|
||||
<b className="text-foreground font-semibold tabular-nums">{count(s.key)}</b>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
<Card title="GRE-туннели на карте" value={tunnels.length ? `${up} из ${tunnels.length}` : "—"} unit="работают">
|
||||
<Seg parts={[{ n: up, color: TONE_COLOR.ok }, { n: degraded, color: TONE_COLOR.wn }, { n: tunnels.length - up - degraded, color: TONE_COLOR.er }]} />
|
||||
<div className="text-muted-foreground text-xs">{tunnels.length ? `Деградация: ${degraded} · недоступны: ${tunnels.length - up - degraded}` : "Туннелей на карте нет"}</div>
|
||||
</Card>
|
||||
<Card title={`NetFlow · окно ${minutes} мин`} value={netflowBytes == null ? "—" : fmtRate((netflowBytes * 8) / Math.max(1, windowSec))} unit="через Exit-узлы">
|
||||
<Seg parts={[{ n: netflowBytes ? 1 : 0, color: "var(--chart-4)" }]} />
|
||||
<div className="text-muted-foreground text-xs">{netflowBytes == null ? "Потоки ещё не загружены" : "Средняя скорость за окно потоков"}</div>
|
||||
</Card>
|
||||
<Card title="Требуют внимания" value={String(problems.length)} unit="узлов">
|
||||
{problems.length ? (
|
||||
<div className="-mx-1.5 -mb-1 flex flex-col">
|
||||
{problems.slice(0, 3).map((server) => (
|
||||
<button key={server.id} type="button" onClick={() => onSelect(server)} className="hover:bg-muted/70 flex min-h-[26px] items-center gap-2 rounded-md px-1.5 text-left text-[12.5px] transition-colors">
|
||||
<span aria-hidden="true" className="size-2 shrink-0 rounded-full" style={{ background: TONE_COLOR[server.status === "offline" ? "er" : server.status === "degraded" ? "wn" : "mu"] }} />
|
||||
<span className="min-w-0 flex-1 truncate">{server.name} — {server.status === "offline" ? "нет ответа" : server.status === "degraded" ? "ухудшение" : "статус неизвестен"}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-muted-foreground text-xs">Проблемных узлов нет</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user