фикс пинга 4
This commit is contained in:
parent
974d31a1c4
commit
6bbd4b6dab
1 changed files with 26 additions and 14 deletions
|
|
@ -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 (
|
||||||
|
<Space size={6}>
|
||||||
|
{dot}
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
{d.monitor_enabled ? 'ожидание...' : 'нет данных'}
|
{d.monitor_enabled ? 'ожидание...' : 'нет данных'}
|
||||||
</Typography.Text>
|
</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>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue