fix(api): сохранять неизвестные показатели BFD и OSPF

This commit is contained in:
Denozordec committed 2026-09-30 19:42:07 +07:00
1 parent 47dcd89b3c
commit e3791f3496
13 files changed
+136 -44

No files matched your search

+14 -14
View File
@@ -27,16 +27,16 @@ export interface BfdSessionRow {
localAddr: string
remoteAddr: string
state: BfdState
interval: number
multiplier: number
interval: number | null
multiplier: number | null
iface: string
uptime: string | null
multihop: boolean
rxInterval: number
holdTime: number
packetsRx: number
packetsTx: number
stateChanges: number
rxInterval: number | null
holdTime: number | null
packetsRx: number | null
packetsTx: number | null
stateChanges: number | null
}
function stateClass(state: BfdSessionRow["state"]) {
@@ -61,8 +61,8 @@ function Chip({ children, color }: { children: React.ReactNode; color?: string }
)
}
function fmtMs(ms: number) {
if (!ms) return "—"
function fmtMs(ms: number | null) {
if (ms === null) return "—"
if (ms < 1000) return `${ms}ms`
return `${(ms / 1000).toFixed(1)}s`
}
@@ -177,7 +177,7 @@ function OspfBfdDataGrid({ sessions }: OspfBfdDataGridProps) {
},
{
id: "intervals",
header: () => <span className="text-xs font-medium text-muted-foreground">Tx / Rx</span>,
header: () => <span className="text-xs font-medium text-muted-foreground">TX факт / RX минимум</span>,
enableSorting: false,
cell: ({ row }) => {
const b = row.original
@@ -209,7 +209,7 @@ function OspfBfdDataGrid({ sessions }: OspfBfdDataGridProps) {
accessorKey: "multiplier",
header: ({ column }) => <DataGridSortHeader column={column} title="Mult" />,
cell: ({ row }) => (
<span className="font-mono tabular-nums text-center block">{row.original.multiplier}</span>
<span className="font-mono tabular-nums text-center block">{row.original.multiplier ?? "—"}</span>
),
meta: {
headerTitle: "Mult",
@@ -225,7 +225,7 @@ function OspfBfdDataGrid({ sessions }: OspfBfdDataGridProps) {
),
cell: ({ row }) => (
<span className="font-mono tabular-nums text-right text-muted-foreground block">
{row.original.packetsRx.toLocaleString()}
{row.original.packetsRx?.toLocaleString() ?? "—"}
</span>
),
meta: {
@@ -242,7 +242,7 @@ function OspfBfdDataGrid({ sessions }: OspfBfdDataGridProps) {
),
cell: ({ row }) => (
<span className="font-mono tabular-nums text-right text-muted-foreground block">
{row.original.packetsTx.toLocaleString()}
{row.original.packetsTx?.toLocaleString() ?? "—"}
</span>
),
meta: {
@@ -258,7 +258,7 @@ function OspfBfdDataGrid({ sessions }: OspfBfdDataGridProps) {
<DataGridSortHeader column={column} title="Переходы" className="ml-auto" />
),
cell: ({ row }) => (
<span className="font-mono tabular-nums text-right block">{row.original.stateChanges}</span>
<span className="font-mono tabular-nums text-right block">{row.original.stateChanges ?? "—"}</span>
),
meta: {
headerTitle: "Переходы",
@@ -32,7 +32,7 @@ export interface OspfNeighborRow {
state: OspfNeighborState
cost: number | null
uptime: string
priority: number
priority: number | null
}
function stateClass(state: OspfNeighborRow["state"]) {
@@ -177,7 +177,7 @@ function OspfNeighborsDataGrid({
accessorKey: "priority",
header: ({ column }) => <DataGridSortHeader column={column} title="Prio" />,
cell: ({ row }) => (
<span className="text-center font-mono block">{row.original.priority}</span>
<span className="text-center font-mono block">{row.original.priority ?? "—"}</span>
),
meta: {
headerTitle: "Prio",