фикс пинга 4

This commit is contained in:
dv 2026-04-10 11:59:25 +03:00
parent 974d31a1c4
commit 6bbd4b6dab

View file

@ -421,29 +421,40 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
{ {
title: 'Последний пинг', title: 'Последний пинг',
key: 'monitoring', key: 'monitoring',
onCell: (row: TableRow) => { onCell: (row: TableRow) => row._type === 'group' ? { colSpan: 0 } : {},
if (row._type === 'group') return { colSpan: 0 }
const d = row as DeviceRow
const bg =
d.status === 'online' ? '#f6ffed' :
d.status === 'offline' ? '#fff2f0' : undefined
return bg ? { style: { background: bg } } : {}
},
render: (_: unknown, row: TableRow) => { render: (_: unknown, row: TableRow) => {
if (row._type === 'group') return null if (row._type === 'group') return null
const d = row as DeviceRow const d = row as DeviceRow
const dotColor =
d.status === 'online' ? '#52c41a' :
d.status === 'offline' ? '#ff4d4f' : '#d9d9d9'
const dot = (
<span style={{
display: 'inline-block',
width: 7,
height: 7,
borderRadius: '50%',
backgroundColor: dotColor,
flexShrink: 0,
}} />
)
const pingTime = d.last_ping_at ?? d.last_seen const pingTime = d.last_ping_at ?? d.last_seen
if (!pingTime) { if (!pingTime) {
return ( return (
<Typography.Text type="secondary"> <Space size={6}>
{d.monitor_enabled ? 'ожидание...' : 'нет данных'} {dot}
</Typography.Text> <Typography.Text type="secondary">
{d.monitor_enabled ? 'ожидание...' : 'нет данных'}
</Typography.Text>
</Space>
) )
} }
const pauseIcon = !d.monitor_enabled const pauseIcon = !d.monitor_enabled
? <Tooltip title="Мониторинг выключен"><span style={{ color: '#faad14', marginLeft: 4 }}></span></Tooltip> ? <Tooltip title="Мониторинг выключен"><span style={{ color: '#faad14' }}></span></Tooltip>
: null : null
const lastSeenHint = d.last_seen && d.last_ping_at && d.last_ping_at !== d.last_seen const lastSeenHint = d.last_seen && d.last_ping_at && d.last_ping_at !== d.last_seen
@ -453,9 +464,10 @@ export function ObjectDetailPage({ defaultMode = 'inventory' }: { defaultMode?:
const tooltipText = [elapsedAgo(pingTime), lastSeenHint].filter(Boolean).join(' · ') const tooltipText = [elapsedAgo(pingTime), lastSeenHint].filter(Boolean).join(' · ')
return ( return (
<Space size={2}> <Space size={6}>
{dot}
<Tooltip title={tooltipText}> <Tooltip title={tooltipText}>
<span style={{ cursor: 'default' }}> <span style={{ color: dotColor, cursor: 'default' }}>
{dayjs(pingTime).format('DD.MM.YYYY HH:mm')} {dayjs(pingTime).format('DD.MM.YYYY HH:mm')}
</span> </span>
</Tooltip> </Tooltip>