fix(api): передавать происхождение метрик оптимизатора OSPF

This commit is contained in:
Denozordec committed 2026-10-01 00:50:17 +07:00
1 parent 255f272fab
commit 7077844655
13 files changed
+96 -9

No files matched your search

@@ -3,6 +3,7 @@
import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
import { useMemo } from "react"
import type {OspfOptimizerObserved} from "@mmapp/contracts"
import {
type ColumnDef,
useTable,
@@ -17,7 +18,15 @@ import { DataGridSortHeader } from "@/components/data-grids/shared/data-grid-sor
import { EmptyState } from "@/components/empty-state"
import { NetworkIcon } from "lucide-react"
function describeObserved(metric:OspfOptimizerObserved["ping"]|undefined,unit:string){
if(!metric || metric.value===null)return "Измерение: —"
const source=metric.source==="speed-probe"?"Проба":"Трафик интерфейса"
const date=metric.measuredAt?new Date(metric.measuredAt).toLocaleString("ru-RU"):"дата неизвестна"
return source+": "+metric.value+" "+unit+" · "+date
}
export interface OspfPreviewInterfaceRow {
observed?: OspfOptimizerObserved
id: string
interface: string
currentCost: number
@@ -88,19 +97,19 @@ function RouteOptimizerOspfPreviewDataGrid({
{
id: "pingMs",
accessorKey: "pingMs",
header: ({ column }) => <DataGridSortHeader column={column} title="Ping" />,
cell: ({ row }) => <span className="font-mono">{row.original.pingMs}ms</span>,
meta: { headerTitle: "Ping", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD },
header: ({ column }) => <DataGridSortHeader column={column} title="Ping модели" />,
cell: ({ row }) => <div><span className="font-mono">{row.original.pingMs}ms</span><p className="text-[10px] text-muted-foreground">{describeObserved(row.original.observed?.ping,"мс")}</p></div>,
meta: { headerTitle: "Ping модели", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD },
},
{
id: "speed",
header: () => <span className="text-xs font-medium text-muted-foreground">Speed (dl/ul)</span>,
header: () => <span className="text-xs font-medium text-muted-foreground">Speed (dl/ul) · модель</span>,
enableSorting: false,
cell: ({ row }) => {
const r = row.original
return (
<span className="font-mono">
↓{r.dlMbps} / ↑{r.ulMbps}
↓{r.dlMbps} / ↑{r.ulMbps}<span className="block text-[10px] text-muted-foreground">↓ {describeObserved(r.observed?.dl,"Мбит/с")}<br />↑ {describeObserved(r.observed?.ul,"Мбит/с")}</span>
</span>
)
},