fix(uptime): сбросить снимок при смене пары и сохранить историю

This commit is contained in:
Denozordec committed 2026-10-07 15:52:58 +07:00
1 parent 8627459bfa
commit e4f951175c
12 files changed
+142 -20

No files matched your search

+13 -7
View File
@@ -1,5 +1,6 @@
"use client"
import { publishSpeedProbeSnapshots } from "@/lib/speed-probe-snapshot"
import { parseSpeedRunResponse } from "@/lib/speed-run-response"
import { dashboardProbeOverviewSchema } from "@/lib/dashboard-probes"
@@ -1528,6 +1529,8 @@ function UptimePageContent({ selectedProbeId, allProbesHref }: { selectedProbeId
})
}
const publishSpeedProbes = (rows: SpeedProbeRow[]) => setSpeedProbes(previous => publishSpeedProbeSnapshots(previous, rows))
const persistSpeedProbes = useCallback(async (rows: SpeedProbeRow[]) => {
if (!liveApi) return
if (!speedCatalogReady) throw new Error("Каталог speed-проб не подтверждён. Обновите данные перед сохранением.")
@@ -1871,7 +1874,7 @@ function UptimePageContent({ selectedProbeId, allProbesHref }: { selectedProbeId
}
return next
})
void saveProbeForm(() => persistSpeedProbes(nextRows), () => setSpeedProbes(nextRows))
void saveProbeForm(() => persistSpeedProbes(nextRows), () => publishSpeedProbes(nextRows))
}
const openAddSpeedSheet = () => {
@@ -1916,7 +1919,7 @@ function UptimePageContent({ selectedProbeId, allProbesHref }: { selectedProbeId
? { ...p, ...speedDraft, id: editingSpeedProbeId, durationSec: String(speedDraft.durationSec ?? "10") } : p)
: [{ ...speedDraft, id: speedDraft.id }, ...speedProbes]
void saveProbeForm(() => persistSpeedProbes(next), () => {
setSpeedProbes(next)
publishSpeedProbes(next)
setEditingSpeedProbeId(null)
setSpeedSheetOpen(false)
})
@@ -1943,7 +1946,7 @@ function UptimePageContent({ selectedProbeId, allProbesHref }: { selectedProbeId
const ids = readMockDashboardStarIds(); ids.delete(id); writeMockDashboardStarIds(ids)
}
window.dispatchEvent(new Event(UPTIME_PROBES_CHANGED))
} else setSpeedProbes(nextSpeed)
} else publishSpeedProbes(nextSpeed)
setDeleteTarget(null)
})
}
@@ -2199,13 +2202,16 @@ function UptimePageContent({ selectedProbeId, allProbesHref }: { selectedProbeId
(r.srcInterface ?? "") === probe.srcInterface &&
(r.dstInterface ?? "") === probe.dstInterface,
)
const viewStatus = run?.status ?? (probe.lastStatus === "error" || probe.lastStatus === "done" ? probe.lastStatus : null)
const viewTx = run ? run.txAvgMbps : probe.lastTxAvgMbps == null ? null : Math.round(probe.lastTxAvgMbps)
const viewRx = run ? run.rxAvgMbps : probe.lastRxAvgMbps == null ? null : Math.round(probe.lastRxAvgMbps)
const useRun = run && (run.status === "running" || (
probe.lastStatus != null && probe.lastRunAt != null && run.startedAt >= Date.parse(probe.lastRunAt)
))
const viewStatus = useRun ? run.status : (probe.lastStatus === "error" || probe.lastStatus === "done" ? probe.lastStatus : null)
const viewTx = useRun ? run.txAvgMbps : probe.lastTxAvgMbps == null ? null : Math.round(probe.lastTxAvgMbps)
const viewRx = useRun ? run.rxAvgMbps : probe.lastRxAvgMbps == null ? null : Math.round(probe.lastRxAvgMbps)
const maxVal = Math.max(viewTx ?? 0, viewRx ?? 0, 1)
const canRun = probe.enabled && !!probe.srcServerId && !!probe.dstServerId && probe.srcServerId !== probe.dstServerId
const viewAfterBtPing =
run?.status === "done" && run.afterBtPing
useRun && run.status === "done" && run.afterBtPing
? run.afterBtPing
: probe.lastPingAt
? {