fix(uptime): показывать реальные наблюдения и пропуски RTT на дашборде
This commit is contained in:
1 parent
8f65d1620d
commit
9d3129372b
18 files changed
+169
-203
No files matched your search
@@ -1,7 +1,8 @@
|
||||
"use client"
|
||||
|
||||
import { useMemo } from "react"
|
||||
import type { PingProbe, Server, ServerType } from "@/lib/data"
|
||||
import type { Server, ServerType } from "@/lib/data"
|
||||
import type {DashboardProbe} from "@/lib/dashboard-probes"
|
||||
import { Flag } from "@/components/flag"
|
||||
import { StatusBadge } from "@/components/status-badge"
|
||||
import { StatusDot } from "@/components/status-dot"
|
||||
@@ -10,8 +11,8 @@ import { CompactDataGrid, type CompactDataGridColumn } from "@/components/data-g
|
||||
import { cn } from "@/lib/utils"
|
||||
import { FilterIcon } from "lucide-react"
|
||||
|
||||
function formatLossPct(loss: number): string {
|
||||
if (!Number.isFinite(loss)) return "—"
|
||||
function formatLossPct(loss: number|null): string {
|
||||
if (loss===null || !Number.isFinite(loss)) return "—"
|
||||
return Number.isInteger(loss) ? `${loss}%` : `${loss.toFixed(1)}%`
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ function TypeChip({ type }: { type: ServerType }) {
|
||||
)
|
||||
}
|
||||
|
||||
function ProbeSourceCell({ probe, catalog }: { probe: PingProbe; catalog: Server[] }) {
|
||||
function ProbeSourceCell({ probe, catalog }: { probe: DashboardProbe; catalog: Server[] }) {
|
||||
const srv = catalog.find((s) => s.id === probe.srcServerId)
|
||||
const iface = (probe.srcInterface ?? "").trim() || "auto"
|
||||
|
||||
@@ -40,7 +41,7 @@ function ProbeSourceCell({ probe, catalog }: { probe: PingProbe; catalog: Server
|
||||
return (
|
||||
<div className="flex items-start gap-2 min-w-0 max-w-[280px]">
|
||||
<span className="mt-1 shrink-0 inline-flex">
|
||||
<StatusDot status="offline" />
|
||||
<StatusDot status="unknown" />
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
<p className="text-[13px] font-medium text-muted-foreground truncate">
|
||||
@@ -79,7 +80,7 @@ function ProbeSourceCell({ probe, catalog }: { probe: PingProbe; catalog: Server
|
||||
}
|
||||
|
||||
interface DashboardActiveProbesDataGridProps {
|
||||
probes: PingProbe[]
|
||||
probes: DashboardProbe[]
|
||||
catalog: Server[]
|
||||
isLoading?: boolean
|
||||
emptyTitle?: string
|
||||
@@ -93,7 +94,7 @@ function DashboardActiveProbesDataGrid({
|
||||
emptyTitle = "Нет активных проб",
|
||||
emptyDescription,
|
||||
}: DashboardActiveProbesDataGridProps) {
|
||||
const columns = useMemo<CompactDataGridColumn<PingProbe>[]>(
|
||||
const columns = useMemo<CompactDataGridColumn<DashboardProbe>[]>(
|
||||
() => [
|
||||
{
|
||||
id: "source",
|
||||
@@ -140,7 +141,7 @@ function DashboardActiveProbesDataGrid({
|
||||
cell: (p) => (
|
||||
<span
|
||||
className={cn(
|
||||
p.loss > 5 ? "text-red-500" : p.loss > 0 ? "text-amber-500" : "text-muted-foreground",
|
||||
(p.loss??0) > 5 ? "text-red-500" : (p.loss??0) > 0 ? "text-amber-500" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{formatLossPct(p.loss)}
|
||||
@@ -149,7 +150,7 @@ function DashboardActiveProbesDataGrid({
|
||||
},
|
||||
{
|
||||
id: "series",
|
||||
header: "60с",
|
||||
header: "RTT · 1 ч",
|
||||
enableSorting: false,
|
||||
headerClassName: "w-36",
|
||||
cell: (p) => {
|
||||
@@ -168,7 +169,7 @@ function DashboardActiveProbesDataGrid({
|
||||
enableSorting: false,
|
||||
cell: (p) => (
|
||||
<StatusBadge
|
||||
status={p.status === "up" ? "online" : p.status === "warn" ? "degraded" : "offline"}
|
||||
status={p.status === "unknown" ? "unknown" : p.status === "up" ? "online" : p.status === "warn" ? "degraded" : "offline"}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user