fix
This commit is contained in:
@@ -10,7 +10,10 @@ export interface RoomDeviceItem {
|
||||
name: string
|
||||
description: string
|
||||
room_id: string
|
||||
device_code?: string
|
||||
device_category: string
|
||||
type?: string
|
||||
status_url?: string
|
||||
agent_config: string
|
||||
collect_method: 'api' | 'snmp'
|
||||
snmp_target: string
|
||||
@@ -23,6 +26,15 @@ export interface RoomDeviceItem {
|
||||
collect_on: boolean
|
||||
collect_interval: number
|
||||
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[]
|
||||
}
|
||||
|
||||
@@ -111,6 +123,21 @@ export interface MetricItem {
|
||||
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 {
|
||||
metrics: MetricItem[]
|
||||
@@ -148,7 +175,7 @@ export const patchRoomDeviceCollect = (id: number, data: RoomDeviceCollectData)
|
||||
|
||||
/** 查询最新指标 */
|
||||
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 },
|
||||
})
|
||||
}
|
||||
|
||||
@@ -108,7 +108,11 @@ const handleViewMetrics = async () => {
|
||||
metricsLoading.value = true
|
||||
try {
|
||||
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) {
|
||||
console.error('获取最新指标失败:', error)
|
||||
Message.error('获取最新指标失败')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user