fix(map): показывать скорость сервисов по короткому окну IPFIX
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 2m14s
Docker images / updater-image (push) Successful in 39s
Docker images / netflow-agent-image (push) Successful in 31s
Docker images / backend-image (push) Successful in 15s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 2m14s
Docker images / updater-image (push) Successful in 39s
Docker images / netflow-agent-image (push) Successful in 31s
Docker images / backend-image (push) Successful in 15s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
This commit is contained in:
1 parent
ed7b1e0350
commit
c44bcd8f59
14 files changed
+261
-120
No files matched your search
@@ -26,7 +26,8 @@ import {
|
||||
type ServerStatus,
|
||||
type ServerType,
|
||||
} from "@/lib/data"
|
||||
import {validateNetworkMapSnapshot,networkMapFlowSchema,validateNetworkMapDns,type NetworkMapServerRow} from "@/lib/network-map-response"
|
||||
import {validateNetworkMapSnapshot,networkMapFlowSchema,recentMapFlowSchema,validateNetworkMapDns,type NetworkMapServerRow} from "@/lib/network-map-response"
|
||||
import { getFlowMapHops } from "@/shared/api/traffic-flow"
|
||||
import { useDataSource } from "@/lib/data-source"
|
||||
import { requestJson } from "@/shared/api/http-client"
|
||||
import {
|
||||
@@ -196,6 +197,30 @@ function makeApiFetch(backendUrl: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function useServiceSnapshot(base: string | null, range: "1m" | "5m", userId: string | undefined, refresh: number) {
|
||||
const key = JSON.stringify([base, range, userId])
|
||||
const [snapshot, setSnapshot] = useState<{ key: string; refresh: number; data?: ReturnType<typeof networkMapFlowSchema.parse>; at?: string; error?: string }>()
|
||||
useEffect(() => {
|
||||
if (base === null) return
|
||||
const controller = new AbortController()
|
||||
let timer: ReturnType<typeof setTimeout>
|
||||
const poll = async () => {
|
||||
try {
|
||||
const raw = await getFlowMapHops(base, { range, userId }, { signal: controller.signal })
|
||||
const data = (range === "1m" ? recentMapFlowSchema : networkMapFlowSchema).parse(raw)
|
||||
if (!controller.signal.aborted) setSnapshot({ key, refresh, data, at: new Date().toISOString() })
|
||||
} catch {
|
||||
if (!controller.signal.aborted) setSnapshot(last => ({ ...(last?.key === key ? last : undefined), key, refresh, error: "Не удалось обновить данные IPFIX" }))
|
||||
} finally {
|
||||
if (!controller.signal.aborted) timer = setTimeout(poll, range === "1m" ? 4000 : 15_000)
|
||||
}
|
||||
}
|
||||
queueMicrotask(() => { if (!controller.signal.aborted) void poll() })
|
||||
return () => { controller.abort(); clearTimeout(timer) }
|
||||
}, [base, range, userId, refresh, key])
|
||||
return base !== null && snapshot?.key === key ? snapshot : undefined
|
||||
}
|
||||
|
||||
function fmtMB(mb: number | null): string {
|
||||
if(mb==null)return "—"
|
||||
if (mb >= 1024) return `${(mb / 1024).toFixed(mb >= 10240 ? 0 : 1)} ГБ`
|
||||
@@ -952,11 +977,11 @@ function NetworkMapContent() {
|
||||
const [flowReadAt,setFlowReadAt]=useState<string|null>(null)
|
||||
const [flowListener,setFlowListener]=useState(false)
|
||||
const [flowLoading,setFlowLoading]=useState(false)
|
||||
const [userFlow, setUserFlow] = useState<{ key: string; data?: ReturnType<typeof networkMapFlowSchema.parse>; at?: string; 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 [filterService, setFilterService] = useState<Pick<FlowMapService, "id" | "label"> | null>(null)
|
||||
const filteredServiceId = filterService?.id ?? null
|
||||
const [mapEvents, setMapEvents] = useState<EventItem[] | null>(null)
|
||||
const [eventsError, setEventsError] = useState<string | null>(null)
|
||||
const [eventsAt, setEventsAt] = useState(() => Date.now())
|
||||
@@ -1133,7 +1158,7 @@ function NetworkMapContent() {
|
||||
function setDestMode(mode: DestMode) {
|
||||
updateUrl({dest:mode==="services"?null:mode,service:null})
|
||||
setSelectedService(null)
|
||||
setFilteredServiceId(null)
|
||||
setFilterService(null)
|
||||
setExpandedCountryId(null)
|
||||
setHighlightedPath(null)
|
||||
try { sessionStorage.setItem(DEST_MODE_KEY, mode) } catch { /* private mode */ }
|
||||
@@ -1327,38 +1352,25 @@ function NetworkMapContent() {
|
||||
const usersInTopology = [...(ixOnly ? [] : access.users), ...access.linux].filter(user => user.bindings.some(binding => topologyIds.has(binding.node)))
|
||||
const pickedUser = usersInTopology.find(user => user.id === pickedUserId)
|
||||
const scopeUser = pickedUser && !pickedUser.linux ? pickedUser.id : undefined
|
||||
const scopeKey = JSON.stringify([backendUrl, scopeUser, flowRefresh])
|
||||
const userSnapshot = useLiveData && scopeUser && userFlow?.key === scopeKey ? userFlow : undefined
|
||||
const destinationWindowSec = userSnapshot?.data?.windowSec ?? mapWindowSec
|
||||
const destinationWindow = formatMapFlowWindow(destinationWindowSec)
|
||||
const destinationReadAt = pickedUserId ? userSnapshot?.at ?? null : flowReadAt
|
||||
const destinationTotalBytes = pickedUserId ? userSnapshot?.data?.totalBytes : mapTotalBytes
|
||||
const destinationNamedBytes = pickedUserId ? userSnapshot?.data?.namedBytes : mapNamedBytes
|
||||
useEffect(() => {
|
||||
if (!useLiveData || !scopeUser || !showServices) return
|
||||
const controller = new AbortController()
|
||||
let timer: ReturnType<typeof setTimeout>
|
||||
async function refresh() {
|
||||
try {
|
||||
const raw = await apiFetch<unknown>(`/api/traffic/flow/map-hops?${new URLSearchParams({range:"5m",userId:scopeUser!})}`, {signal:controller.signal})
|
||||
const data = networkMapFlowSchema.parse(raw)
|
||||
if (!controller.signal.aborted) setUserFlow({ key: scopeKey, data, at: new Date().toISOString() })
|
||||
} catch {
|
||||
if (!controller.signal.aborted) setUserFlow(last => ({ ...(last?.key === scopeKey ? last : undefined), key: scopeKey, error: "Снимок потоков пользователя недоступен" }))
|
||||
} finally {
|
||||
if (!controller.signal.aborted) timer = setTimeout(() => { void refresh() }, 15_000)
|
||||
}
|
||||
}
|
||||
void refresh()
|
||||
return () => { controller.abort(); clearTimeout(timer) }
|
||||
}, [useLiveData, scopeUser, showServices, scopeKey, apiFetch])
|
||||
const rawPaths = destMode === "countries" ? mapCountryPaths : mapServicePaths
|
||||
const filterPaths = filteredServiceId?.includes("|") ? mapCountryServiceGroups.find(group => group.countryId === filteredServiceId.split("|")[0])?.paths ?? [] : rawPaths
|
||||
const liveServiceView = useLiveData && destMode === "services"
|
||||
const requestRecent = liveServiceView && (showServices || showNetflow) && (!pickedUserId || Boolean(scopeUser))
|
||||
const recent = useServiceSnapshot(requestRecent ? backendUrl : null, "1m", scopeUser, flowRefresh)
|
||||
const history = useServiceSnapshot(liveServiceView && scopeUser && (selectedService || linkedService) ? backendUrl : null, "5m", scopeUser, flowRefresh)
|
||||
const destinationWindowSec = liveServiceView ? recent?.data?.windowSec ?? 60 : mapWindowSec
|
||||
const destinationWindow = liveServiceView && !recent?.data ? "—" : formatMapFlowWindow(destinationWindowSec)
|
||||
const destinationReadAt = liveServiceView ? recent?.at ?? null : flowReadAt
|
||||
const destinationListener = liveServiceView ? recent?.data?.live : flowListener
|
||||
const destinationTotalBytes = liveServiceView ? recent?.data?.totalBytes : mapTotalBytes
|
||||
const destinationNamedBytes = liveServiceView ? recent?.data?.namedBytes : mapNamedBytes
|
||||
const initialDestNodes = liveServiceView ? recent?.data?.services ?? [] : destMode === "countries" ? mapCountries : mapServices
|
||||
const initialDestEdges = liveServiceView ? recent?.data?.serviceEdges ?? [] : destMode === "countries" ? mapCountryEdges : mapServiceEdges
|
||||
const rawPaths = liveServiceView ? recent?.data?.servicePaths ?? [] : destMode === "countries" ? mapCountryPaths : mapServicePaths
|
||||
const filterPaths = filteredServiceId?.includes("|") ? mapCountryServiceGroups.find(group => group.countryId === filteredServiceId.split("|")[0])?.paths ?? [] : scopeUser ? mapServicePaths : rawPaths
|
||||
const topologyPaths = rawPaths.filter(path => topologyIds.has(path.enId || path.viaId))
|
||||
const servicePaths = filteredServiceId ? filterPaths.filter(path => topologyIds.has(path.enId || path.viaId) && path.serviceId === filteredServiceId) : []
|
||||
const userIdsForService = new Set(servicePaths.map(path => path.clientId))
|
||||
const pickerUsers = filteredServiceId ? usersInTopology.filter(user => !user.linux && userIdsForService.has(user.id)) : usersInTopology
|
||||
const pickedPaths = pickedUser && !pickedUser.linux ? (userSnapshot?.data?.servicePaths ?? topologyPaths).filter(path => path.clientId === pickedUser.id && topologyIds.has(path.enId || path.viaId)) : []
|
||||
const pickedPaths = pickedUser && !pickedUser.linux ? topologyPaths.filter(path => path.clientId === pickedUser.id) : []
|
||||
const accessGroups = new Map<string, typeof usersInTopology>()
|
||||
for (const user of showUsers ? (pickedUser ? [pickedUser] : pickerUsers) : []) {
|
||||
const bindings = new Set(user.bindings.map(binding => binding.node))
|
||||
@@ -1366,11 +1378,11 @@ function NetworkMapContent() {
|
||||
}
|
||||
const focusedNodeIds = new Set([...(pickedUser?.bindings.map(binding => binding.node) ?? accessGroups.keys()), ...pickedPaths.flatMap(path => [path.viaId, path.enId])])
|
||||
const serviceNodeIds = new Set([...accessGroups.keys(), ...servicePaths.flatMap(path => [path.viaId, path.enId]),
|
||||
...(destMode === "countries" ? mapCountryEdges : mapServiceEdges).filter(edge => edge.toId === filteredServiceId).map(edge => edge.fromId)])
|
||||
...initialDestEdges.filter(edge => edge.toId === filteredServiceId).map(edge => edge.fromId)])
|
||||
const onMap = (id: string) => topologyIds.has(id) && (pickedUserId ? focusedNodeIds.has(id) && Boolean(pickedUser) : !filteredServiceId || !serviceNodeIds.size || serviceNodeIds.has(id))
|
||||
const userDetailsOpen = Boolean(pickedUser && inspectUser && !selected && !selectedGreStored && !selectedService && !params.has("service"))
|
||||
function changeMapView(ix: boolean) {
|
||||
setSelectedGreEdge(null); setSelectedService(null); setHighlightedPath(null); setFilteredServiceId(null)
|
||||
setSelectedGreEdge(null); setSelectedService(null); setHighlightedPath(null); setFilterService(null)
|
||||
setExpandedCountryId(null); setShowSmallServices(false)
|
||||
updateUrl({ filter: ix ? "ix-node" : null, server: null, wan: null, user: null, service: null, q: null, dest: null })
|
||||
}
|
||||
@@ -1547,14 +1559,15 @@ function NetworkMapContent() {
|
||||
return m
|
||||
}, [homeRouters, mapHops, showNetflow])
|
||||
|
||||
const initialDestNodes = destMode === "countries" ? mapCountries : mapServices
|
||||
const initialDestEdges = destMode === "countries" ? mapCountryEdges : mapServiceEdges
|
||||
const scoped = pickedUserId && !pickedUser ? { services: [], edges: [], paths: [] } : userSnapshot?.data
|
||||
? scopeMapDestinations(userSnapshot.data.services, userSnapshot.data.serviceEdges, userSnapshot.data.servicePaths, id => topologyIds.has(id))
|
||||
: pickedUser || ixOnly || splitIx && isolatedIx.size > 0
|
||||
? scopeMapDestinations(initialDestNodes, initialDestEdges, pickedUser?.linux ? [] : rawPaths, id => topologyIds.has(id), pickedUser?.id, !ixOnly && !pickedUser)
|
||||
: { services: initialDestNodes, edges: initialDestEdges, paths: rawPaths }
|
||||
const { services: destNodes, edges: destEdges, paths: destPaths } = scoped
|
||||
function inMapScope(services: FlowMapService[], edges: FlowMapServiceEdge[], paths: FlowMapServicePath[]) {
|
||||
if (pickedUserId && !pickedUser) return { services: [], edges: [], paths: [], shareOfVisible: false }
|
||||
const localUser = liveServiceView && scopeUser ? undefined : pickedUser?.id
|
||||
return localUser || ixOnly || splitIx && isolatedIx.size > 0
|
||||
? scopeMapDestinations(services, edges, pickedUser?.linux ? [] : paths, id => topologyIds.has(id), localUser, !ixOnly && !pickedUser)
|
||||
: { services, edges, paths, shareOfVisible: false }
|
||||
}
|
||||
const { services: destNodes, edges: destEdges, paths: destPaths, shareOfVisible } = inMapScope(initialDestNodes, initialDestEdges, rawPaths)
|
||||
const destinationShareLabel = shareOfVisible ? "трафика показанных назначений" : "трафика окна"
|
||||
const countryGroup = destMode === "countries" ? mapCountryServiceGroups.find(group => group.countryId === expandedCountryId) : undefined
|
||||
const expandedCountryGroup = countryGroup && splitIx && isolatedIx.size > 0 ? (() => {
|
||||
const paths = countryGroup.paths.filter(path => topologyIds.has(path.enId || path.viaId))
|
||||
@@ -1562,10 +1575,17 @@ function NetworkMapContent() {
|
||||
const result = scopeMapDestinations(countryGroup.services, edges, paths, () => true)
|
||||
return { countryId: countryGroup.countryId, ...result }
|
||||
})() : countryGroup
|
||||
const countryShareOfVisible = Boolean(expandedCountryGroup && "shareOfVisible" in expandedCountryGroup && expandedCountryGroup.shareOfVisible)
|
||||
const nestedServices = useMemo(() => expandedCountryGroup?.services ?? [], [expandedCountryGroup])
|
||||
const activeServiceId = selectedService?.id ?? linkedService
|
||||
const selectedNestedService = nestedServices.find(service => service.id === activeServiceId)
|
||||
const activeService = destNodes.find(service => service.id === activeServiceId) ?? selectedNestedService ?? null
|
||||
const historyWindowSec = scopeUser ? history?.data?.windowSec : mapWindowSec
|
||||
const networkHistory = flowReadAt && !flowError ? {services: mapServices, serviceEdges: mapServiceEdges, servicePaths: mapServicePaths} : undefined
|
||||
const serviceHistory = scopeUser ? (history?.error ? undefined : history?.data) : networkHistory
|
||||
const archivedService = liveServiceView && activeService && serviceHistory
|
||||
? inMapScope(serviceHistory.services, serviceHistory.serviceEdges, serviceHistory.servicePaths).services.find(row => row.id === activeService.id)
|
||||
: undefined
|
||||
const liveSelectedService = activeService
|
||||
const expandedCountry = destNodes.find(service => service.id === expandedCountryId)
|
||||
const minorServices = destMode === "services" ? destNodes.filter(service => service.share <= 0.1) : []
|
||||
@@ -1739,7 +1759,7 @@ function NetworkMapContent() {
|
||||
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}:${Math.round(canvasPx.w)}x${Math.round(canvasPx.h)}`
|
||||
const viewKey = `${ixOnly}:${pickedUser?.id ?? ""}:${filteredServiceId ?? ""}:${showSmallServices}:${splitIx}:${fitWidth !== W}:${Boolean(recent?.data)}:${showUsers && usersInTopology.length > 0}:${Math.round(canvasPx.w)}x${Math.round(canvasPx.h)}`
|
||||
const lastViewKey = useRef(viewKey)
|
||||
const lastUserView = useRef(pickedUser?.id)
|
||||
useEffect(() => {
|
||||
@@ -2202,7 +2222,6 @@ function NetworkMapContent() {
|
||||
return { id: e.id, ts: eventsAt - (m ? Number(m[1]) * unitMs[m[2]] : 0), ...eventTone(e.sev === "destructive" ? "critical" : e.sev), title: e.title, message: e.message }
|
||||
})
|
||||
).filter(e => Number.isFinite(e.ts)).sort((a, b) => b.ts - a.ts)
|
||||
const filterService = initialDestNodes.find(service => service.id === filteredServiceId) ?? (liveSelectedService?.id === filteredServiceId ? liveSelectedService : null)
|
||||
const tablePaths = filterService ? (selectedNestedService ? expandedCountryGroup?.paths ?? [] : destPaths).filter(p => p.serviceId === filterService.id) : destPaths
|
||||
const flowRows = [...tablePaths].sort((a, b) => b.bps - a.bps).slice(0, 100).map(p => ({
|
||||
id: servicePathKey(p),
|
||||
@@ -2244,7 +2263,7 @@ function NetworkMapContent() {
|
||||
<>
|
||||
<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 · ${destinationWindow}${destinationWindowSec >= 120 && destinationWindowSec < 300 ? " из 5 запрошенных" : ""} · ответ ${new Date(destinationReadAt ?? flowReadAt).toLocaleTimeString("ru-RU")} · ${flowListener ? "приёмник включён" : "приёмник выключен"} · средняя скорость по сохранённым потокам`}>IPFIX · среднее за {destinationWindow}{!flowListener ? " · приёмник выключен" : ""}</span> : <span>Данные NetFlow неизвестны</span>}</>}
|
||||
{useLiveData && (showNetflow || showServices) && <>{" · "}{destinationReadAt ? <span title={`NetFlow · ${destinationWindow}${!liveServiceView && destinationWindowSec < 300 ? " из 5 запрошенных" : ""} · средняя скорость по принятым записям IPFIX · ответ ${new Date(destinationReadAt).toLocaleTimeString("ru-RU")}`}>IPFIX · среднее за {destinationWindow}{!destinationListener ? " · приёмник выключен" : ""}</span> : <span>Данные NetFlow неизвестны</span>}</>}
|
||||
</>
|
||||
)
|
||||
// Подсказки поиска макета: узлы и назначения текущего снимка.
|
||||
@@ -2254,8 +2273,10 @@ function NetworkMapContent() {
|
||||
...(showServices ? destNodes : []).filter((d) => !sq || destDisplayLabel(d, destMode).toLowerCase().includes(sq)).map((d) => ({ key: "d:" + d.id, label: destDisplayLabel(d, destMode), sub: `${destMode === "countries" ? "Страна" : d.category || "Сервис"} · ${formatNetflowRate({ bps: d.bps })}`, dot: "var(--chart-4)", pick: () => selectService(d) })),
|
||||
].slice(0, 8) : []
|
||||
const statusFilterLabel = ({ online: "Онлайн", degraded: "Внимание", offline: "Оффлайн", unknown: "Неизвестно", "jump-host": "JumpHost", "exit-node": "Exit Node", "home-router": "Home Router" } as Record<string, string>)[filter]
|
||||
const bottomStat = `Окно ${mapWindow}${flowReadAt ? " · " + new Date(flowReadAt).toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" }) : ""}${filterService && bottomTab === "flows" ? " · фильтр: " + filterService.label : selected || selectedService || selectedGreEdge ? " · строки выбранного объекта подсвечены" : ""}`
|
||||
const refreshBusy = dataLoading || flowLoading && (showNetflow || showServices) || Boolean(useLiveData && scopeUser && showServices && !userSnapshot)
|
||||
const bottomServiceTab = bottomTab === "flows" || bottomTab === "dest"
|
||||
const bottomReadAt = bottomServiceTab ? destinationReadAt : flowReadAt
|
||||
const bottomStat = `Окно ${bottomServiceTab ? destinationWindow : mapWindow}${bottomReadAt ? " · " + new Date(bottomReadAt).toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" }) : ""}${filterService && bottomTab === "flows" ? " · фильтр: " + filterService.label : selected || selectedService || selectedGreEdge ? " · строки выбранного объекта подсвечены" : ""}`
|
||||
const refreshBusy = dataLoading || flowLoading && (showNetflow || showServices) || requestRecent && recent?.refresh !== flowRefresh
|
||||
const inspectorOpen = detailsOpen
|
||||
function inspectEvent(event: MapEventRow) {
|
||||
setInspectedEvent(event)
|
||||
@@ -2426,7 +2447,7 @@ function NetworkMapContent() {
|
||||
<UsersIcon aria-hidden />{pickedUser?.name ?? (ixOnly ? "Linux-клиенты" : "Пользователи")}
|
||||
</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>}
|
||||
{filterService && <Button type="button" variant="outline" size="sm" aria-label={`Сбросить фильтр сервиса ${filterService.label}`} onClick={() => setFilterService(null)}>{filterService.label}<XIcon aria-hidden /></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>
|
||||
@@ -2479,12 +2500,12 @@ function NetworkMapContent() {
|
||||
<NetworkMapLegend compact={Boolean(selected || selectedGreEdge || selectedService || (nodes.length && !nodes.some(isVisible)))} />
|
||||
</FramePanel>
|
||||
|
||||
{(inspectedEvent || userSnapshot?.error) && <FramePanel className="flex flex-col gap-2" aria-label="Разбор события">
|
||||
{(inspectedEvent || recent?.error) && <FramePanel className="flex flex-col gap-2" aria-label="Разбор события">
|
||||
{inspectedEvent && <>
|
||||
<div className="flex items-start justify-between gap-2"><div className="min-w-0"><h2 className="text-sm font-semibold">{inspectedEvent.title}</h2><p className="text-xs text-muted-foreground">{new Date(inspectedEvent.ts).toLocaleString("ru-RU")} · {inspectedEvent.message}</p></div><Button variant="ghost" size="icon-xs" aria-label="Закрыть разбор" onClick={() => setInspectedEvent(null)}><XIcon /></Button></div>
|
||||
{inspectedEvent.serverId && <Link className={buttonVariants({variant:"outline",size:"xs",className:"self-start"})} href={nodeTrafficHref(inspectedEvent.serverId)}>Трафик узла</Link>}
|
||||
</>}
|
||||
{userSnapshot?.error && <p role="status" className="text-xs text-muted-foreground">{userSnapshot.error}. Показаны подтверждённые строки из доступного снимка.</p>}
|
||||
{recent?.error && <p role="status" className="text-xs text-muted-foreground">{recent.error}. {recent.data ? "Показан предыдущий снимок сервисов." : "Скорости сервисов пока недоступны."}</p>}
|
||||
</FramePanel>}
|
||||
|
||||
{/* Состояние данных: загрузка и ошибки снимка, NetFlow и DNS */}
|
||||
@@ -2727,7 +2748,7 @@ function NetworkMapContent() {
|
||||
})}
|
||||
|
||||
{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)} />}
|
||||
x={minorPosition.x} y={minorPosition.y} destMode="services" shareLabel={destinationShareLabel} expanded={showSmallServices} isSel={false} isVis isDragged={false} onPointerDown={() => {}} onClick={() => setShowSmallServices(value => !value)} />}
|
||||
{visibleMapServices.map((svc) => {
|
||||
const pos = servicePosById[svc.id]
|
||||
if (!pos) return null
|
||||
@@ -2736,6 +2757,7 @@ function NetworkMapContent() {
|
||||
key={svc.id}
|
||||
label={destDisplayLabel(svc, destMode)}
|
||||
share={svc.share}
|
||||
shareLabel={destinationShareLabel}
|
||||
category={destMode === "countries" ? "Страна" : serviceMapSubtitle(svc)}
|
||||
rate={formatNetflowRate({ bytes: svc.bytes, bps: svc.bps, bpsFwd: svc.bps, bpsRev: 0 })}
|
||||
compact={Boolean(expandedCountryGroup)}
|
||||
@@ -2778,7 +2800,7 @@ function NetworkMapContent() {
|
||||
isVis
|
||||
isDragged={draggedSvcId === svc.id}
|
||||
destMode="services"
|
||||
shareLabel="трафика страны"
|
||||
shareLabel={countryShareOfVisible ? "трафика показанных сервисов страны" : "трафика страны"}
|
||||
onPointerDown={(e) => onServicePointerDown(e, svc.id, pos.x, pos.y)}
|
||||
onClick={() => {
|
||||
if (suppressClickRef.current) { suppressClickRef.current = false; return }
|
||||
@@ -3080,17 +3102,19 @@ function NetworkMapContent() {
|
||||
</div>
|
||||
</>
|
||||
) : activeService && (destMode === "services" || selectedNestedService) ? (
|
||||
<ServiceInspector key={activeService.id} service={activeService}
|
||||
<ServiceInspector key={JSON.stringify([pickedUserId, ixOnly, activeService.id])} service={activeService}
|
||||
paths={selectedDestPaths}
|
||||
exits={selectedNestedService ? [] : selectedDestEdges}
|
||||
exitName={id => mapServers.find(s => s.id === id)?.name ?? id}
|
||||
country={selectedNestedService ? expandedCountry?.label : undefined}
|
||||
base={useLiveData ? backendUrl : null} refresh={flowRefresh} windowLabel={destinationWindow} flowAt={destinationReadAt} stale={Boolean(pickedUserId ? userSnapshot?.error : flowError)}
|
||||
shareOfVisible={selectedNestedService ? countryShareOfVisible : shareOfVisible}
|
||||
base={useLiveData ? backendUrl : null} refresh={flowRefresh} windowLabel={destinationWindow} flowAt={destinationReadAt} stale={Boolean(liveServiceView ? recent?.error : flowError)}
|
||||
history={liveServiceView ? {service: archivedService, window: formatMapFlowWindow(historyWindowSec ?? 300)} : undefined}
|
||||
activePath={highlightedPath} onPath={togglePathHighlight}
|
||||
onClose={() => { setSelectedService(null); updateUrl({service:null}); returnToMapControl() }}
|
||||
userId={pickedUser?.id} ix={ixOnly} topology={ixOnly || splitIx && isolatedIx.size > 0 ? topologyIds : undefined}
|
||||
filtered={filterService?.id === activeService.id} onFilter={() => {
|
||||
setFilteredServiceId(filterService?.id === activeService.id ? null : activeService.id)
|
||||
setFilterService(filterService?.id === activeService.id ? null : {id: activeService.id, label: activeService.label})
|
||||
setBottomTab("flows")
|
||||
setAnalysisOpen(true)
|
||||
}}
|
||||
@@ -3123,7 +3147,7 @@ function NetworkMapContent() {
|
||||
<div className="flex-1 min-h-0 overflow-y-auto px-4 py-4 flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<div className="flex items-center justify-between py-2 border-b border-border/50">
|
||||
<span className="text-xs text-muted-foreground">Доля окна</span>
|
||||
<span className="text-xs text-muted-foreground">Доля {destinationShareLabel}</span>
|
||||
<span className="text-xs font-mono font-medium text-cyan-400">{serviceSharePct(liveSelectedService.share)}</span>
|
||||
</div>
|
||||
{destinationTotalBytes !== undefined && destinationTotalBytes > 0 && destinationNamedBytes !== undefined && (
|
||||
|
||||
Reference in new issue
Block a user