fix(map): улучшить навигацию и разбор инцидентов на карте
Docker images / prepare-release (push) Successful in 15s
Docker images / backend-test (push) Successful in 4s
Docker images / frontend-image (push) Successful in 2m22s
Docker images / updater-image (push) Successful in 41s
Docker images / netflow-agent-image (push) Successful in 33s
Docker images / backend-image (push) Successful in 16s
Docker images / publish-release (push) Successful in 10s
Docker images / notify-webhook (push) Successful in 2s
Docker images / prepare-release (push) Successful in 15s
Docker images / backend-test (push) Successful in 4s
Docker images / frontend-image (push) Successful in 2m22s
Docker images / updater-image (push) Successful in 41s
Docker images / netflow-agent-image (push) Successful in 33s
Docker images / backend-image (push) Successful in 16s
Docker images / publish-release (push) Successful in 10s
Docker images / notify-webhook (push) Successful in 2s
This commit is contained in:
1 parent
d174bca5d6
commit
4eafc78c8e
9 files changed
+322
-126
No files matched your search
+152
-88
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState, useRef, useEffect, useMemo, useCallback, Suspense } from "react"
|
||||
import {fitNetworkMapCamera} from "@/lib/network-map-camera"
|
||||
import { mapObservationRoute } from "@/lib/network-map-observation-route"
|
||||
import { useSearchParams } from "next/navigation"
|
||||
import {readNetworkMapUrl,patchNetworkMapUrl,type NetworkMapFilter} from "@/lib/network-map-url-state"
|
||||
import {Alert,AlertTitle,AlertDescription} from "@/components/ui/alert"
|
||||
@@ -101,7 +102,7 @@ import {
|
||||
DownloadIcon, XIcon, LockIcon, LockOpenIcon, WifiIcon, RefreshCwIcon,
|
||||
SearchIcon,
|
||||
LayersIcon, FilterIcon, MapIcon, HomeIcon, TerminalIcon, ShieldIcon,
|
||||
CableIcon, ActivityIcon, ArrowDownLeftIcon, ArrowUpRightIcon, UsersIcon,
|
||||
CableIcon, ActivityIcon, ArrowDownLeftIcon, ArrowUpRightIcon, UsersIcon, ChevronDownIcon, ChevronUpIcon, CircleHelpIcon,
|
||||
} from "lucide-react"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { formatServicePathLabel, formatServicePathTitle, servicePathKey } from "@/lib/format-service-path-label"
|
||||
@@ -573,6 +574,7 @@ function ServiceNode({
|
||||
category,
|
||||
rate,
|
||||
compact,
|
||||
expanded,
|
||||
onClick,
|
||||
onPointerDown,
|
||||
}: {
|
||||
@@ -584,6 +586,7 @@ function ServiceNode({
|
||||
rate?: string
|
||||
/** Узкая строка: раскрытая страна показывает две колонки назначений. */
|
||||
compact?: boolean
|
||||
expanded?: boolean
|
||||
x: number
|
||||
y: number
|
||||
isSel: boolean
|
||||
@@ -604,10 +607,10 @@ function ServiceNode({
|
||||
const barW = bw - 72
|
||||
const flagIso = destMode === "countries" && iso && iso !== "Прочее" ? iso : ""
|
||||
return (
|
||||
<g role="button" aria-label={(destMode==="countries"?"Страна ":"Сервис ")+label} aria-pressed={isSel} tabIndex={isVis?0:-1} className="network-map-focusable"
|
||||
<g role="button" aria-label={expanded === undefined ? (destMode==="countries"?"Страна ":"Сервис ")+label : label} aria-pressed={expanded === undefined ? isSel : undefined} aria-expanded={expanded} tabIndex={isVis?0:-1} className="network-map-focusable"
|
||||
onKeyDown={e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();e.stopPropagation();onClick()}}}
|
||||
transform={`translate(${x},${y})`}
|
||||
style={{ cursor: isDragged ? "grabbing" : "grab", transition: isDragged ? "none" : "opacity 0.25s" }}
|
||||
style={{ cursor: expanded !== undefined ? "pointer" : isDragged ? "grabbing" : "grab" }}
|
||||
opacity={isVis ? (dim ? 0.35 : 1) : 0.08}
|
||||
onPointerDown={(e) => { e.stopPropagation(); onPointerDown(e) }}
|
||||
onClick={(e) => { e.stopPropagation(); onClick() }}
|
||||
@@ -620,9 +623,10 @@ function ServiceNode({
|
||||
<g transform={`translate(${-hw + 13},${flagIso ? -8 : -11})`} pointerEvents="none">
|
||||
{flagIso
|
||||
? <CountryFlagSvg iso={flagIso} size={22} />
|
||||
: <ServiceBrandIcon aria-hidden="true" label={destMode === "countries" ? "Прочее" : label} size={22} />}
|
||||
: expanded !== undefined ? expanded ? <ChevronUpIcon width={22} height={22} color="var(--muted-foreground)" /> : <ChevronDownIcon width={22} height={22} color="var(--muted-foreground)" />
|
||||
: <ServiceBrandIcon aria-hidden="true" label={destMode === "countries" ? "Прочее" : label} size={22} />}
|
||||
</g>
|
||||
<text x={-hw + 48} y="-3" fill="var(--foreground)" fontSize="13" fontWeight="600" fontFamily="Geist,sans-serif">{shortName(label, compact ? 8 : 18)}</text>
|
||||
<text x={-hw + 48} y="-3" fill="var(--foreground)" fontSize="13" fontWeight="600" fontFamily="Geist,sans-serif">{shortName(label, expanded === undefined ? compact ? 8 : 18 : 28)}</text>
|
||||
<text x={-hw + 48} y="12" fill="var(--muted-foreground)" fontSize="11" fontFamily="Geist,sans-serif">{compact ? serviceSharePct(share) : category || (destMode === "countries" ? "Страна" : "Сервис")}</text>
|
||||
{!compact && rate ? <text x={hw - 12} y="-3" textAnchor="end" fill="var(--foreground)" fontSize="12" fontFamily="Geist Mono,monospace">{rate}</text> : null}
|
||||
{!compact ? <text x={hw - 12} y="12" textAnchor="end" fill="var(--muted-foreground)" fontSize="11" fontFamily="Geist Mono,monospace">{serviceSharePct(share)}</text> : null}
|
||||
@@ -944,6 +948,8 @@ function NetworkMapContent() {
|
||||
const [flowLoading,setFlowLoading]=useState(false)
|
||||
const [userFlow, setUserFlow] = useState<{ key: string; data?: ReturnType<typeof networkMapFlowSchema.parse>; error?: string }>()
|
||||
const [bottomTab, setBottomTab] = useState<MapBottomTab>("flows")
|
||||
const [analysisOpen, setAnalysisOpen] = useState(false)
|
||||
const [summaryOpen, setSummaryOpen] = useState(false)
|
||||
const [filteredServiceId, setFilteredServiceId] = useState<string | null>(null)
|
||||
const [mapEvents, setMapEvents] = useState<EventItem[] | null>(null)
|
||||
const [eventsError, setEventsError] = useState<string | null>(null)
|
||||
@@ -953,9 +959,21 @@ function NetworkMapContent() {
|
||||
useEffect(() => {
|
||||
if (!useLiveData) return
|
||||
let cancelled = false
|
||||
listEvents(backendUrl, { limit: 50 })
|
||||
.then(rows => { if (!cancelled) { setMapEvents(rows); setEventsError(null); setEventsAt(Date.now()) } })
|
||||
.catch(error => { if (!cancelled) setEventsError(error instanceof Error ? error.message : "не удалось загрузить") })
|
||||
const now = Date.now()
|
||||
const from = new Date(now - 86_400_000).toISOString()
|
||||
void Promise.allSettled([
|
||||
listEvents(backendUrl, { limit: 50 }),
|
||||
listEvents(backendUrl, { limit: 100, level: "critical", from }),
|
||||
listEvents(backendUrl, { limit: 100, level: "warning", from }),
|
||||
]).then(results => {
|
||||
if (cancelled) return
|
||||
const rows = new Map<string, EventItem>()
|
||||
for (const result of results) if (result.status === "fulfilled") for (const event of result.value) rows.set(event.id, event)
|
||||
if (results.some(result => result.status === "fulfilled")) {
|
||||
setMapEvents([...rows.values()]); setEventsAt(now)
|
||||
}
|
||||
setEventsError(results.every(result => result.status === "fulfilled") ? null : "Журнал загружен не полностью")
|
||||
})
|
||||
return () => { cancelled = true }
|
||||
}, [useLiveData, backendUrl, flowRefresh])
|
||||
const [dnsError,setDnsError]=useState<string|null>(null)
|
||||
@@ -1271,18 +1289,17 @@ function NetworkMapContent() {
|
||||
return out
|
||||
}, [mapServers, autoLayout.wanSatPos, satPositions])
|
||||
|
||||
const compactLanes = homeRouters.length === 0 ? 180 : 0
|
||||
const nodePosById = useMemo(
|
||||
() =>
|
||||
Object.fromEntries(
|
||||
mapServers.map((s) => {
|
||||
const pos =
|
||||
nodePositions[s.id] ??
|
||||
autoLayout.nodePos[s.id] ??
|
||||
{ x: W / 2, y: NETWORK_MAP_PIPELINE_Y }
|
||||
const auto = autoLayout.nodePos[s.id] ?? { x: W / 2, y: NETWORK_MAP_PIPELINE_Y }
|
||||
const pos = nodePositions[s.id] ?? { x: auto.x - compactLanes, y: auto.y }
|
||||
return [s.id, pos] as const
|
||||
}),
|
||||
),
|
||||
[mapServers, nodePositions, autoLayout.nodePos],
|
||||
[mapServers, nodePositions, autoLayout.nodePos, compactLanes],
|
||||
)
|
||||
|
||||
const greEdges = useMemo(
|
||||
@@ -1350,6 +1367,10 @@ function NetworkMapContent() {
|
||||
setInspectUser(true); setUserPicker(false)
|
||||
updateUrl({ user: user.id, server: null, wan: null, service: null, q: null, filter: ixOnly ? "ix-node" : null })
|
||||
}
|
||||
function returnToNetwork() {
|
||||
updateUrl({user:null, server:null, wan:null, service:null})
|
||||
setSelectedService(null); setSelectedGreEdge(null); setHighlightedPath(null); setUserPicker(false)
|
||||
}
|
||||
|
||||
/** Speed-пробы на сегментах WAN→JH (тот же формат бейджа, что на GRE JH↔EN). */
|
||||
const speedProbeByWanJhKey = useMemo(
|
||||
@@ -1535,9 +1556,11 @@ function NetworkMapContent() {
|
||||
const activeService = destNodes.find(service => service.id === activeServiceId) ?? selectedNestedService ?? null
|
||||
const liveSelectedService = activeService
|
||||
const expandedCountry = destNodes.find(service => service.id === expandedCountryId)
|
||||
const minorServices = destMode === "services" ? destNodes.filter(service => service.share <= 0.1 && service.id !== activeService?.id && service.id !== filteredServiceId) : []
|
||||
const hasMinorServices = minorServices.length > 0
|
||||
const visibleMapServices = !showServices ? [] : showSmallServices ? destNodes : destNodes.filter(service => !minorServices.includes(service))
|
||||
const minorServices = destMode === "services" ? destNodes.filter(service => service.share <= 0.1) : []
|
||||
const groupedServices = minorServices.filter(service => service.id !== activeService?.id && service.id !== filteredServiceId)
|
||||
const mainServices = showServices ? destNodes.filter(service => !groupedServices.includes(service)) : []
|
||||
const hasMinorServices = showServices && (groupedServices.length > 0 || showSmallServices && minorServices.length > 0)
|
||||
const visibleMapServices = showServices && showSmallServices ? [...mainServices, ...groupedServices] : mainServices
|
||||
const visibleServiceEdges = showServices
|
||||
? destEdges.filter(edge => nodePosById[edge.fromId] && visibleMapServices.some(service => service.id === edge.toId))
|
||||
: []
|
||||
@@ -1562,7 +1585,7 @@ function NetworkMapContent() {
|
||||
const nodeById = Object.fromEntries(nodes.map((n) => [n.id, n]))
|
||||
|
||||
const autoServicePos = placeServiceNodes(
|
||||
[...visibleMapServices.map((s) => s.id), ...(showServices && hasMinorServices && !showSmallServices ? ["minor-services"] : [])],
|
||||
[...mainServices.map((s) => s.id), ...(hasMinorServices ? ["minor-services"] : [])],
|
||||
mapServers
|
||||
.filter((s) => s.type === "exit-node")
|
||||
.map((s) => nodePosById[s.id])
|
||||
@@ -1570,22 +1593,24 @@ function NetworkMapContent() {
|
||||
)
|
||||
// Раскрытая страна: колонка стран уходит влево, правый x занимает столбец её сервисов.
|
||||
const countryColShift = expandedCountryGroup ? SERVICE_COL_W : 0
|
||||
const autoDestPos = countryColShift
|
||||
? Object.fromEntries(
|
||||
Object.entries(autoServicePos).map(([id, p]) => [id, { x: p.x - countryColShift, y: p.y }]),
|
||||
)
|
||||
: autoServicePos
|
||||
const autoDestPos = Object.fromEntries(Object.entries(autoServicePos).map(([id, p]) => [id, { x: p.x - countryColShift - compactLanes, y: p.y }]))
|
||||
const minorPosition = autoDestPos["minor-services"]
|
||||
if (minorPosition && showSmallServices) for (const [index, service] of groupedServices.entries()) {
|
||||
autoDestPos[service.id] = { x: minorPosition.x, y: minorPosition.y + (index + 1) * (MAP_SERVICE_NODE_H + 10) }
|
||||
}
|
||||
const servicePosById = Object.fromEntries(
|
||||
visibleMapServices.map((s) => [s.id, servicePositions[s.id] ?? autoDestPos[s.id]!]),
|
||||
)
|
||||
const minorPosition = autoDestPos["minor-services"]
|
||||
const autoNestedPos = placeCountryServiceNodes(
|
||||
nestedServices.map((s) => s.id),
|
||||
expandedCountryId ? servicePosById[expandedCountryId] ?? autoDestPos[expandedCountryId] : undefined,
|
||||
)
|
||||
const nestedPosById = Object.fromEntries(
|
||||
nestedServices
|
||||
.map((s) => [s.id, servicePositions[s.id] ?? autoNestedPos[s.id]] as const)
|
||||
.map((s) => {
|
||||
const position = autoNestedPos[s.id]
|
||||
return [s.id, servicePositions[s.id] ?? (position && { x: position.x - compactLanes, y: position.y })] as const
|
||||
})
|
||||
.filter((entry): entry is readonly [string, { x: number; y: number }] => Boolean(entry[1])),
|
||||
)
|
||||
|
||||
@@ -1621,20 +1646,25 @@ function NetworkMapContent() {
|
||||
function exportSvg() {
|
||||
const svg = svgRef.current
|
||||
if (!svg) return
|
||||
// Clone with full viewBox (reset pan/zoom)
|
||||
const clone = svg.cloneNode(true) as SVGSVGElement
|
||||
const x = Math.min(0, ...mapObstacles.map(box => box.x - 20))
|
||||
const y = Math.min(0, lanesTop - 16, ...observationTracks.map(track => track - 20))
|
||||
const width = Math.ceil(Math.max(W, ...mapObstacles.map(box => box.x + box.w + 20)) - x)
|
||||
const height = Math.ceil(Math.max(H, lanesBottom + 16, ...observationTracks.map(track => track + 20)) - y)
|
||||
clone.querySelectorAll(".network-map-focus-ring").forEach(ring => ring.remove())
|
||||
clone.setAttribute("viewBox", `0 0 ${W} ${H}`)
|
||||
clone.setAttribute("width", String(W))
|
||||
clone.setAttribute("height", String(H))
|
||||
clone.setAttribute("viewBox", `${x} ${y} ${width} ${height}`)
|
||||
clone.setAttribute("width", String(width))
|
||||
clone.setAttribute("height", String(height))
|
||||
clone.setAttribute("xmlns","http://www.w3.org/2000/svg")
|
||||
const computed=getComputedStyle(svg)
|
||||
const variables=new Set([...clone.outerHTML.matchAll(/var\((--[a-zA-Z0-9_-]+)/g)].map(match=>match[1]))
|
||||
variables.add("--background")
|
||||
for(const name of variables){const value=computed.getPropertyValue(name).trim();if(!value)continue;clone.style.setProperty(name,value);for(const match of value.matchAll(/var\((--[a-zA-Z0-9_-]+)/g))variables.add(match[1])}
|
||||
clone.style.width=W+"px";clone.style.height=H+"px"
|
||||
clone.style.width=width+"px";clone.style.height=height+"px"
|
||||
const background=document.createElementNS("http://www.w3.org/2000/svg","rect")
|
||||
background.setAttribute("width",String(W));background.setAttribute("height",String(H));background.setAttribute("fill","var(--background)");clone.prepend(background)
|
||||
background.setAttribute("x",String(x));background.setAttribute("y",String(y));background.setAttribute("width",String(width));background.setAttribute("height",String(height));background.setAttribute("fill","var(--background)");clone.prepend(background)
|
||||
const grid = clone.querySelector("[data-map-background]")
|
||||
for (const key of ["x", "y", "width", "height"]) grid?.setAttribute(key, background.getAttribute(key)!)
|
||||
const blob = new Blob(
|
||||
[`<?xml version="1.0" encoding="UTF-8"?>\n`, new XMLSerializer().serializeToString(clone)],
|
||||
{ type: "image/svg+xml;charset=utf-8" },
|
||||
@@ -1685,16 +1715,17 @@ function NetworkMapContent() {
|
||||
},[zoom,viewportHeight])
|
||||
|
||||
// Миникарта — только на широком холсте; снизу резервируем полосу под неё и панель масштаба.
|
||||
const minimapVisible = showMinimap && canvasPx.w >= 640
|
||||
const overlayReserve = canvasPx.h ? ((minimapVisible ? 112 : 36) + 20) / canvasPx.h : 0
|
||||
const accessPosition = { x: homeRouters.some(router => onMap(router.id)) ? -105 : MAP_LANES.home.cx,
|
||||
y: Math.max(80, [...accessGroups.keys()].reduce((sum, id) => sum + (nodePosById[id]?.y ?? 0), 0) / (accessGroups.size || 1)) }
|
||||
const detailsOpen = Boolean(selected || activeService || selectedGreEdge || userDetailsOpen)
|
||||
const fitWidth = canvasPx.w >= 760 && detailsOpen ? W * (1 - 330 / canvasPx.w) : W
|
||||
const sideInspector = canvasPx.w >= 620 && detailsOpen
|
||||
const minimapVisible = showMinimap && canvasPx.w >= 640 && !detailsOpen
|
||||
const overlayReserve = canvasPx.h ? ((minimapVisible ? 112 : 36) + 20) / canvasPx.h + (detailsOpen && !sideInspector ? 0.35 : 0) : 0
|
||||
const fitWidth = sideInspector ? W * (1 - 302 / canvasPx.w) : W
|
||||
const {pan:{x:fitX,y:fitY},zoom:fitZoom}=fitNetworkMapCamera([...nodes,...homeRouters.filter(router => onMap(router.id)).flatMap(router => effectiveSatPos[router.id] ?? []),...(showUsers && usersInTopology.length ? [accessPosition] : []),...(minorPosition ? [minorPosition] : []),...Object.values(servicePosById).map(p=>({x:p.x+(expandedCountryGroup?MAP_SERVICE_COMPACT_W:MAP_SERVICE_NODE_W)/2-100,y:p.y})),...Object.values(nestedPosById).map(p=>({x:p.x+MAP_SERVICE_COMPACT_W/2-100,y:p.y}))],fitWidth,viewportHeight,overlayReserve)
|
||||
function fitView(){setPan({x:fitX,y:fitY});setZoom(fitZoom)}
|
||||
useEffect(()=>{if(initialFit.current||!canvasMeasured||!mapServers.length)return;initialFit.current=true;queueMicrotask(()=>{setPan({x:fitX,y:fitY});setZoom(fitZoom)})},[canvasMeasured,mapServers.length,fitX,fitY,fitZoom])
|
||||
const viewKey = `${ixOnly}:${pickedUser?.id ?? ""}:${filteredServiceId ?? ""}:${showSmallServices}:${splitIx}:${fitWidth !== W}:${Boolean(userSnapshot?.data)}:${showUsers && usersInTopology.length > 0}`
|
||||
const viewKey = `${ixOnly}:${pickedUser?.id ?? ""}:${filteredServiceId ?? ""}:${showSmallServices}:${splitIx}:${fitWidth !== W}:${Boolean(userSnapshot?.data)}:${showUsers && usersInTopology.length > 0}:${Math.round(canvasPx.w)}x${Math.round(canvasPx.h)}`
|
||||
const lastViewKey = useRef(viewKey)
|
||||
const lastUserView = useRef(pickedUser?.id)
|
||||
useEffect(() => {
|
||||
@@ -1716,11 +1747,11 @@ function NetworkMapContent() {
|
||||
// ── Keyboard shortcuts ────────────────────────────────────────────────────
|
||||
useEffect(() => {
|
||||
function onKey(e: KeyboardEvent) {
|
||||
if (ctxMenu||showLayers) return
|
||||
if (ctxMenu || showLayers || userPicker || summaryOpen) return
|
||||
if (e.key!=="Escape"&&(e.ctrlKey||e.metaKey||e.altKey||e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement))return
|
||||
if (e.key === "Escape") {
|
||||
setSelected(null)
|
||||
updateUrl({wan:null})
|
||||
updateUrl({wan:null,service:null})
|
||||
setSelectedGreEdge(null)
|
||||
setSelectedService(null)
|
||||
setHighlightedPath(null)
|
||||
@@ -1735,7 +1766,7 @@ function NetworkMapContent() {
|
||||
}
|
||||
window.addEventListener("keydown", onKey)
|
||||
return () => window.removeEventListener("keydown", onKey)
|
||||
}, [applyZoomCenter,fitX,fitY,fitZoom,setSelected,updateUrl,ctxMenu,showLayers,returnToMapControl])
|
||||
}, [applyZoomCenter,fitX,fitY,fitZoom,setSelected,updateUrl,ctxMenu,showLayers,userPicker,summaryOpen,returnToMapControl])
|
||||
|
||||
// ── Drag ─────────────────────────────────────────────────────────────────
|
||||
function onSvgPointerDown(e: React.PointerEvent<SVGSVGElement>) {
|
||||
@@ -2008,7 +2039,9 @@ function NetworkMapContent() {
|
||||
merged: mergeGreMetricsWithSpeedProbe(sp, greTunnelProbe(e.tunnel, !useLiveData)),
|
||||
flowHop: netflowByGreKey.get(id),
|
||||
liveRate: getGreLiveRate(id),
|
||||
opacity: dimmed ? 0.05 : highlightedPath && !greMatchesPath(e, highlightedPath) ? 0.14 : 1,
|
||||
opacity: dimmed ? 0.05 : highlightedPath ? greMatchesPath(e, highlightedPath) ? 1 : 0.16
|
||||
: activeService ? selectedDestPaths.some(path => greMatchesPath(e, path)) ? 1 : 0.2
|
||||
: selected && selected.id !== e.fromServer.id && selected.id !== e.toServer.id ? 0.3 : 1,
|
||||
link: mapLinkPath(e.from, greHalfW(e.from, e.fromServer), e.to, greHalfW(e.to, e.toServer)),
|
||||
}
|
||||
})
|
||||
@@ -2124,11 +2157,19 @@ function NetworkMapContent() {
|
||||
...visibleMapServices.flatMap((s) => servicePosById[s.id] ? [{ x: servicePosById[s.id].x - destHalfW, y: servicePosById[s.id].y - MAP_SERVICE_NODE_H / 2, w: destHalfW * 2, h: MAP_SERVICE_NODE_H }] : []),
|
||||
...(expandedCountryGroup ? nestedServices : []).flatMap((s) => nestedPosById[s.id] ? [{ x: nestedPosById[s.id].x - MAP_SERVICE_COMPACT_W / 2, y: nestedPosById[s.id].y - MAP_SERVICE_NODE_H / 2, w: MAP_SERVICE_COMPACT_W, h: MAP_SERVICE_NODE_H }] : []),
|
||||
]
|
||||
const linkLabels = placeMapLinkLabels([...accessLinks.filter(link => link.texts[0]), ...greLabels, ...wanLabels], mapObstacles)
|
||||
const destRibbons = visibleServiceEdges.flatMap(edge => {
|
||||
const observationTracks: number[] = []
|
||||
const destRibbons = [...visibleServiceEdges].sort((a, b) =>
|
||||
Number(b.toId === activeService?.id) - Number(a.toId === activeService?.id) || b.bps - a.bps || a.fromId.localeCompare(b.fromId) || a.toId.localeCompare(b.toId),
|
||||
).flatMap(edge => {
|
||||
const from = nodeById[edge.fromId], to = servicePosById[edge.toId]
|
||||
return from && to ? [{ edge, link: mapLinkPath(from, MAP_CARD_W / 2, to, destHalfW) }] : []
|
||||
if (!from || !to) return []
|
||||
const direct = edge.observedOnly || from.type === "jump-host" || from.type === "home-router"
|
||||
const detour = direct ? mapObservationRoute({ x: from.x + MAP_CARD_W / 2, y: from.y }, { x: to.x - destHalfW, y: to.y }, mapObstacles, observationTracks) : null
|
||||
if (detour) observationTracks.push(detour.track)
|
||||
return [{ edge, direct, detour, link: mapLinkPath(from, MAP_CARD_W / 2, to, destHalfW) }]
|
||||
})
|
||||
const observationMarkers = destRibbons.flatMap(({ edge, detour }) => edge.observedOnly && detour ? [{ x: detour.marker.x - 17, y: detour.marker.y - 7, w: 34, h: 14 }] : [])
|
||||
const linkLabels = placeMapLinkLabels([...accessLinks.filter(link => link.texts[0]), ...greLabels, ...wanLabels], [...mapObstacles, ...observationMarkers])
|
||||
const nestedRibbons = mapRibbons((expandedCountryGroup?.edges ?? []).flatMap((edge) => {
|
||||
const from = servicePosById[edge.fromId], to = nestedPosById[edge.toId]
|
||||
return from && to ? [{ edge, from, fromHalfW: MAP_SERVICE_COMPACT_W / 2, to, toHalfW: MAP_SERVICE_COMPACT_W / 2, bps: destinationRate(edge).bps }] : []
|
||||
@@ -2179,12 +2220,15 @@ function NetworkMapContent() {
|
||||
hl: selectedService?.id === svc.id || Boolean(selected && destEdges.some(edge => edge.fromId === selected.id && edge.toId === svc.id)),
|
||||
}))
|
||||
const mapLinkCount = greGroups.length + wanLinks.length
|
||||
const activeMapPoints = [...nodes, ...Object.values(servicePosById), ...Object.values(nestedPosById), ...(minorPosition ? [minorPosition] : [])]
|
||||
const lanesTop = Math.min(...activeMapPoints.map(point => point.y), NETWORK_MAP_PIPELINE_Y) - 66
|
||||
const lanesBottom = Math.max(...activeMapPoints.map(point => point.y), NETWORK_MAP_PIPELINE_Y) + 52
|
||||
const recentIncidents = eventRows.filter(event => (event.tone === "er" || event.tone === "wn") && event.ts >= eventsAt - 86_400_000)
|
||||
const mapHeadSub = (
|
||||
<>
|
||||
<span>{useLiveData ? (readAt ? `Live · снимок API ${new Date(readAt).toLocaleTimeString("ru-RU")}` : "Данные карты неизвестны") : "Демо · mock"}</span>
|
||||
{useLiveData ? <>{" · "}<span>{showNetflow || showServices ? (flowReadAt ? `NetFlow · ${mapWindow}${mapWindowSec >= 120 && mapWindowSec < 300 ? " из 5 запрошенных" : ""} · ответ ${new Date(flowReadAt).toLocaleTimeString("ru-RU")} · ${flowListener ? "приёмник включён" : "приёмник выключен"}` : "Данные NetFlow неизвестны") : "NetFlow: отображение и обновление выключены"}</span></> : null}
|
||||
{" · "}
|
||||
<span>{`${nodes.length} ${ruPlural(nodes.length, "узел", "узла", "узлов")}, ${mapLinkCount} ${ruPlural(mapLinkCount, "связь", "связи", "связей")}, ${visibleMapServices.length} ${ruPlural(visibleMapServices.length, "назначение", "назначения", "назначений")}`}</span>
|
||||
<span title={readAt ? `Снимок API ${new Date(readAt).toLocaleTimeString("ru-RU")}` : undefined}>{useLiveData ? (readAt ? "Текущий срез" : "Данные карты неизвестны") : "Демонстрационные данные"}</span>
|
||||
{" · "}<span>{nodes.length} {ruPlural(nodes.length, "узел", "узла", "узлов")} · {mapLinkCount} {ruPlural(mapLinkCount, "связь", "связи", "связей")}</span>
|
||||
{useLiveData && (showNetflow || showServices) && <>{" · "}{flowReadAt ? <span title={`NetFlow · ${mapWindow}${mapWindowSec >= 120 && mapWindowSec < 300 ? " из 5 запрошенных" : ""} · ответ ${new Date(flowReadAt).toLocaleTimeString("ru-RU")} · ${flowListener ? "приёмник включён" : "приёмник выключен"}`}>IPFIX · {mapWindow}{!flowListener ? " · приёмник выключен" : ""}</span> : <span>Данные NetFlow неизвестны</span>}</>}
|
||||
</>
|
||||
)
|
||||
// Подсказки поиска макета: узлы и назначения текущего снимка.
|
||||
@@ -2200,9 +2244,17 @@ function NetworkMapContent() {
|
||||
function inspectEvent(event: MapEventRow) {
|
||||
setInspectedEvent(event)
|
||||
setBottomTab("events")
|
||||
setAnalysisOpen(true)
|
||||
const node = event.serverId ? nodeById[event.serverId] : undefined
|
||||
if (node && selected?.id !== node.id) selectServer(node)
|
||||
}
|
||||
function inspectFlow(id: string) {
|
||||
const path = tablePaths.find(row => servicePathKey(row) === id)
|
||||
const service = path && [...destNodes, ...nestedServices].find(item => item.id === path.serviceId)
|
||||
if (!path || !service) return
|
||||
if (activeService?.id !== service.id) selectService(service)
|
||||
setHighlightedPath(path)
|
||||
}
|
||||
const pickedBindings = new Map([...accessGroups.keys()].map(id => [id, pickedUser?.bindings.filter(binding => binding.node === id) ?? []]))
|
||||
const selectedNodeRate = !selectedNodeTraffic.error && isFreshMapTrafficSample(selectedNodeTraffic.sample) ? selectedNodeTraffic.sample : undefined
|
||||
function nodeTrafficHref(server: string) {
|
||||
@@ -2216,11 +2268,11 @@ function NetworkMapContent() {
|
||||
<div className="flex flex-col h-full min-h-0 min-w-0 [&_button]:focus-visible:outline-2 [&_button]:focus-visible:outline-ring [&_button]:focus-visible:outline-offset-2">
|
||||
<PageHeader crumbs={[{ label: "Главная", href: "/dashboard" }, { label: "Обзор" }, { label: "Карта сети" }]} />
|
||||
|
||||
<div className="flex min-h-0 min-w-0 flex-1 flex-col gap-5 overflow-y-auto px-4 pt-5 pb-6 md:px-7 md:pt-6">
|
||||
<div className="flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-y-auto px-3 py-3 md:overflow-hidden lg:px-5">
|
||||
<PageTitle
|
||||
icon={<MapIcon />}
|
||||
title="Карта сети"
|
||||
description={mapHeadSub}
|
||||
description={<span className="line-clamp-2">{mapHeadSub}</span>}
|
||||
actions={
|
||||
<>
|
||||
{useLiveData && (
|
||||
@@ -2235,8 +2287,9 @@ function NetworkMapContent() {
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<details className="order-last min-w-0">
|
||||
<summary className="mb-2 cursor-pointer text-sm font-medium">Сводка сети</summary>
|
||||
<Dialog open={summaryOpen} onOpenChange={setSummaryOpen}>
|
||||
<DialogContent className="max-h-[85svh] overflow-y-auto sm:max-w-4xl">
|
||||
<DialogHeader><DialogTitle>Сводка сети</DialogTitle><DialogDescription>Состояние устройств, туннелей и потоки за текущее окно.</DialogDescription></DialogHeader>
|
||||
<MapKpiStrip
|
||||
className="max-lg:order-last"
|
||||
servers={mapServers}
|
||||
@@ -2247,21 +2300,17 @@ function NetworkMapContent() {
|
||||
netflowBytes={mapTotalBytes > 0 ? mapTotalBytes : useLiveData && flowReadAt ? 0 : null}
|
||||
windowSec={mapWindowSec}
|
||||
filter={filter}
|
||||
onFilter={(key) => setFilter(key)}
|
||||
onSelect={(server) => { setSelectedGreEdge(null); setSelectedService(null); setSelected(server) }}
|
||||
onFilter={(key) => { setFilter(key); setSummaryOpen(false) }}
|
||||
onSelect={(server) => { setSelectedGreEdge(null); setSelectedService(null); setSelected(server); setSummaryOpen(false) }}
|
||||
/>
|
||||
</details>
|
||||
|
||||
<details className="text-sm text-muted-foreground">
|
||||
<summary className="cursor-pointer font-medium text-foreground">Как читать карту</summary>
|
||||
<p className="mt-2">Связи GRE и привязки пользователей показывают конфигурацию. IPFIX показывает среднюю скорость за окно. Метка IPFIX на линии означает, что известен экспортёр, а выход не подтверждён.</p>
|
||||
</details>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{urlState.server&&((hasSnapshot||!useLiveData)&&!selected||selected&&selWanIdx!==null&&!selected.wanUplinks?.[selWanIdx])&&<Alert variant="destructive"><AlertTitle>Объект карты недоступен</AlertTitle><AlertDescription>{!selected?"Устройство "+urlState.server+" отсутствует в текущем снимке.":"Запрошенный WAN отсутствует у выбранного устройства."}<Button type="button" variant="outline" onClick={()=>updateUrl({server:null,wan:null})}>Сбросить выбранный объект</Button></AlertDescription></Alert>}
|
||||
{pickedUserId && !pickedUser && (ixOnly ? access.linuxPending : access.pending) && <p role="status" className="text-sm text-muted-foreground">Загрузка пользователя карты…</p>}
|
||||
{pickedUserId && !pickedUser && !(ixOnly ? access.linuxPending : access.pending) && <Alert><AlertTitle>Пользователь карты недоступен</AlertTitle><AlertDescription><Button type="button" size="sm" variant="outline" onClick={() => updateUrl({user:null,service:null})}>Вернуться к схеме</Button></AlertDescription></Alert>}
|
||||
<div className="relative flex min-w-0 shrink-0 flex-col gap-3">
|
||||
<Frame spacing="sm" className="min-w-0 flex-1">
|
||||
<div className="relative flex min-w-0 shrink-0 flex-col md:min-h-0 md:flex-1">
|
||||
<Frame spacing="sm" className="min-h-0 min-w-0 flex-1">
|
||||
<FramePanel className="flex items-center gap-1.5 p-1.5 grow-0 shrink-0 flex-wrap">
|
||||
{/* Поиск узла или назначения с подсказками */}
|
||||
<div className="relative min-w-[140px] flex-[1_1_150px] md:max-w-[280px]" onBlur={e => { if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setSearchOpen(false) }}>
|
||||
@@ -2360,9 +2409,20 @@ function NetworkMapContent() {
|
||||
{showUsers && <Button type="button" variant="outline" size="sm" onClick={() => setUserPicker(true)}>
|
||||
<UsersIcon aria-hidden />{pickedUser?.name ?? (ixOnly ? "Linux-клиенты" : "Пользователи")}
|
||||
</Button>}
|
||||
{pickedUser && <Button type="button" variant="ghost" size="icon-sm" aria-label="Вся схема пользователей" onClick={() => { updateUrl({user:null, server:null, wan:null, service:null}); setSelectedService(null); setSelectedGreEdge(null); setHighlightedPath(null) }}><XIcon /></Button>}
|
||||
{pickedUser && <Button type="button" variant="ghost" size="icon-sm" aria-label="Вся схема пользователей" onClick={returnToNetwork}><XIcon /></Button>}
|
||||
{filterService && <Button type="button" variant="outline" size="sm" aria-label={`Сбросить фильтр сервиса ${filterService.label}`} onClick={() => setFilteredServiceId(null)}>{filterService.label}<XIcon aria-hidden /></Button>}
|
||||
{showServices && hasMinorServices && <Button type="button" variant="outline" size="sm" aria-expanded={showSmallServices} onClick={() => setShowSmallServices(value => !value)}>{showSmallServices ? "Свернуть остальные" : `Остальные сервисы (${minorServices.length})`}</Button>}
|
||||
<Button type="button" variant="ghost" size="sm" onClick={() => setSummaryOpen(true)}>Сводка сети</Button>
|
||||
<Popover>
|
||||
<PopoverTrigger render={<Button type="button" variant="ghost" size="icon-sm" aria-label="Как читать карту" />}><CircleHelpIcon aria-hidden /></PopoverTrigger>
|
||||
<PopoverContent align="end" aria-label="Как читать карту" className="max-w-[calc(100vw-2rem)]">
|
||||
<p className="text-sm font-semibold">Как читать карту</p>
|
||||
<ol className="grid list-decimal gap-2 pl-4 text-xs text-muted-foreground">
|
||||
<li>Слева выберите пользователя. Карта покажет правее его узлы подключения, выход в интернет и сервисы.</li>
|
||||
<li>Откройте узел или линию. Справа появятся источник данных, состояние связи и доступные измерения.</li>
|
||||
<li>Метка IPFIX показывает, где замечен трафик. Дальнейший маршрут для такой линии требует подтверждения.</li>
|
||||
</ol>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
{/* Слои */}
|
||||
<Popover modal open={showLayers} onOpenChange={setShowLayers}>
|
||||
@@ -2423,7 +2483,7 @@ function NetworkMapContent() {
|
||||
|
||||
{/* ── Canvas ── */}
|
||||
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
<div ref={canvasRef} className="relative h-[390px] w-full min-w-0 overflow-hidden bg-card select-none md:h-[max(540px,calc(100svh-14rem))]">
|
||||
<div ref={canvasRef} className="relative h-[390px] w-full min-w-0 overflow-hidden bg-card select-none md:h-auto md:min-h-0 md:flex-1">
|
||||
<p id="network-map-help" className="sr-only">Стрелки перемещают карту, плюс и минус меняют масштаб, F вписывает объекты. Tab выбирает объект, Enter открывает детали.</p>
|
||||
<svg
|
||||
ref={svgRef} role="group" aria-label="Интерактивная карта сети" tabIndex={0} aria-describedby="network-map-help"
|
||||
@@ -2447,49 +2507,52 @@ function NetworkMapContent() {
|
||||
{/* Background grid */}
|
||||
<rect data-map-background x={pan.x} y={pan.y} width={W/zoom} height={viewportHeight/zoom} fill="url(#map-dots)" />
|
||||
{([
|
||||
...(showUsers && usersInTopology.length ? [{ lane: { x0: accessPosition.x - 96 + compactLanes, x1: accessPosition.x + 96 + compactLanes }, label: pickedUser ? "ПОЛЬЗОВАТЕЛЬ" : "ПОДКЛЮЧЕНИЯ" }] : []),
|
||||
...(nodes.some(node => node.type === "home-router") ? [
|
||||
{ lane: MAP_LANES.home, label: `HOME ROUTER · ${nodes.filter(node => node.type === "home-router").length}` },
|
||||
{ lane: MAP_LANES.home, label: `ДОМАШНИЕ РОУТЕРЫ · ${nodes.filter(node => node.type === "home-router").length}` },
|
||||
{ lane: MAP_LANES.wan, label: `АПЛИНКИ WAN · ${nodes.reduce((sum, router) => sum + (router.wanUplinks?.length ?? 0), 0)}` },
|
||||
] : []),
|
||||
...(!ixOnly ? [{ lane: MAP_LANES.jh, label: `JUMPHOST · ${nodes.filter(server => server.type === "jump-host").length}` }] : []),
|
||||
{ lane: MAP_LANES.en, label: ixOnly ? `IX · ${nodes.length}` : `EXIT NODES · ${nodes.filter(server => server.type === "exit-node").length}${nodes.some(server => server.type === "ix-node") ? ` · IX · ${nodes.filter(server => server.type === "ix-node").length}` : ""}` },
|
||||
...(!ixOnly && nodes.some(node => node.type === "jump-host") ? [{ lane: MAP_LANES.jh, label: `УЗЛЫ ДОСТУПА · ${nodes.filter(server => server.type === "jump-host").length}` }] : []),
|
||||
...(nodes.some(node => node.type === "exit-node" || node.type === "ix-node") ? [{ lane: MAP_LANES.en, label: ixOnly ? `IX · ${nodes.length}` : `ИНТЕРНЕТ-ВЫХОДЫ · ${nodes.filter(server => server.type === "exit-node").length}${nodes.some(server => server.type === "ix-node") ? ` · IX · ${nodes.filter(server => server.type === "ix-node").length}` : ""}` }] : []),
|
||||
...(visibleMapServices.length ? [{ lane: MAP_LANES.dest, label: `${destMode === "countries" ? "СТРАНЫ" : "СЕРВИСЫ"} · ${visibleMapServices.length}` }] : []),
|
||||
]).map(({ lane, label }, i) => (
|
||||
<g key={label} aria-hidden="true" pointerEvents="none">
|
||||
<rect x={lane.x0} y={0} width={lane.x1 - lane.x0} height={H} fill="var(--foreground)" fillOpacity={i % 2 ? 0.035 : 0} />
|
||||
<text x={(lane.x0 + lane.x1) / 2} y="32" textAnchor="middle" fill="var(--muted-foreground)" fontSize="11" fontWeight="600" letterSpacing="0.08em" fontFamily="Geist,sans-serif">{label}</text>
|
||||
<g key={label} aria-hidden="true" pointerEvents="none" transform={`translate(${-compactLanes},0)`}>
|
||||
<rect x={lane.x0} y={lanesTop} width={lane.x1 - lane.x0} height={lanesBottom - lanesTop} fill="var(--foreground)" fillOpacity={i % 2 ? 0.035 : 0} />
|
||||
<text x={(lane.x0 + lane.x1) / 2} y={lanesTop + 18} textAnchor="middle" fill="var(--muted-foreground)" fontSize="12" fontWeight="600" fontFamily="Geist,sans-serif">{label}</text>
|
||||
</g>
|
||||
))}
|
||||
|
||||
{accessLinks.map(({ id, link, name, open, opacity }) => <path key={id} d={link.d} fill="none" stroke="var(--chart-2)" strokeWidth={pickedUser ? 2.5 : 1.5} opacity={opacity * (pickedUser ? 0.9 : 0.6)} pointerEvents="stroke" onPointerDown={e => e.stopPropagation()} onClick={open}><title>{name}</title></path>)}
|
||||
{/* Наблюдаемые пути от выходов и экспортёров к сервисам. */}
|
||||
{destRibbons.map(({ edge, link }) => {
|
||||
{destRibbons.map(({ edge, direct, detour, link }) => {
|
||||
const hop = destinationRate(edge)
|
||||
const selectedDestinationId = highlightedPath?.serviceId.split("|")[0]
|
||||
const pathHit = Boolean(highlightedPath && (highlightedPath.enId || highlightedPath.viaId) === edge.fromId && selectedDestinationId === edge.toId)
|
||||
const hl = pathHit || (!highlightedPath && (activeService?.id === edge.toId || selected?.id === edge.fromId || expandedCountryId === edge.toId || filteredServiceId === edge.toId))
|
||||
const countryDim = !hl && Boolean(expandedCountryGroup) && edge.toId !== expandedCountryId
|
||||
const d = direct ? detour?.d : link.d
|
||||
const svc = visibleMapServices.find((s) => s.id === edge.toId)
|
||||
const enName = mapServers.find((s) => s.id === edge.fromId)?.name ?? edge.fromId
|
||||
const clientLabel = edge.clients?.map((c) => c.name).filter(Boolean).join(", ") || edge.clientName || "—"
|
||||
const rate = hopHasRate(hop) ? ` · ${formatNetflowRate(hop)}${edge.bpsFwd + edge.bpsRev > 0 ? ` (${formatNetflowDir(hop)})` : ""}` : ""
|
||||
return (
|
||||
<g key={`${edge.fromId}|${edge.toId}|${Boolean(edge.observedOnly)}`} data-map-ribbon data-observation={edge.observedOnly || undefined} opacity={highlightedPath && !pathHit || filteredServiceId && !hl ? 0.12 : hl ? 1 : countryDim ? 0.12 : 0.52}
|
||||
<g key={`${edge.fromId}|${edge.toId}|${Boolean(edge.observedOnly)}`} data-map-ribbon data-observation={edge.observedOnly || undefined} opacity={(activeService || selected || highlightedPath || filteredServiceId) && !hl ? 0.13 : hl ? 1 : countryDim ? 0.12 : direct ? 0.47 : 0.72}
|
||||
style={{ transition: "opacity 0.3s", cursor: "pointer" }}
|
||||
onPointerDown={(ev) => { ev.stopPropagation() }}
|
||||
onClick={(ev) => { ev.stopPropagation(); if (svc) selectService(svc) }}>
|
||||
<title>{edge.observedOnly
|
||||
? `Наблюдение IPFIX · ${enName} → ${destDisplayLabel(svc, destMode, edge.toId)}${rate} · выход не подтверждён`
|
||||
: `${clientLabel} → ${enName} → ${destDisplayLabel(svc, destMode, edge.toId)}${rate}`}</title>
|
||||
<path d={link.d} fill="none" stroke="var(--chart-4)" strokeWidth={hl ? 2.5 : 1.5} />
|
||||
<path d={link.d} fill="none" stroke="transparent" strokeWidth="14" />
|
||||
{edge.observedOnly && (() => { const p = mapLinkPoint(link, 0.5); return <g transform={`translate(${p.x},${p.y})`}>
|
||||
<rect x="-17" y="-8" width="34" height="16" rx="8" fill="var(--card)" stroke="var(--chart-4)" />
|
||||
{d && <path data-map-route={direct ? "observation" : "service"} d={d} fill="none" stroke={direct ? "var(--muted-foreground)" : "var(--chart-4)"} strokeLinejoin="round" strokeWidth={hl ? 2.5 : 1.5} />}
|
||||
{d && <path d={d} fill="none" stroke="transparent" strokeWidth="12" />}
|
||||
{edge.observedOnly && detour && <g transform={`translate(${detour.marker.x},${detour.marker.y})`}>
|
||||
<rect x="-17" y="-7" width="34" height="14" rx="7" fill="var(--card)" stroke="var(--muted-foreground)" />
|
||||
<text textAnchor="middle" y="3.5" fill="var(--foreground)" fontSize="9">IPFIX</text>
|
||||
</g> })()}
|
||||
{showAnimDots && !reducedMotion && hl && hopHasRate(hop) && (
|
||||
</g>}
|
||||
{!d && <circle cx={link.x2 - 5} cy={link.y2} r="4" fill="var(--muted-foreground)" />}
|
||||
{d && !direct && showAnimDots && !reducedMotion && hl && hopHasRate(hop) && (
|
||||
<circle r="2.5" fill="var(--foreground)" opacity="0.7" pointerEvents="none">
|
||||
<animateMotion dur="2.6s" repeatCount="indefinite" path={link.d} />
|
||||
<animateMotion dur="2.6s" repeatCount="indefinite" path={d} />
|
||||
</circle>
|
||||
)}
|
||||
</g>
|
||||
@@ -2646,8 +2709,8 @@ function NetworkMapContent() {
|
||||
}).filter(Boolean)
|
||||
})}
|
||||
|
||||
{minorPosition && <ServiceNode label={`Остальные сервисы (${minorServices.length})`} share={minorServices.reduce((sum, service) => sum + service.share, 0)} category="Доля каждого ≤ 10%"
|
||||
x={minorPosition.x} y={minorPosition.y} destMode="services" isSel={false} isVis isDragged={false} onPointerDown={() => {}} onClick={() => setShowSmallServices(true)} />}
|
||||
{minorPosition && <ServiceNode label={showSmallServices ? "Свернуть остальные" : `Остальные сервисы (${groupedServices.length})`} share={groupedServices.reduce((sum, service) => sum + service.share, 0)} category={showSmallServices ? `${groupedServices.length} в группе` : "Доля каждого ≤ 10%"}
|
||||
x={minorPosition.x} y={minorPosition.y} destMode="services" expanded={showSmallServices} isSel={false} isVis isDragged={false} onPointerDown={() => {}} onClick={() => setShowSmallServices(value => !value)} />}
|
||||
{visibleMapServices.map((svc) => {
|
||||
const pos = servicePosById[svc.id]
|
||||
if (!pos) return null
|
||||
@@ -2786,14 +2849,8 @@ function NetworkMapContent() {
|
||||
: `Найдено: ${nodes.filter(isVisible).length} узл${nodes.filter(isVisible).length === 1 ? "" : nodes.filter(isVisible).length < 5 ? "а" : "ов"}`}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<MapTimeline events={eventRows} now={eventsAt} onPick={inspectEvent} />
|
||||
</div>
|
||||
</FramePanel>
|
||||
</Frame>
|
||||
|
||||
{/* ── Инспектор: узел, связь или назначение ── */}
|
||||
{inspectorOpen && <Frame spacing="sm" className="fixed inset-x-3 bottom-3 z-30 max-h-[52svh] min-w-0 overflow-hidden shadow-lg md:absolute md:inset-x-auto md:top-14 md:right-3 md:bottom-auto md:max-h-[calc(100svh-10rem)] md:w-80">
|
||||
{inspectorOpen && <Frame spacing="sm" className={cn("fixed inset-x-3 bottom-3 z-30 max-h-[52svh] min-w-0 overflow-hidden md:absolute md:bottom-2", sideInspector ? "md:inset-x-auto md:top-2 md:right-2 md:max-h-none md:w-72" : "md:inset-x-2 md:max-h-[50%]")}>
|
||||
<FramePanel className="flex min-h-0 flex-1 flex-col overflow-hidden p-0">
|
||||
{inspectorOpen && (
|
||||
<div role="complementary" aria-label="Детали объекта карты" className="flex flex-1 flex-col overflow-hidden bg-card w-full min-h-0 min-w-0">
|
||||
@@ -3018,6 +3075,7 @@ function NetworkMapContent() {
|
||||
filtered={filterService?.id === activeService.id} onFilter={() => {
|
||||
setFilteredServiceId(filterService?.id === activeService.id ? null : activeService.id)
|
||||
setBottomTab("flows")
|
||||
setAnalysisOpen(true)
|
||||
}}
|
||||
/>
|
||||
) : liveSelectedService ? (
|
||||
@@ -3554,10 +3612,16 @@ function NetworkMapContent() {
|
||||
)}
|
||||
</FramePanel>
|
||||
</Frame>}
|
||||
</div>
|
||||
<MapTimeline events={recentIncidents} now={eventsAt} state={useLiveData ? eventsError ?? (mapEvents === null ? "Загрузка журнала" : undefined) : undefined} onPick={inspectEvent} />
|
||||
</div>
|
||||
</FramePanel>
|
||||
</Frame>
|
||||
</div>
|
||||
<MapUserPicker open={userPicker} onOpenChange={setUserPicker} users={pickerUsers} pending={ixOnly ? access.linuxPending : access.pending}
|
||||
unavailable={ixOnly ? access.linuxUnavailable : access.unavailable} onPick={pickMapUser} />
|
||||
<MapBottomPanel tab={bottomTab} onTab={setBottomTab} flows={flowRows} rtt={rttRows} destinations={destRows} events={eventRows} onEvent={inspectEvent} eventsError={useLiveData ? eventsError : null} stat={bottomStat} />
|
||||
unavailable={ixOnly ? access.linuxUnavailable : access.unavailable} selectedUser={pickedUser} nodeName={id => mapServers.find(server => server.id === id)?.name ?? id} onPick={pickMapUser} onClear={returnToNetwork} />
|
||||
<MapBottomPanel tab={bottomTab} onTab={setBottomTab} open={analysisOpen} onOpenChange={setAnalysisOpen} flows={flowRows} rtt={rttRows} destinations={destRows} events={eventRows} onEvent={inspectEvent} onFlow={inspectFlow}
|
||||
onDestination={id => { const service = destNodes.find(row => row.id === id); if (service && activeService?.id !== id) selectService(service) }} eventsError={useLiveData ? eventsError : null} stat={bottomStat} />
|
||||
</div>
|
||||
{/* ── Context menu ── */}
|
||||
{ctxMenu&¤tCtxServer&&<ContextMenu menu={{...ctxMenu,server:currentCtxServer}} trafficHref={nodeTrafficHref(currentCtxServer.id)} onClose={()=>setCtxMenu(null)} />}
|
||||
|
||||
Reference in new issue
Block a user