Compare commits

...
1 Commits
Author SHA1 Message Date
Denozordec 4900101b5e fix(ui): обновить раздел точек обмена и выбор типа узла
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 3m34s
Docker images / updater-image (push) Successful in 2m36s
Docker images / netflow-agent-image (push) Successful in 36s
Docker images / backend-image (push) Successful in 16s
Docker images / publish-release (push) Failing after 10s
Docker images / notify-webhook (push) Successful in 2s
2026-11-23 02:07:56 +07:00
5 changed files with 566 additions and 186 deletions

No files matched your search

+159
View File
@@ -0,0 +1,159 @@
"use client"
import { useMemo } from "react"
import { type ColumnDef, useTable } from "@tanstack/react-table"
import { FileTextIcon, PlusIcon, XIcon } from "lucide-react"
import type { IxConfiguration, IxSegment, IxSite, IxSiteObservation } from "@mmapp/contracts/internet-exchange"
import { DataGridShell } from "@/components/data-grids/shared/data-grid-shell"
import { EmptyState } from "@/components/empty-state"
import { Badge } from "@/components/reui/badge"
import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
import { Frame, FrameDescription, FrameHeader, FramePanel, FrameTitle } from "@/components/reui/frame"
import { Button } from "@/components/ui/button"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
export type IxNode = { id: number; name: string; site: string; country: string; enabled: boolean }
type Route = IxSiteObservation["routes"][number]
export const nodeLabel = (nodes: readonly IxNode[], id: number) => nodes.find(node => node.id === id)?.name || `Узел ${id}`
export const newSite = (): IxSite => ({
serverId: 0, autonomousSystem: 64512, routerId: "",
interfaces: [], groups: [], exits: [], routes: [], neighbors: [], discardNetworks: [],
})
export function SegmentStatus({ segment }: { segment: IxSegment }) {
return segment.revision === segment.appliedRevision
? <Badge variant="success-light">Применена</Badge>
: <Badge variant="warning-light">{segment.appliedRevision ? "Есть черновик" : "Черновик"}</Badge>
}
export function SegmentGrid({ rows, nodes, loading, open, empty }: {
rows: IxSegment[]; nodes: IxNode[]; loading: boolean; open: (segment: IxSegment) => void; empty: React.ReactNode
}) {
const columns = useMemo<ColumnDef<DataGridFeatures, IxSegment>[]>(() => [
{ id: "name", header: "Сегмент", size: 210, cell: ({ row }) => (
<Button type="button" variant="link" size="sm" className="max-w-full justify-start" onClick={() => open(row.original)}>
<span className="truncate">{row.original.configuration.name}</span>
</Button>
) },
{ id: "sites", header: "Площадки", size: 230, cell: ({ row }) => row.original.configuration.sites.map(site => nodeLabel(nodes, site.serverId)).join(", ") },
{ id: "neighbors", header: "BGP-соседи", size: 115, cell: ({ row }) =>
<span className="tabular-nums">{row.original.configuration.sites.reduce((total, site) => total + site.neighbors.length, 0)}</span> },
{ id: "state", header: "Состояние", size: 140, cell: ({ row }) => <SegmentStatus segment={row.original} /> },
], [nodes, open])
const table = useTable({ features: dataGridFeatures, manualPagination: true, data: rows, columns, getRowId: row => row.id })
return <DataGridShell table={table} recordCount={rows.length} isLoading={loading} loadingMode="skeleton" emptyMessage={empty} />
}
export function ConfigurationFields({ configuration, nodes, readOnly, change }: {
configuration: IxConfiguration; nodes: IxNode[]; readOnly: boolean; change: (value: IxConfiguration) => void
}) {
function updateSite(index: number, fields: Partial<IxSite>) {
change({ ...configuration, sites: configuration.sites.map((site, position) => position === index ? { ...site, ...fields } : site) })
}
const canAddSite = configuration.sites.length < 2 && nodes.filter(node => node.enabled).length > configuration.sites.length
return <div className="grid min-w-0 gap-3">
<Frame spacing="sm">
<FrameHeader><FrameTitle>Сегмент</FrameTitle></FrameHeader>
<FramePanel>
<Field className="max-w-md">
<FieldLabel htmlFor="ix-name">Имя сегмента</FieldLabel>
<Input id="ix-name" placeholder="ix-central" value={configuration.name} readOnly={readOnly}
onChange={event => change({ ...configuration, name: event.target.value })} />
{!readOnly && <FieldDescription>Латинские строчные буквы, цифры и дефисы.</FieldDescription>}
</Field>
</FramePanel>
</Frame>
{configuration.sites.map((site, index) => {
const fieldId = `ix-site-${index}`
const choices = nodes.filter(node => node.id === site.serverId || (node.enabled && !configuration.sites.some((other, i) => i !== index && other.serverId === node.id)))
return <Frame key={fieldId} spacing="sm">
<FrameHeader className="flex-row items-center justify-between gap-2">
<div className="min-w-0">
<FrameTitle>Площадка {index + 1}</FrameTitle>
{site.serverId > 0 && <FrameDescription className="wrap-anywhere">{nodeLabel(nodes, site.serverId)}</FrameDescription>}
</div>
{!readOnly && configuration.sites.length > 1 && <Button type="button" size="icon-sm" variant="ghost"
aria-label={`Убрать площадку ${index + 1}`}
onClick={() => change({ ...configuration, sites: configuration.sites.filter((_, position) => position !== index) })}>
<XIcon aria-hidden />
</Button>}
</FrameHeader>
<FramePanel className="grid gap-4">
<div className="grid min-w-0 gap-3 sm:grid-cols-2 lg:grid-cols-3">
<Field className="min-w-0">
<FieldLabel htmlFor={fieldId}>Узел IX</FieldLabel>
<Select
value={site.serverId ? String(site.serverId) : null}
items={choices.map(node => ({ value: String(node.id), label: node.name }))}
disabled={readOnly}
onValueChange={value => { if (value) updateSite(index, { serverId: Number(value) }) }}
>
<SelectTrigger id={fieldId} className="w-full"><SelectValue placeholder="Выберите узел" /></SelectTrigger>
<SelectContent>
{choices.map(node => <SelectItem key={node.id} value={String(node.id)} disabled={!node.enabled}>{node.name}</SelectItem>)}
</SelectContent>
</Select>
</Field>
<Field className="min-w-0">
<FieldLabel htmlFor={fieldId + "-asn"}>Локальный ASN</FieldLabel>
<Input id={fieldId + "-asn"} inputMode="numeric" value={site.autonomousSystem || ""} readOnly={readOnly}
onChange={event => { if (/^\d*$/.test(event.target.value)) updateSite(index, { autonomousSystem: Number(event.target.value) }) }} />
</Field>
<Field className="min-w-0">
<FieldLabel htmlFor={fieldId + "-router"}>Router ID</FieldLabel>
<Input id={fieldId + "-router"} placeholder="192.0.2.10" value={site.routerId} readOnly={readOnly}
onChange={event => updateSite(index, { routerId: event.target.value })} />
</Field>
</div>
<dl className="grid grid-cols-2 gap-3 border-t pt-3 text-sm sm:grid-cols-4">
{[
["Интерфейсы", site.interfaces.length], ["Группы шлюзов", site.groups.length],
["Маршруты", site.routes.length], ["BGP-соседи", site.neighbors.length],
].map(([label, count]) => <div className="grid gap-0.5" key={label}>
<dt className="text-xs text-muted-foreground">{label}</dt>
<dd className="font-medium tabular-nums">{count}</dd>
</div>)}
</dl>
</FramePanel>
</Frame>
})}
{!readOnly && canAddSite && <Button type="button" variant="outline" size="sm" className="w-fit"
onClick={() => change({ ...configuration, sites: [...configuration.sites, newSite()] })}>
<PlusIcon aria-hidden />Добавить площадку
</Button>}
</div>
}
const routeColumns: ColumnDef<DataGridFeatures, Route>[] = [
{ id: "prefix", header: "Префикс", size: 160, cell: ({ row }) => <span className="font-mono">{row.original.prefix}</span> },
{ id: "gateway", header: "Шлюз", size: 140, cell: ({ row }) => row.original.gateway || "—" },
{ id: "immediate", header: "Фактический next hop", size: 200, cell: ({ row }) => row.original.immediateGateway ?? "—" },
{ id: "active", header: "Состояние", size: 112, cell: ({ row }) => row.original.active
? <Badge variant="success-light">Активен</Badge>
: <Badge variant="secondary">Неактивен</Badge> },
]
export function RouteGrid({ observation, nodes }: { observation: IxSiteObservation; nodes: IxNode[] }) {
const table = useTable({ features: dataGridFeatures, manualPagination: true, data: observation.routes, columns: routeColumns })
return <Frame spacing="sm" className="min-w-0">
<FrameHeader className="flex-row flex-wrap items-center justify-between gap-2">
<div className="min-w-0">
<FrameTitle className="wrap-anywhere">{nodeLabel(nodes, observation.serverId)}</FrameTitle>
<FrameDescription>{new Date(observation.observedAt).toLocaleString("ru-RU")}</FrameDescription>
</div>
{observation.available ? <Badge variant="info-light">
BGP {observation.neighbors.filter(peer => peer.established).length} из {observation.neighbors.length}
</Badge> : <Badge variant="warning-light">Состояние недоступно</Badge>}
</FrameHeader>
{observation.available && <FramePanel className="min-w-0 p-0">
<div className="overflow-x-auto">
<DataGridShell table={table} recordCount={observation.routes.length}
emptyMessage={<EmptyState icon={<FileTextIcon />} title="Маршруты не найдены" className="py-8" />} />
</div>
</FramePanel>}
</Frame>
}
+274 -173
View File
@@ -1,250 +1,351 @@
"use client"
import { useEffect, useMemo, useState } from "react"
import { useEffect, useRef, useState } from "react"
import Link from "next/link"
import { NetworkIcon, PlusIcon, RefreshCwIcon } from "lucide-react"
import { type ColumnDef, useTable } from "@tanstack/react-table"
import { ixSegmentConfigurationSchema, type IxChange, type IxRouterObject, type IxSegment, type IxSiteObservation } from "@mmapp/contracts/internet-exchange"
import { ArrowLeftIcon, CircleAlertIcon, NetworkIcon, PlusIcon, RefreshCwIcon } from "lucide-react"
import { ixSegmentConfigurationSchema, type IxChange, type IxConfiguration, type IxRouterObject, type IxSegment, type IxSiteObservation } from "@mmapp/contracts/internet-exchange"
import { Alert, AlertDescription, AlertTitle } from "@/components/reui/alert"
import { Badge } from "@/components/reui/badge"
import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
import { DataGridShell } from "@/components/data-grids/shared/data-grid-shell"
import { Frame, FrameDescription, FrameHeader, FramePanel, FrameTitle } from "@/components/reui/frame"
import { EmptyState } from "@/components/empty-state"
import { PageHeader } from "@/components/page-header"
import { Button, buttonVariants } from "@/components/ui/button"
import { Button } from "@/components/ui/button"
import { Field, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Skeleton } from "@/components/ui/skeleton"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Textarea } from "@/components/ui/textarea"
import { can, ensureAuthConfig } from "@/lib/auth"
import { useDataSource } from "@/lib/data-source"
import { requestJson } from "@/shared/api/http-client"
import { mcpApi } from "@/shared/api/mcp"
import { ConfigurationFields, newSite, RouteGrid, SegmentGrid, SegmentStatus, type IxNode } from "./ix-view"
type Node = { id: number; name: string; site: string; country: string; enabled: boolean }
type Connection = { id: string; name: string }
type Plan = { planId: string; state: string }
type Tab = "configuration" | "routes" | "changes"
const title = "Точки обмена трафиком"
const describe = (error: unknown) => error instanceof Error ? error.message : "Не удалось выполнить операцию IX"
const json = (value: unknown) => JSON.stringify(value, null, 2)
const post = (value: unknown) => ({ method: "POST", body: JSON.stringify(value) })
function SegmentGrid({ rows, open }: { rows: IxSegment[]; open: (segment: IxSegment) => void }) {
const columns: ColumnDef<DataGridFeatures, IxSegment>[] = [
{ id: "name", header: "Сегмент", cell: ({ row }) => <Button variant="ghost" size="sm" onClick={() => open(row.original)}>{row.original.configuration.name}</Button> },
{ id: "sites", header: "Площадки", cell: ({ row }) => row.original.configuration.sites.length },
{ id: "neighbors", header: "BGP-соседи", cell: ({ row }) => row.original.configuration.sites.reduce((total, site) => total + site.neighbors.length, 0) },
{ id: "state", header: "Состояние конфигурации", cell: ({ row }) => row.original.revision === row.original.appliedRevision
? <Badge variant="success-light">Применена</Badge>
: <Badge variant="warning-light">Черновик</Badge> },
]
const table = useTable({ features: dataGridFeatures, manualPagination: true, data: rows, columns, getRowId: row => row.id })
return <DataGridShell table={table} recordCount={rows.length} />
const planStates: Record<string, string> = {
draft: "Черновик плана", "awaiting-approval": "Ждёт подтверждения", approved: "Подтверждён",
pending: "В очереди", running: "Выполняется", completed: "Завершён", applied: "Применён",
rejected: "Отклонён", expired: "Истёк", failed: "Ошибка", partial: "Выполнен частично", unknown: "Нужна сверка",
}
export default function IxPage() {
const { backendUrl, mode, prefsHydrated } = useDataSource()
const [segments, setSegments] = useState<IxSegment[]>([])
const [nodes, setNodes] = useState<Node[]>([])
const [nodes, setNodes] = useState<IxNode[]>([])
const [connections, setConnections] = useState<Connection[]>([])
const [connectionId, setConnectionId] = useState("")
const [connectionError, setConnectionError] = useState("")
const [selected, setSelected] = useState<IxSegment | null>(null)
const [editing, setEditing] = useState(false)
const [body, setBody] = useState("")
const [draft, setDraft] = useState<IxConfiguration | null>(null)
const [advanced, setAdvanced] = useState<string | null>(null)
const [filter, setFilter] = useState("")
const [nodeId, setNodeId] = useState("")
const [name, setName] = useState("")
const [asn, setAsn] = useState("64512")
const [routerId, setRouterId] = useState("")
const [observations, setObservations] = useState<IxSiteObservation[]>([])
const [observations, setObservations] = useState<IxSiteObservation[] | null>(null)
const [preview, setPreview] = useState<IxRouterObject[] | null>(null)
const [linux, setLinux] = useState("")
const [plan, setPlan] = useState<Plan | null>(null)
const [tab, setTab] = useState<"configuration" | "routes" | "changes">("configuration")
const [tab, setTab] = useState<Tab>("configuration")
const [loading, setLoading] = useState(true)
const [busy, setBusy] = useState(false)
const [error, setError] = useState("")
const [notice, setNotice] = useState("")
const [write, setWrite] = useState(false)
const [approve, setApprove] = useState(false)
const heading = useRef<HTMLHeadingElement>(null)
const focusAfterNavigation = useRef(false)
const inDetail = draft !== null
async function load(signal?: AbortSignal) {
const options = { signal }
if (signal?.aborted) return
setWrite(can("mm:network:write"))
setApprove(can("mm:mcp:approve"))
const [segmentsResult, nodesResult] = await Promise.all([
requestJson<{ items: IxSegment[] }>(backendUrl, "/api/ix/segments?limit=100", options),
requestJson<{ items: Node[] }>(backendUrl, "/api/ix/nodes", options),
requestJson<{ items: IxSegment[] }>(backendUrl, "/api/ix/segments?limit=100", { signal }),
requestJson<{ items: IxNode[] }>(backendUrl, "/api/ix/nodes", { signal }),
])
if (signal?.aborted) return
setSegments(segmentsResult.items)
setNodes(nodesResult.items)
if (can("mm:mcp:read")) {
const { connections } = await mcpApi(backendUrl).connections(signal)
setConnections(connections.filter(connection => connection.policy.status === "active" &&
connection.policy.scope.operationIds.includes("network.ix.configure")).map(connection => ({ id: connection.id, name: connection.name })))
setConnectionError("")
if (!can("mm:mcp:read")) {
setConnections([])
setConnectionId("")
return
}
try {
const result = await mcpApi(backendUrl).connections(signal)
if (signal?.aborted) return
const available = result.connections.filter(connection => connection.policy.status === "active" &&
connection.policy.scope.operationIds.includes("network.ix.configure"))
setConnections(available.map(connection => ({ id: connection.id, name: connection.name })))
setConnectionId(current => available.some(connection => connection.id === current) ? current : available.length === 1 ? available[0].id : "")
} catch (error) {
if (signal?.aborted) return
setConnections([])
setConnectionId("")
setConnectionError(describe(error))
}
}
useEffect(() => {
if (!prefsHydrated || mode !== "live") return
const controller = new AbortController()
void ensureAuthConfig().then(async () => {
void ensureAuthConfig().then(() => {
if (controller.signal.aborted) return
setWrite(can("mm:network:write"))
setApprove(can("mm:mcp:approve"))
await load(controller.signal)
}).catch(error => { if (!controller.signal.aborted) setError(describe(error)) })
setLoading(true)
setError("")
return load(controller.signal)
})
.catch(error => { if (!controller.signal.aborted) setError(describe(error)) })
.finally(() => { if (!controller.signal.aborted) setLoading(false) })
return () => controller.abort()
// Load only when the project source changes.
// Reload when the project data source changes.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [backendUrl, mode, prefsHydrated])
const rows = useMemo(() => segments.filter(segment => segment.configuration.name.includes(filter.toLowerCase().trim())), [filter, segments])
function open(segment: IxSegment | null) {
setSelected(segment)
setBody(segment ? json(segment.configuration) : "")
setPreview(null)
useEffect(() => {
if (focusAfterNavigation.current) {
focusAfterNavigation.current = false
heading.current?.focus()
}
}, [inDetail])
const rows = segments.filter(segment => segment.configuration.name.includes(filter.trim().toLowerCase()))
const enabledNodes = nodes.filter(node => node.enabled)
const live = prefsHydrated && mode === "live"
const canCreate = live && write && !loading && enabledNodes.length > 0
function invalidateReview() {
setPlan(null)
setObservations([])
setPreview(null)
setNotice("")
}
function open(segment: IxSegment | null) {
focusAfterNavigation.current = !inDetail
setSelected(segment)
setDraft(segment?.configuration ?? { name: "", sites: [{ ...newSite(), serverId: enabledNodes.length === 1 ? enabledNodes[0].id : 0 }] })
setAdvanced(null)
setObservations(null)
setLinux("")
setTab("configuration")
setError("")
setEditing(true)
invalidateReview()
}
function close() {
focusAfterNavigation.current = true
setDraft(null)
setError("")
setNotice("")
}
function change(): IxChange {
const configuration = ixSegmentConfigurationSchema.parse(JSON.parse(body))
const configuration = ixSegmentConfigurationSchema.parse(advanced === null ? draft : JSON.parse(advanced))
return { ...(selected ? { id: selected.id } : {}), revision: selected?.revision ?? 0, configuration }
}
async function perform(work: () => Promise<void>) {
setBusy(true)
setError("")
setNotice("")
try { await work() } catch (error) { setError(describe(error)) }
finally { setBusy(false) }
}
async function save() {
const { segment } = await requestJson<{ segment: IxSegment }>(backendUrl, "/api/ix/segments", post(change()))
open(segment)
await load()
}
async function observe() {
if (!selected) return
const { sites } = await requestJson<{ sites: IxSiteObservation[] }>(backendUrl, `/api/ix/segments/${selected.id}/status`)
setObservations(sites)
setTab("routes")
setSegments(current => current.some(item => item.id === segment.id)
? current.map(item => item.id === segment.id ? segment : item)
: [segment, ...current])
setNotice("Черновик сохранён")
}
async function observe() {
if (!selected?.appliedRevision) return
const { sites } = await requestJson<{ sites: IxSiteObservation[] }>(backendUrl, `/api/ix/segments/${selected.id}/status`)
setObservations(sites)
}
function showTab(next: Tab) {
if (next === tab || busy) return
setError("")
setTab(next)
if (next === "routes" && observations === null && selected?.appliedRevision) void perform(observe)
}
const listEmpty = error ? "Не удалось загрузить список" :
filter.trim() ? "Сегменты не найдены" : !live ? "Подключите backend" : "Нет сегментов IX"
const listDescription = error ? "Повторите загрузку списка." : filter.trim() ? "Попробуйте другое имя сегмента." :
!live ? "Откройте раздел в режиме «Живые»." : enabledNodes.length ? undefined : "Сначала добавьте сервер типа IX Node."
const linuxBindings = selected?.appliedRevision ? selected.configuration.sites.flatMap(site =>
site.interfaces.filter(binding => binding.provisionWireguard?.hubEndpoint).map(binding => ({ site, binding }))) : []
return <>
<PageHeader crumbs={[{ label: "Сеть" }, { label: "Точки обмена трафиком" }]} />
<div className="mx-auto flex w-full max-w-6xl flex-1 flex-col gap-6 p-4 md:p-6">
<div className="flex flex-wrap items-start justify-between gap-3">
<div>
<h1 className="text-2xl font-semibold tracking-tight">Точки обмена трафиком</h1>
<p className="mt-1 text-sm text-muted-foreground">IX-сегменты, маршруты и BGP-политики в отдельных VRF.</p>
</div>
<div className="flex gap-2">
<Button variant="outline" size="icon" disabled={busy || mode !== "live"} aria-label="Обновить список" onClick={() => void perform(() => load())}><RefreshCwIcon /></Button>
{write && <Button onClick={() => open(null)} disabled={busy}><PlusIcon />Добавить сегмент</Button>}
</div>
</div>
{error && <p role="alert" className="rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive">{error}</p>}
<div className="grid grid-cols-1 gap-3 sm:grid-cols-3">
{[{ name: "Узлы IX", count: nodes.length }, { name: "Сегменты", count: segments.length }, { name: "Применённые ревизии", count: segments.filter(segment => segment.appliedRevision === segment.revision).length }].map(item =>
<div key={item.name} className="rounded-lg border bg-card p-4">
<div className="text-sm text-muted-foreground">{item.name}</div>
<div className="mt-1 text-2xl font-semibold tabular-nums">{item.count}</div>
</div>
)}
</div>
<section className="flex flex-col gap-3" aria-label="IX-сегменты">
<Input aria-label="Поиск сегментов" placeholder="Найти сегмент" className="max-w-xs" value={filter} onChange={event => setFilter(event.target.value)} />
{rows.length ? <SegmentGrid rows={rows} open={open} /> :
<EmptyState icon={<NetworkIcon className="size-4" />} title={filter ? "Сегменты не найдены" : "Нет IX-сегментов"}
description={mode !== "live" ? "Сегменты доступны при подключении к серверу." : "Добавьте сервер типа IX Node, чтобы создать сегмент."} />}
</section>
{editing && <section className="flex flex-col gap-4 rounded-lg border bg-card p-4" aria-label="Карточка IX">
<div className="flex flex-wrap items-center justify-between gap-2">
<h2 className="text-lg font-semibold">{selected?.configuration.name ?? "Новый сегмент"}</h2>
<Button variant="ghost" size="sm" onClick={() => setEditing(false)}>Закрыть</Button>
</div>
<div className="flex flex-wrap gap-2">
<Button size="sm" variant={tab === "configuration" ? "secondary" : "ghost"} onClick={() => setTab("configuration")}>Конфигурация</Button>
<Button size="sm" variant={tab === "routes" ? "secondary" : "ghost"} disabled={!selected?.appliedRevision || busy} onClick={() => void perform(observe)}>Маршруты и BGP</Button>
<Button size="sm" variant={tab === "changes" ? "secondary" : "ghost"} disabled={!preview && !plan} onClick={() => setTab("changes")}>Изменения</Button>
</div>
{tab === "configuration" && <>
{!body && <div className="grid gap-3 sm:grid-cols-2">
<div className="grid gap-2"><Label htmlFor="ix-name">Имя сегмента</Label><Input id="ix-name" placeholder="compute" value={name} onChange={event => setName(event.target.value)} /></div>
<div className="grid gap-2"><Label htmlFor="ix-site">Площадка</Label><select id="ix-site" className="h-9 rounded-md border bg-background px-3 text-sm" value={nodeId} onChange={event => setNodeId(event.target.value)}>
<option value="">Выберите IX Node</option>
{nodes.filter(node => node.enabled).map(node => <option key={node.id} value={node.id}>{node.name || node.id}</option>)}
</select></div>
<div className="grid gap-2"><Label htmlFor="ix-asn">Локальный ASN</Label><Input id="ix-asn" inputMode="numeric" value={asn} onChange={event => setAsn(event.target.value)} /></div>
<div className="grid gap-2"><Label htmlFor="ix-router-id">Router ID</Label><Input id="ix-router-id" placeholder="192.0.2.10" value={routerId} onChange={event => setRouterId(event.target.value)} /></div>
<Button variant="outline" disabled={!nodeId || !name || !routerId} onClick={() => void perform(async () => {
setBody(json(ixSegmentConfigurationSchema.parse({ name, sites: [{ serverId: Number(nodeId), autonomousSystem: Number(asn), routerId }] })))
})}>Подготовить конфигурацию</Button>
<Link className={buttonVariants({ variant: "link" })} href="/servers">Открыть каталог серверов</Link>
</div>}
{body && <div className="grid gap-2">
<Label htmlFor="ix-configuration">Конфигурация сегмента</Label>
<Textarea id="ix-configuration" spellCheck={false} readOnly={!write} rows={13} className="font-mono" value={body} onChange={event => {
setBody(event.target.value); setPlan(null); setPreview(null)
}} />
</div>}
{body && write && <div className="flex flex-wrap items-end gap-2">
<Button onClick={() => void perform(save)} disabled={busy}>Сохранить черновик</Button>
<Button variant="outline" disabled={busy} onClick={() => void perform(async () => {
const result = await requestJson<{ objects: IxRouterObject[] }>(backendUrl, "/api/ix/preview", post(change()))
setPreview(result.objects); setTab("changes")
})}>Предпросмотр</Button>
<div className="grid gap-2"><Label htmlFor="ix-connection">Подключение MCP</Label><select id="ix-connection" className="h-9 rounded-md border bg-background px-3 text-sm" value={connectionId} onChange={event => setConnectionId(event.target.value)}>
<option value="">Выберите подключение</option>
{connections.map(connection => <option key={connection.id} value={connection.id}>{connection.name}</option>)}
</select></div>
<Button variant="outline" disabled={!connectionId || busy} onClick={() => void perform(async () => {
setPlan(await requestJson<Plan>(backendUrl, "/api/mcp/ix/plan", post({ connectionId, change: change() })))
setTab("changes")
})}>Подготовить план MCP</Button>
</div>}
</>}
{tab === "changes" && <>
{preview && <div className="grid gap-2"><p className="text-sm">{preview.length} объектов в желаемой конфигурации</p>
<pre className="max-h-96 overflow-auto rounded-md border bg-muted/30 p-3 text-sm">{json(preview)}</pre></div>}
{plan && <div className="flex flex-wrap items-center gap-2">
<Badge variant="info-light">{plan.state}</Badge>
<span className="text-sm text-muted-foreground">{plan.planId}</span>
<Link className={buttonVariants({ variant: "link" })} href="/mcp">Планы и операции</Link>
{plan.state === "awaiting-approval" && approve && <Button variant="outline" disabled={busy} onClick={() => void perform(async () => {
await mcpApi(backendUrl).decision(plan.planId, true)
setPlan({ ...plan, state: "approved" })
})}>Подтвердить</Button>}
{["draft", "approved"].includes(plan.state) && <Button disabled={busy} onClick={() => void perform(async () => {
const result = await mcpApi(backendUrl).apply(plan.planId)
setPlan({ ...plan, state: result.state })
})}>Применить план</Button>}
</div>}
</>}
{tab === "routes" && <div className="grid gap-4">
{selected?.configuration.sites.flatMap(site => site.interfaces.filter(binding => binding.provisionWireguard?.hubEndpoint).map(binding =>
<Button key={site.serverId + ":" + binding.name} size="sm" variant="outline" className="w-fit" disabled={busy} onClick={() => void perform(async () => {
const query = new URLSearchParams({ serverId: String(site.serverId), interfaceName: binding.name })
const result = await requestJson<{ template: string }>(backendUrl, `/api/ix/segments/${selected.id}/linux?${query}`)
setLinux(result.template)
})}>Конфигурация Linux · {binding.name}</Button>
))}
{linux && <pre className="overflow-auto rounded-md border bg-muted/30 p-3 text-sm">{linux}</pre>}
{observations.map(site => <div key={site.serverId} className="grid gap-2">
<div className="flex flex-wrap justify-between gap-2 text-sm">
<span className="font-medium">{nodes.find(node => node.id === site.serverId)?.name || site.serverId}</span>
<span className="text-muted-foreground">{new Date(site.observedAt).toLocaleString()}</span>
<PageHeader crumbs={inDetail ? [{ label: "Сегменты IX" }, { label: selected?.configuration.name ?? "Новый сегмент" }] : [{ label: title }]} />
<div className="min-h-0 min-w-0 flex-1 overflow-y-auto">
<div className="mx-auto flex w-full max-w-6xl min-w-0 flex-col gap-4 p-4 md:gap-5 md:p-6" aria-busy={busy}>
{inDetail && <Button type="button" variant="ghost" size="sm" className="w-fit" disabled={busy} onClick={close}>
<ArrowLeftIcon aria-hidden />Все сегменты
</Button>}
<div className="flex flex-wrap items-center justify-between gap-3">
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-2">
<h1 ref={heading} tabIndex={-1} className="text-xl font-semibold tracking-tight wrap-anywhere md:text-2xl">
{inDetail ? selected?.configuration.name ?? "Новый сегмент" : title}
</h1>
{inDetail && selected && <SegmentStatus segment={selected} />}
</div>
{site.available ? <>
<p className="text-sm text-muted-foreground">Активные BGP-сессии {site.neighbors.filter(peer => peer.established).length} из {site.neighbors.length}</p>
<div className="overflow-x-auto"><table className="w-full text-left text-sm">
<thead><tr className="border-b"><th className="p-2">Префикс</th><th className="p-2">Шлюз</th><th className="p-2">Фактический next hop</th><th className="p-2">Активен</th></tr></thead>
<tbody>{site.routes.map((route, index) => <tr key={route.prefix + ":" + index} className="border-b">
<td className="p-2 font-mono">{route.prefix}</td><td className="p-2">{route.gateway || "—"}</td>
<td className="p-2">{route.immediateGateway ?? "Не подтверждён"}</td><td className="p-2">{route.active ? "Да" : "Нет"}</td>
</tr>)}</tbody>
</table></div>
</> : <Badge variant="warning-light">Состояние недоступно</Badge>}
</div>)}
</div>}
</section>}
{inDetail ? (selected && <p className="mt-1 text-sm text-muted-foreground">
Ревизия {selected.revision}{selected.appliedRevision ? ` · Применена ревизия ${selected.appliedRevision}` : ""}
</p>) : <p className="mt-1 text-sm text-muted-foreground">Сегменты IX, площадки и маршрутизация</p>}
</div>
{!inDetail && <div className="flex flex-wrap items-center gap-2">
<Button type="button" size="icon-sm" variant="outline" disabled={busy || loading || !live} aria-label="Обновить список"
onClick={() => void perform(() => load())}><RefreshCwIcon aria-hidden /></Button>
{canCreate && <Button type="button" size="sm" onClick={() => open(null)} disabled={busy}><PlusIcon aria-hidden />Добавить сегмент</Button>}
</div>}
</div>
{error && <Alert variant="destructive"><CircleAlertIcon aria-hidden /><AlertTitle>Ошибка IX</AlertTitle><AlertDescription className="wrap-anywhere">{error}</AlertDescription></Alert>}
{notice && <p role="status" className="text-sm text-muted-foreground">{notice}</p>}
{!draft ? <Frame spacing="sm" className="min-w-0">
<FrameHeader className="flex-row flex-wrap items-center justify-between gap-2">
<div><FrameTitle>Сегменты</FrameTitle><FrameDescription>{live && !loading ? `Найдено: ${rows.length}` : ""}</FrameDescription></div>
<Input type="search" aria-label="Поиск сегментов" placeholder="Найти сегмент" className="w-full sm:w-56"
value={filter} onChange={event => setFilter(event.target.value)} />
</FrameHeader>
<FramePanel className="min-w-0 p-0">
<div className="overflow-x-auto">
<SegmentGrid rows={rows} nodes={nodes} loading={!prefsHydrated || (live && loading)} open={open} empty={
<EmptyState icon={<NetworkIcon aria-hidden />} title={listEmpty} description={listDescription}
action={live && !filter.trim() && !error && enabledNodes.length === 0 ? <Button render={<Link href="/servers" />} nativeButton={false} size="sm" variant="outline">Открыть серверы</Button> : undefined} />
} />
</div>
</FramePanel>
</Frame> : <Tabs value={tab} onValueChange={value => showTab(value as Tab)} className="min-w-0 gap-3">
<div className="min-w-0 overflow-x-auto border-b pb-1">
<TabsList variant="line" aria-label="Разделы сегмента">
<TabsTrigger value="configuration">Конфигурация</TabsTrigger>
<TabsTrigger value="routes">Маршруты и BGP</TabsTrigger>
<TabsTrigger value="changes">План изменений</TabsTrigger>
</TabsList>
</div>
<TabsContent value="configuration" className="grid min-w-0 gap-3">
{advanced === null ? <ConfigurationFields configuration={draft} nodes={nodes} readOnly={!write || busy}
change={value => { setDraft(value); invalidateReview() }} /> : <Frame spacing="sm">
<FrameHeader><FrameTitle>Конфигурация JSON</FrameTitle><FrameDescription>Интерфейсы, группы шлюзов, маршруты и BGP-политики.</FrameDescription></FrameHeader>
<FramePanel>
<Textarea aria-label="Конфигурация JSON" spellCheck={false} readOnly={!write || busy} rows={14}
className="font-mono" value={advanced} onChange={event => { setAdvanced(event.target.value); invalidateReview() }} />
</FramePanel>
</Frame>}
<div className="flex flex-wrap items-center gap-2">
{write && <Button type="button" size="sm" disabled={busy} onClick={() => void perform(save)}>Сохранить черновик</Button>}
{advanced === null ? <Button type="button" size="sm" variant="outline" disabled={busy} onClick={() => setAdvanced(json(draft))}>
{write ? "Редактировать JSON" : "Показать JSON"}
</Button> : <Button type="button" size="sm" variant="outline" disabled={busy} onClick={() => void perform(async () => {
setDraft(change().configuration)
setAdvanced(null)
})}>К форме</Button>}
</div>
</TabsContent>
<TabsContent value="routes" className="grid min-w-0 gap-3">
{!selected?.appliedRevision ? <EmptyState title="Конфигурация ещё не применена"
description="Маршруты и BGP-сессии появятся после применения плана." className="py-8" /> : <>
<div className="flex flex-wrap gap-2">
<Button type="button" size="sm" variant="outline" disabled={busy} onClick={() => void perform(observe)}>
<RefreshCwIcon aria-hidden />Обновить состояние
</Button>
{linuxBindings.map(({ site, binding }) => <Button key={site.serverId + ":" + binding.name}
type="button" size="sm" variant="outline" disabled={busy} onClick={() => void perform(async () => {
const query = new URLSearchParams({ serverId: String(site.serverId), interfaceName: binding.name })
const result = await requestJson<{ template: string }>(backendUrl, `/api/ix/segments/${selected.id}/linux?${query}`)
setLinux(result.template)
})}>Linux · {binding.name}</Button>)}
</div>
{linux && <Frame spacing="sm"><FrameHeader><FrameTitle>Конфигурация Linux</FrameTitle></FrameHeader>
<FramePanel><pre className="overflow-x-auto text-xs">{linux}</pre></FramePanel></Frame>}
{busy && observations === null && <Skeleton className="h-28 w-full" role="status" aria-label="Загрузка маршрутов" />}
{observations?.map(site => <RouteGrid key={site.serverId} observation={site} nodes={nodes} />)}
</>}
</TabsContent>
<TabsContent value="changes" className="grid min-w-0 gap-3">
<Frame spacing="sm">
<FrameHeader>
<FrameTitle>Предпросмотр</FrameTitle>
<FrameDescription>Объекты RouterOS, которые создаёт текущая конфигурация.</FrameDescription>
</FrameHeader>
<FramePanel className="grid min-w-0 gap-3">
<Button type="button" size="sm" variant="outline" className="w-fit" disabled={busy} onClick={() => void perform(async () => {
const result = await requestJson<{ objects: IxRouterObject[] }>(backendUrl, "/api/ix/preview", post(change()))
setPreview(result.objects)
})}>Построить предпросмотр</Button>
{preview && <details className="min-w-0 border-t pt-3">
<summary className="cursor-pointer text-sm font-medium">Объекты RouterOS · {preview.length}</summary>
<pre className="mt-2 overflow-x-auto text-xs">{json(preview)}</pre>
</details>}
</FramePanel>
</Frame>
{write && <Frame spacing="sm">
<FrameHeader>
<FrameTitle>Применение через MCP</FrameTitle>
<FrameDescription>План, подтверждение и применение к площадкам сегмента.</FrameDescription>
</FrameHeader>
<FramePanel className="grid min-w-0 gap-4">
{connectionError && <p role="status" className="wrap-anywhere text-sm text-muted-foreground">{connectionError}</p>}
<div className="flex flex-wrap items-end gap-3">
<Field className="w-full min-w-0 sm:w-64">
<FieldLabel htmlFor="ix-connection">Подключение MCP</FieldLabel>
<Select value={connectionId || null} items={connections.map(connection => ({ value: connection.id, label: connection.name }))}
disabled={busy || connections.length === 0} onValueChange={value => { setConnectionId(value ?? ""); setPlan(null) }}>
<SelectTrigger id="ix-connection" className="w-full"><SelectValue placeholder={connections.length ? "Выберите подключение" : "Нет доступных подключений"} /></SelectTrigger>
<SelectContent>{connections.map(connection => <SelectItem key={connection.id} value={connection.id}>{connection.name}</SelectItem>)}</SelectContent>
</Select>
</Field>
<Button type="button" size="sm" disabled={!connectionId || busy} onClick={() => void perform(async () => {
setPlan(await requestJson<Plan>(backendUrl, "/api/mcp/ix/plan", post({ connectionId, change: change() })))
})}>Подготовить план MCP</Button>
{connections.length === 0 && <Button render={<Link href="/mcp?tab=connections" />} nativeButton={false} variant="outline" size="sm">Открыть подключения</Button>}
</div>
{plan && <div className="flex flex-wrap items-center gap-2 border-t pt-3">
<Badge variant={plan.state === "awaiting-approval" ? "warning-light" : plan.state === "applied" ? "success-light" : "info-light"}>{planStates[plan.state] ?? plan.state}</Badge>
<Button render={<Link href="/mcp?tab=plans" />} nativeButton={false} size="sm" variant="link">Планы и операции</Button>
{plan.state === "awaiting-approval" && approve && <Button type="button" size="sm" variant="outline" disabled={busy} onClick={() => void perform(async () => {
await mcpApi(backendUrl).decision(plan.planId, true)
setPlan({ ...plan, state: "approved" })
})}>Подтвердить</Button>}
{["draft", "approved"].includes(plan.state) && <Button type="button" size="sm" disabled={busy} onClick={() => void perform(async () => {
const name = change().configuration.name
const result = await mcpApi(backendUrl).apply(plan.planId)
setPlan({ ...plan, state: result.state })
if (result.state === "applied") {
const refreshed = await requestJson<{ items: IxSegment[] }>(backendUrl, "/api/ix/segments?limit=100")
setSegments(refreshed.items)
const applied = refreshed.items.find(segment => segment.id === selected?.id || segment.configuration.name === name)
if (applied) setSelected(applied)
}
})}>Применить план</Button>}
</div>}
</FramePanel>
</Frame>}
</TabsContent>
</Tabs>}
</div>
</div>
</>
}
+25 -13
View File
@@ -38,6 +38,8 @@ import { cn } from "@/lib/utils"
import { KpiStatGrid } from "@/components/reui-kit/kpi-stat-grid"
import { DataPageCard } from "@/components/data-page-card"
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"
import { Field, FieldTitle } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import {
Sheet, SheetContent, SheetHeader, SheetTitle,
@@ -772,19 +774,29 @@ function ServersPageContent() {
value={form.name} onChange={e => set("name", e.target.value)} />
</FormField>
<FormField label="Тип узла" required>
<SegmentedControl
className="max-w-full flex-wrap"
value={form.type}
onChange={v => set("type", v)}
options={[
{ value: "home-router", label: "Home Router" },
{ value: "jump-host", label: "JumpHost" },
{ value: "exit-node", label: "Exit Node" },
{ value: "ix-node", label: "IX Node" },
]}
/>
</FormField>
<Field>
<FieldTitle id="server-node-type-label">Тип узла <span aria-hidden className="text-destructive">*</span></FieldTitle>
<ButtonGroup aria-labelledby="server-node-type-label" className="max-w-full">
{([
["home-router", "Home Router"],
["jump-host", "JumpHost"],
["exit-node", "Exit Node"],
["ix-node", "IX Node"],
] as const).map(([value, label]) => (
<Button
key={value}
type="button"
variant={form.type === value ? "default" : "outline"}
size="sm"
aria-pressed={form.type === value}
className="h-auto min-h-7 min-w-0 flex-auto shrink whitespace-normal py-1"
onClick={() => set("type", value)}
>
{label}
</Button>
))}
</ButtonGroup>
</Field>
<div className="grid grid-cols-2 gap-3">
<FormField label="Площадка" required hint="MSK, SPB, FRA…">
+85
View File
@@ -0,0 +1,85 @@
import { expect, test } from "@playwright/test"
import { ixChangeSchema, ixSegmentConfigurationSchema } from "@mmapp/contracts/internet-exchange"
import { mcpLimitsSchema } from "@mmapp/contracts/mcp"
const id = "fa58fa40-4bcb-4616-9316-cb69463b3150"
const observedAt = "2026-11-20T00:00:00Z"
const nodes = [
{ id: 1, name: "ix-node-01", site: "TEST-1", country: "DE", enabled: true },
{ id: 2, name: "ix-node-02", site: "TEST-2", country: "FI", enabled: true },
]
test("IX: карточка доступна на узком экране, сохранение удерживает настройки маршрутизации", async ({ page }, testInfo) => {
const configuration = ixSegmentConfigurationSchema.parse({ name: "ix-central", sites: [
{ serverId: 1, autonomousSystem: 64512, routerId: "192.0.2.10", interfaces: [{ name: "wg-member", kind: "wireguard" }] },
{ serverId: 2, autonomousSystem: 64512, routerId: "192.0.2.11" },
] })
let segment = { id, revision: 1, appliedRevision: 1, configuration, updatedAt: observedAt }
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", async route => {
const request = route.request()
const path = new URL(request.url()).pathname
const json = (body: unknown) => route.fulfill({ json: body })
if (path === "/api/auth/config") return json({ required: false })
if (path === "/api/ix/nodes") return json({ items: nodes })
if (path === "/api/mcp/connections") return json({ connections: [{
id, name: "IX Lab", ownerId: "test", createdAt: observedAt, updatedAt: observedAt, lastUsedAt: null, generationValid: true,
policy: { id, version: 1, status: "active", mode: "approval", expiresAt: "2099-01-01T00:00:00Z",
permissions: ["mm:network:write"], scope: { serverIds: [1, 2], operationIds: ["network.ix.configure"], allowGlobal: false },
dangerousPolicy: "approval", autonomousDangerousOperationIds: [], limits: mcpLimitsSchema.parse({}) },
}] })
if (path === "/api/mcp/ix/plan") return json({ planId: id, state: "awaiting-approval" })
if (path === `/api/mcp/plans/${id}/decision`) return json({ ok: true })
if (path === `/api/mcp/plans/${id}/apply`) return json({ id, state: "pending" })
if (path === "/api/ix/segments" && request.method() === "POST") {
const change = ixChangeSchema.parse(request.postDataJSON())
segment = { ...segment, configuration: change.configuration, revision: change.revision + 1 }
return json({ segment })
}
if (path === "/api/ix/segments") return json({ items: [segment] })
if (path === `/api/ix/segments/${id}/status`) return json({ sites: [{
serverId: 1, available: true, observedAt, neighbors: [{ name: "member", established: true }],
routes: [{ prefix: "2001:db8:120::/48", gateway: "2001:db8::1", immediateGateway: "2001:db8::2%wg-member", active: true }],
}] })
if (path === "/api/ix/preview") return json({ objects: [] })
if (path === "/api/servers") return json([])
return json({})
})
await page.goto("/ix")
const row = page.getByRole("button", { name: "ix-central", exact: true })
await expect(row).toBeVisible()
const search = page.getByRole("searchbox", { name: "Поиск сегментов" })
await search.fill("no-match")
await expect(page.getByText("Сегменты не найдены")).toBeVisible()
await search.clear()
await expect(row).toBeVisible()
await page.screenshot({ path: testInfo.outputPath("ix-list-desktop.png"), animations: "disabled" })
await row.click()
await expect(page.getByRole("heading", { name: "ix-central" })).toBeFocused()
await page.screenshot({ path: testInfo.outputPath("ix-detail-desktop.png"), animations: "disabled" })
await page.setViewportSize({ width: 390, height: 760 })
await page.getByLabel("Локальный ASN", { exact: true }).first().fill("64513")
const save = page.getByRole("button", { name: "Сохранить черновик" })
await save.scrollIntoViewIfNeeded()
await expect(save).toBeInViewport()
await save.click()
await expect(page.getByText("Черновик сохранён")).toBeVisible()
expect(segment.configuration.sites[0]).toEqual({ ...configuration.sites[0], autonomousSystem: 64513 })
expect(segment.configuration.sites[1]).toEqual(configuration.sites[1])
await page.getByRole("tab", { name: "Маршруты и BGP" }).click()
await expect(page.getByText("2001:db8:120::/48")).toBeVisible()
await expect(page.getByText("BGP 1 из 1")).toBeVisible()
await page.getByRole("tab", { name: "План изменений" }).click()
await page.getByRole("button", { name: "Построить предпросмотр" }).click()
await expect(page.getByText("Объекты RouterOS · 0")).toBeVisible()
await expect(page.getByText("IX Lab", { exact: true })).toBeVisible()
await page.getByRole("button", { name: "Подготовить план MCP" }).click()
await expect(page.getByText("Ждёт подтверждения")).toBeVisible()
await page.getByRole("button", { name: "Подтвердить", exact: true }).click()
await page.getByRole("button", { name: "Применить план" }).click()
await expect(page.getByText("В очереди", { exact: true })).toBeVisible()
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390)
})
+23
View File
@@ -45,6 +45,29 @@ async function edit(page: Page, id = 1) {
await page.getByRole("menuitem", { name: "Редактировать", exact: true }).click()
}
test("типы узлов в узкой форме выбираются кнопкой и с клавиатуры", async ({ page }, testInfo) => {
await setup(page)
await page.setViewportSize({ width: 390, height: 844 })
await page.getByRole("button", { name: "Добавить сервер", exact: true }).click()
const types = page.getByRole("group", { name: "Тип узла" })
const exit = types.getByRole("button", { name: "Exit Node" })
const ix = types.getByRole("button", { name: "IX Node" })
await expect(exit).toHaveAttribute("aria-pressed", "true")
await expect(types).toBeInViewport({ ratio: 1 })
const buttonTops = await types.getByRole("button").evaluateAll(buttons => buttons.map(button => button.getBoundingClientRect().top))
expect(buttonTops).toHaveLength(4)
expect(new Set(buttonTops).size).toBe(1)
await ix.click()
await expect(ix).toHaveAttribute("aria-pressed", "true")
await expect(types.getByRole("button", { pressed: true })).toHaveCount(1)
await expect(page.getByPlaceholder("AS65001")).toBeVisible()
await page.screenshot({ path: testInfo.outputPath("node-type-mobile.png"), animations: "disabled" })
await page.keyboard.press("Shift+Tab")
await expect(exit).toBeFocused()
await page.keyboard.press("Space")
await expect(exit).toHaveAttribute("aria-pressed", "true")
})
test("ссылка на сервер: выбор, опрос одного устройства, сброс и возврат", async ({ page }) => {
const calls: string[] = []
await setup(page, async (route, path) => {