feat(ntp): chrony-Service-Badge im PageHeader
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
|||||||
Alert, Button, Card, Col, Form, Input, InputNumber, Modal, Row, Select, Space, Statistic, Switch, Tabs, Tag, Tooltip, Typography, message,
|
Alert, Button, Card, Col, Form, Input, InputNumber, Modal, Row, Select, Space, Statistic, Switch, Tabs, Tag, Tooltip, Typography, message,
|
||||||
} from 'antd'
|
} from 'antd'
|
||||||
import type { ColumnsType } from 'antd/es/table'
|
import type { ColumnsType } from 'antd/es/table'
|
||||||
import { ClockCircleOutlined, DatabaseOutlined, PlusOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons'
|
import { CheckCircleOutlined, ClockCircleOutlined, CloseCircleOutlined, DatabaseOutlined, PlusOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons'
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
@@ -86,6 +86,15 @@ export default function NTPPage() {
|
|||||||
queryFn: fetchNTPStatus,
|
queryFn: fetchNTPStatus,
|
||||||
refetchInterval: 30_000,
|
refetchInterval: 30_000,
|
||||||
})
|
})
|
||||||
|
const { data: services } = useQuery({
|
||||||
|
queryKey: ['system', 'services'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const r = await apiClient.get('/system/services')
|
||||||
|
return isEnvelope(r.data) ? (r.data.data as Array<{ unit: string; active: boolean; state: string }>) : []
|
||||||
|
},
|
||||||
|
refetchInterval: 30_000,
|
||||||
|
})
|
||||||
|
const chrony = services?.find(s => s.unit === 'chrony' || s.unit === 'chronyd')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -93,6 +102,17 @@ export default function NTPPage() {
|
|||||||
icon={<ClockCircleOutlined />}
|
icon={<ClockCircleOutlined />}
|
||||||
title={t('ntp.title')}
|
title={t('ntp.title')}
|
||||||
subtitle={t('ntp.intro')}
|
subtitle={t('ntp.intro')}
|
||||||
|
extra={chrony && (
|
||||||
|
<Tag
|
||||||
|
icon={chrony.active ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
|
||||||
|
color={chrony.active ? 'green' : 'red'}
|
||||||
|
>
|
||||||
|
<Space size={4}>
|
||||||
|
<span>chrony</span>
|
||||||
|
<span style={{ fontWeight: 400, opacity: 0.85 }}>{chrony.state}</span>
|
||||||
|
</Space>
|
||||||
|
</Tag>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
|
|||||||
Reference in New Issue
Block a user