fix
This commit is contained in:
@@ -10,7 +10,10 @@ export interface RoomDeviceItem {
|
|||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
room_id: string
|
room_id: string
|
||||||
|
device_code?: string
|
||||||
device_category: string
|
device_category: string
|
||||||
|
type?: string
|
||||||
|
status_url?: string
|
||||||
agent_config: string
|
agent_config: string
|
||||||
collect_method: 'api' | 'snmp'
|
collect_method: 'api' | 'snmp'
|
||||||
snmp_target: string
|
snmp_target: string
|
||||||
@@ -23,6 +26,15 @@ export interface RoomDeviceItem {
|
|||||||
collect_on: boolean
|
collect_on: boolean
|
||||||
collect_interval: number
|
collect_interval: number
|
||||||
collect_last_result: string
|
collect_last_result: string
|
||||||
|
status?: string
|
||||||
|
status_code?: number
|
||||||
|
status_message?: string
|
||||||
|
response_time?: number
|
||||||
|
last_check_time?: string
|
||||||
|
last_online_time?: string | null
|
||||||
|
last_offline_time?: string | null
|
||||||
|
continuous_errors?: number
|
||||||
|
uptime?: number
|
||||||
policy_ids?: number[]
|
policy_ids?: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +123,21 @@ export interface MetricItem {
|
|||||||
metric_unit?: string
|
metric_unit?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** GET /room-devices/metrics/latest 的 details 载荷 */
|
||||||
|
export interface RoomDeviceMetricsLatestDetails {
|
||||||
|
service_identity: string
|
||||||
|
latest_timestamp?: string | null
|
||||||
|
count: number
|
||||||
|
metrics: MetricItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 统一 API 封装(与 storage 等页一致) */
|
||||||
|
export interface RoomDeviceMetricsLatestResponse {
|
||||||
|
code: number
|
||||||
|
message?: string
|
||||||
|
details?: RoomDeviceMetricsLatestDetails
|
||||||
|
}
|
||||||
|
|
||||||
/** 指标上报数据 */
|
/** 指标上报数据 */
|
||||||
export interface MetricsUploadData {
|
export interface MetricsUploadData {
|
||||||
metrics: MetricItem[]
|
metrics: MetricItem[]
|
||||||
@@ -148,7 +175,7 @@ export const patchRoomDeviceCollect = (id: number, data: RoomDeviceCollectData)
|
|||||||
|
|
||||||
/** 查询最新指标 */
|
/** 查询最新指标 */
|
||||||
export const fetchLatestMetrics = (serviceIdentity: string) => {
|
export const fetchLatestMetrics = (serviceIdentity: string) => {
|
||||||
return request.get<MetricItem[]>('/DC-Control/v1/room-devices/metrics/latest', {
|
return request.get<RoomDeviceMetricsLatestResponse>('/DC-Control/v1/room-devices/metrics/latest', {
|
||||||
params: { service_identity: serviceIdentity },
|
params: { service_identity: serviceIdentity },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,11 @@ const handleViewMetrics = async () => {
|
|||||||
metricsLoading.value = true
|
metricsLoading.value = true
|
||||||
try {
|
try {
|
||||||
const response = await fetchLatestMetrics(props.record.service_identity)
|
const response = await fetchLatestMetrics(props.record.service_identity)
|
||||||
metricsData.value = (response as any)?.details?.data || []
|
const metrics =
|
||||||
|
response?.code === 0 && response.details?.metrics && Array.isArray(response.details.metrics)
|
||||||
|
? response.details.metrics
|
||||||
|
: []
|
||||||
|
metricsData.value = metrics
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取最新指标失败:', error)
|
console.error('获取最新指标失败:', error)
|
||||||
Message.error('获取最新指标失败')
|
Message.error('获取最新指标失败')
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user