refactor(NetworkMap): unify ping handling by implementing edge-based keying for ping timestamps in NetworkMapDashboard and NetworkMapUnifi components
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m59s

This commit is contained in:
2026-02-18 12:02:29 +07:00
parent b5eb47e690
commit 9f85351b6b
2 changed files with 22 additions and 46 deletions
+6 -16
View File
@@ -183,18 +183,16 @@ export default function NetworkMapUnifi({ servers = [], connections = [], pingMa
[getSvgCoords, positions]
);
const edgePingKey = (a, b) => [String(a), String(b)].sort().join(':');
const edgesWithPing = useMemo(() => {
return (connections || []).map((c) => {
const from = String(c.from);
const to = String(c.to);
const p1 = positions[from];
const p2 = positions[to];
const fwd = pingMap[`${from}:${to}`];
const rev = pingMap[`${to}:${from}`];
const parts = [];
if (typeof fwd === 'number') parts.push(`${fwd} ms`);
if (typeof rev === 'number') parts.push(`${rev} ms`);
const pingLabel = parts.length ? parts.join(' ') : null;
const ms = pingMap[edgePingKey(from, to)];
const pingLabel = typeof ms === 'number' ? `${ms} ms` : null;
const sk = speedKey(c.fromKey, c.toKey);
const speed = speedMap[sk];
const speedLabel =
@@ -435,8 +433,7 @@ export default function NetworkMapUnifi({ servers = [], connections = [], pingMa
{selectedEdge && (() => {
const fromServer = servers.find((s) => String(s.ip) === selectedEdge.from);
const toServer = servers.find((s) => String(s.ip) === selectedEdge.to);
const fwd = pingMap[`${selectedEdge.from}:${selectedEdge.to}`];
const rev = pingMap[`${selectedEdge.to}:${selectedEdge.from}`];
const pingMs = pingMap[edgePingKey(selectedEdge.from, selectedEdge.to)];
const sk = speedKey(selectedEdge.raw?.fromKey, selectedEdge.raw?.toKey);
const speed = speedMap[sk] ?? selectedEdge.speed;
return (
@@ -520,14 +517,7 @@ export default function NetworkMapUnifi({ servers = [], connections = [], pingMa
Пинг
</div>
<div>
<div>
<span className="text-muted"> </span>
{typeof fwd === 'number' ? `${fwd} ms` : 'нет данных'}
</div>
<div>
<span className="text-muted"> </span>
{typeof rev === 'number' ? `${rev} ms` : 'нет данных'}
</div>
{typeof pingMs === 'number' ? `${pingMs} ms` : 'нет данных'}
</div>
</div>
{speed && (speed.tcpDownloadBps != null || speed.tcpUploadBps != null) && (