fix(ui): учитывать область в стоимости соседа OSPF

This commit is contained in:
Denozordec committed 2026-09-30 18:09:10 +07:00
1 parent 2199950681
commit b1080b0a05
6 files changed
+54 -9

No files matched your search

+4 -6
View File
@@ -1,5 +1,6 @@
"use client"
import { buildOspfCostIndex, ospfCostKey } from "@/lib/ospf-cost"
import { normalizeOspfState, normalizeBfdState, ospfNodeState, type OspfNeighborState, type BfdState } from "@/lib/ospf-state"
import { useMemo, useState, useEffect, useRef } from "react"
import { ospfCatalogSchema, ospfServersSchema, ospfOptimizeSchema, type OspfCatalog } from "@/lib/ospf-response"
@@ -139,9 +140,9 @@ function isRefInterfaceName(name: string): boolean {
// ─── backend → frontend mappers ───────────────────────────────────────────────
function backendToNeighbor(b: BackendNeighbor, ifaceMap: Map<string, number>): OspfNeighbor {
function backendToNeighbor(b: BackendNeighbor, ifaceMap: Map<string, number | null>): OspfNeighbor {
const state = normalizeOspfState(b.state)
const costKey = `${b.serverId}::${b.interface}`
const costKey = ospfCostKey(b.serverId, b.interface, b.areaId)
return {
id: `${b.serverId}-${b.id}`,
localRouter: String(b.serverId),
@@ -1203,10 +1204,7 @@ function OspfPageContent() {
const { items, neighbors, graphNodes, graphEdges, routerIds, bfdSessions, routes } = useMemo(() => {
if (isLive && liveData) {
// Build interface→cost map for neighbor cost lookup
const ifaceMap = new Map<string, number>()
for (const iface of liveData.interfaces) {
ifaceMap.set(`${iface.serverId}::${iface.interface}`, iface.cost)
}
const ifaceMap = buildOspfCostIndex(liveData.interfaces)
const items = liveData.interfaces
.map(b => ({ ...backendToItem(b), dataUnknown: unknownIds.has(b.serverId) }))