фикс пинга
This commit is contained in:
parent
4f5ab1a48b
commit
b170df43b8
1 changed files with 23 additions and 21 deletions
|
|
@ -434,13 +434,10 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
||||||
if (row._type === 'group') return null
|
if (row._type === 'group') return null
|
||||||
const d = row as DeviceRow
|
const d = row as DeviceRow
|
||||||
|
|
||||||
// Мониторинг выключен и история отсутствует
|
// Нет никаких данных о пинге
|
||||||
if (!d.monitor_enabled && !d.last_ping_at) {
|
const pingTime = d.last_ping_at ?? d.last_seen
|
||||||
return <Typography.Text type="secondary">выключен</Typography.Text>
|
if (!pingTime) {
|
||||||
}
|
if (!d.monitor_enabled) return <Typography.Text type="secondary">выключен</Typography.Text>
|
||||||
|
|
||||||
// Мониторинг включён, но ни разу не пинговалось
|
|
||||||
if (d.monitor_enabled && !d.last_ping_at) {
|
|
||||||
return <Typography.Text type="secondary">ожидание...</Typography.Text>
|
return <Typography.Text type="secondary">ожидание...</Typography.Text>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -448,30 +445,35 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
|
||||||
? <Tooltip title="Мониторинг выключен"><span style={{ color: '#faad14', marginLeft: 4 }}>⏸</span></Tooltip>
|
? <Tooltip title="Мониторинг выключен"><span style={{ color: '#faad14', marginLeft: 4 }}>⏸</span></Tooltip>
|
||||||
: null
|
: null
|
||||||
|
|
||||||
// Устройство online — last_ping_at ≈ last_seen
|
// Устройство online
|
||||||
if (d.status === 'online') {
|
if (d.status === 'online') {
|
||||||
return (
|
return (
|
||||||
<Tooltip title={elapsedAgo(d.last_ping_at!)}>
|
<Space size={2}>
|
||||||
|
<Tooltip title={elapsedAgo(pingTime)}>
|
||||||
<span style={{ color: '#52c41a', cursor: 'default' }}>
|
<span style={{ color: '#52c41a', cursor: 'default' }}>
|
||||||
{dayjs(d.last_ping_at).format('DD.MM.YYYY HH:mm')}
|
{dayjs(pingTime).format('DD.MM.YYYY HH:mm')}
|
||||||
</span>
|
</span>
|
||||||
{pauseIcon}
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{pauseIcon}
|
||||||
|
</Space>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Устройство offline или unknown — показываем время попытки, в tooltip — когда был онлайн
|
// Устройство offline или unknown
|
||||||
const lastSeenHint = d.last_seen
|
// pingTime = последняя попытка (last_ping_at) или последний онлайн (last_seen как fallback)
|
||||||
|
const lastSeenHint = d.last_seen && d.last_ping_at && d.last_ping_at !== d.last_seen
|
||||||
? `онлайн был: ${dayjs(d.last_seen).format('DD.MM.YYYY HH:mm')}`
|
? `онлайн был: ${dayjs(d.last_seen).format('DD.MM.YYYY HH:mm')}`
|
||||||
: 'онлайн не был'
|
: null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip title={`${elapsedAgo(d.last_ping_at!)} · ${lastSeenHint}`}>
|
<Space size={2}>
|
||||||
|
<Tooltip title={[elapsedAgo(pingTime), lastSeenHint].filter(Boolean).join(' · ')}>
|
||||||
<span style={{ color: '#ff4d4f', cursor: 'default' }}>
|
<span style={{ color: '#ff4d4f', cursor: 'default' }}>
|
||||||
{dayjs(d.last_ping_at).format('DD.MM.YYYY HH:mm')}
|
{dayjs(pingTime).format('DD.MM.YYYY HH:mm')}
|
||||||
</span>
|
</span>
|
||||||
{pauseIcon}
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{pauseIcon}
|
||||||
|
</Space>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue