фикс пинга
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
|
||||
const d = row as DeviceRow
|
||||
|
||||
// Мониторинг выключен и история отсутствует
|
||||
if (!d.monitor_enabled && !d.last_ping_at) {
|
||||
return <Typography.Text type="secondary">выключен</Typography.Text>
|
||||
}
|
||||
|
||||
// Мониторинг включён, но ни разу не пинговалось
|
||||
if (d.monitor_enabled && !d.last_ping_at) {
|
||||
// Нет никаких данных о пинге
|
||||
const pingTime = d.last_ping_at ?? d.last_seen
|
||||
if (!pingTime) {
|
||||
if (!d.monitor_enabled) 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>
|
||||
: null
|
||||
|
||||
// Устройство online — last_ping_at ≈ last_seen
|
||||
// Устройство online
|
||||
if (d.status === 'online') {
|
||||
return (
|
||||
<Tooltip title={elapsedAgo(d.last_ping_at!)}>
|
||||
<span style={{ color: '#52c41a', cursor: 'default' }}>
|
||||
{dayjs(d.last_ping_at).format('DD.MM.YYYY HH:mm')}
|
||||
</span>
|
||||
<Space size={2}>
|
||||
<Tooltip title={elapsedAgo(pingTime)}>
|
||||
<span style={{ color: '#52c41a', cursor: 'default' }}>
|
||||
{dayjs(pingTime).format('DD.MM.YYYY HH:mm')}
|
||||
</span>
|
||||
</Tooltip>
|
||||
{pauseIcon}
|
||||
</Tooltip>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
|
||||
// Устройство offline или unknown — показываем время попытки, в tooltip — когда был онлайн
|
||||
const lastSeenHint = d.last_seen
|
||||
// Устройство offline или unknown
|
||||
// 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')}`
|
||||
: 'онлайн не был'
|
||||
: null
|
||||
|
||||
return (
|
||||
<Tooltip title={`${elapsedAgo(d.last_ping_at!)} · ${lastSeenHint}`}>
|
||||
<span style={{ color: '#ff4d4f', cursor: 'default' }}>
|
||||
{dayjs(d.last_ping_at).format('DD.MM.YYYY HH:mm')}
|
||||
</span>
|
||||
<Space size={2}>
|
||||
<Tooltip title={[elapsedAgo(pingTime), lastSeenHint].filter(Boolean).join(' · ')}>
|
||||
<span style={{ color: '#ff4d4f', cursor: 'default' }}>
|
||||
{dayjs(pingTime).format('DD.MM.YYYY HH:mm')}
|
||||
</span>
|
||||
</Tooltip>
|
||||
{pauseIcon}
|
||||
</Tooltip>
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue