fix(ui): сохранить неизвестные данные и ошибки BGP на дашборде
This commit is contained in:
1 parent
c343ce62c8
commit
f0eaa94e02
11 files changed
+78
-24
No files matched your search
@@ -32,6 +32,7 @@ import type { FiltersRulesetRow, RouteOptimizerSpeedProbe } from "@/lib/route-op
|
||||
import { updateDashboardSource, type DashboardSource, type DashboardSources } from "@/lib/dashboard-source-state"
|
||||
|
||||
import {can,ensureAuthConfig} from "@/lib/auth"
|
||||
import {parseDashboardBgp,type DashboardBgp} from "@/lib/dashboard-bgp"
|
||||
import {dashboardRequestPermission} from "@/lib/dashboard-permissions"
|
||||
async function dashboardRequest<T>(path:string,work:()=>Promise<T>,method="GET"):Promise<T>{
|
||||
await ensureAuthConfig();const permission=dashboardRequestPermission(method,path)
|
||||
@@ -251,7 +252,7 @@ export function useDashboardLive() {
|
||||
const [liveProbes, setLiveProbes] = useState<PingProbe[] | null>(null)
|
||||
const [liveServers, setLiveServers] = useState<Server[] | null>(null)
|
||||
const [overlayItems, setOverlayItems] = useState<OverlayItem[] | null>(null)
|
||||
const [bgp, setBgp] = useState<{ prefixSum: number; establishedCount: number } | null>(null)
|
||||
const [bgp, setBgp] = useState<DashboardBgp | null>(null)
|
||||
const [trafficSeries, setTrafficSeries] = useState<{
|
||||
rx: number[]
|
||||
tx: number[]
|
||||
@@ -293,7 +294,7 @@ export function useDashboardLive() {
|
||||
apiFetch<{ probes: PingProbe[] }>("/api/uptime/overview?range=1h"),
|
||||
apiFetch<BackendServerRow[]>("/api/servers"),
|
||||
apiFetch<{ rulesets: Array<{ rules?: unknown[] }> }>("/api/filters/rules"),
|
||||
apiFetch<Array<{ state?: string; prefixesRx?: number }>>("/api/bgp/sessions"),
|
||||
apiFetch<unknown>("/api/bgp/catalog").then(parseDashboardBgp),
|
||||
apiFetch<{ snapshot: InternetPathSnapshotPayload | null }>("/api/internet-path/latest"),
|
||||
apiFetch<{ tunnels?: ApiGreTunnelRow[] }>("/api/filters/gre-tunnels"),
|
||||
dashboardRequest("/api/wireguard",()=>listWireGuard(backendUrl)),
|
||||
@@ -320,18 +321,7 @@ export function useDashboardLive() {
|
||||
setLiveServers(serversMapped)
|
||||
}
|
||||
|
||||
if (br.status === "fulfilled") {
|
||||
let prefixSum = 0
|
||||
let establishedCount = 0
|
||||
for (const s of br.value) {
|
||||
const st = String(s.state ?? "")
|
||||
if (/established/i.test(st)) {
|
||||
establishedCount += 1
|
||||
prefixSum += Number(s.prefixesRx ?? 0)
|
||||
}
|
||||
}
|
||||
setBgp({ prefixSum, establishedCount })
|
||||
}
|
||||
if (br.status === "fulfilled") setBgp(br.value)
|
||||
|
||||
const greItems: OverlayItem[] =
|
||||
greRes.status === "fulfilled"
|
||||
|
||||
Reference in new issue
Block a user