feat
This commit is contained in:
@@ -1,130 +1,145 @@
|
||||
import { request } from "@/api/request";
|
||||
import { request } from '@/api/request'
|
||||
|
||||
/** 获取 告警策略列表 */
|
||||
export const fetchPolicyList = (data: {
|
||||
page?: number,
|
||||
page_size?: number,
|
||||
keyword?: string,
|
||||
enabled?: boolean,
|
||||
priority?: number,
|
||||
created_at_start?: string,
|
||||
created_at_end?: string,
|
||||
order_by?: string,
|
||||
export const fetchPolicyList = (data: {
|
||||
page?: number
|
||||
page_size?: number
|
||||
keyword?: string
|
||||
enabled?: boolean
|
||||
priority?: number
|
||||
created_at_start?: string
|
||||
created_at_end?: string
|
||||
order_by?: string
|
||||
order?: string
|
||||
}) => request.get("/Alert/v1/policy/list", { params: data });
|
||||
}) => request.get('/Alert/v1/policy/list', { params: data })
|
||||
|
||||
/** 获取 告警策略详情 */
|
||||
export const fetchPolicyDetail = (id: number) => request.get(`/Alert/v1/policy/get/${id}`);
|
||||
export const fetchPolicyDetail = (id: number) => request.get(`/Alert/v1/policy/get/${id}`)
|
||||
|
||||
/** 创建 告警策略 */
|
||||
export const createPolicy = (data: {
|
||||
name: string;
|
||||
description?: string;
|
||||
enabled?: boolean;
|
||||
priority?: number;
|
||||
labels?: string;
|
||||
template_id?: number;
|
||||
auto_create_ticket?: boolean;
|
||||
feedback_template_id?: number;
|
||||
dispatch_rule?: string;
|
||||
}) => request.post("/Alert/v1/policy/create", data);
|
||||
name: string
|
||||
description?: string
|
||||
enabled?: boolean
|
||||
priority?: number
|
||||
labels?: string
|
||||
template_id?: number
|
||||
auto_create_ticket?: boolean
|
||||
feedback_template_id?: number
|
||||
dispatch_rule?: string
|
||||
}) => request.post('/Alert/v1/policy/create', data)
|
||||
|
||||
/** 更新 告警策略 */
|
||||
export const updatePolicy = (data: {
|
||||
id: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
enabled?: boolean;
|
||||
priority?: number;
|
||||
labels?: string;
|
||||
template_id?: number;
|
||||
auto_create_ticket?: boolean;
|
||||
feedback_template_id?: number;
|
||||
dispatch_rule?: string;
|
||||
}) => request.post("/Alert/v1/policy/update", data);
|
||||
id: number
|
||||
name?: string
|
||||
description?: string
|
||||
enabled?: boolean
|
||||
priority?: number
|
||||
labels?: string
|
||||
template_id?: number
|
||||
auto_create_ticket?: boolean
|
||||
feedback_template_id?: number
|
||||
dispatch_rule?: string
|
||||
}) => request.post('/Alert/v1/policy/update', data)
|
||||
|
||||
/** 删除 告警策略 */
|
||||
export const deletePolicy = (id: number) => request.delete(`/Alert/v1/policy/delete/${id}`);
|
||||
export const deletePolicy = (id: number) => request.delete(`/Alert/v1/policy/delete/${id}`)
|
||||
|
||||
/** 获取 告警规则列表 */
|
||||
export const fetchRuleList = (data: {
|
||||
policy_id?: number;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
keyword?: string;
|
||||
sort?: string;
|
||||
policy_id?: number
|
||||
page?: number
|
||||
page_size?: number
|
||||
keyword?: string
|
||||
sort?: string
|
||||
order?: string
|
||||
}) => request.get("/Alert/v1/rule/list", { params: data });
|
||||
}) => request.get('/Alert/v1/rule/list', { params: data })
|
||||
|
||||
/** 获取 告警规则详情 */
|
||||
export const fetchRuleDetail = (id: number) => request.get(`/Alert/v1/rule/get/${id}`);
|
||||
export const fetchRuleDetail = (id: number) => request.get(`/Alert/v1/rule/get/${id}`)
|
||||
|
||||
/** 创建 告警规则 */
|
||||
export const createRule = (data: {
|
||||
policy_id: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
rule_type: string;
|
||||
severity_id: number;
|
||||
enabled?: boolean;
|
||||
metric_name?: string;
|
||||
query_expr?: string;
|
||||
threshold?: number;
|
||||
compare_op?: string;
|
||||
duration?: number;
|
||||
baseline_config?: string;
|
||||
labels?: string;
|
||||
annotations?: string;
|
||||
}) => request.post("/Alert/v1/rule/create", data);
|
||||
policy_id: number
|
||||
name: string
|
||||
description?: string
|
||||
rule_type: string
|
||||
severity_id: number
|
||||
enabled?: boolean
|
||||
metric_name?: string
|
||||
query_expr?: string
|
||||
threshold?: number
|
||||
compare_op?: string
|
||||
duration?: number
|
||||
baseline_config?: string
|
||||
labels?: string
|
||||
annotations?: string
|
||||
}) => request.post('/Alert/v1/rule/create', data)
|
||||
|
||||
/** 更新 告警规则 */
|
||||
export const updateRule = (data: {
|
||||
id: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
rule_type?: string;
|
||||
severity_id?: number;
|
||||
enabled?: boolean;
|
||||
metric_name?: string;
|
||||
query_expr?: string;
|
||||
threshold?: number;
|
||||
compare_op?: string;
|
||||
duration?: number;
|
||||
baseline_config?: string;
|
||||
labels?: string;
|
||||
annotations?: string;
|
||||
}) => request.post("/Alert/v1/rule/update", data);
|
||||
id: number
|
||||
name?: string
|
||||
description?: string
|
||||
rule_type?: string
|
||||
severity_id?: number
|
||||
enabled?: boolean
|
||||
metric_name?: string
|
||||
query_expr?: string
|
||||
threshold?: number
|
||||
compare_op?: string
|
||||
duration?: number
|
||||
baseline_config?: string
|
||||
labels?: string
|
||||
annotations?: string
|
||||
}) => request.post('/Alert/v1/rule/update', data)
|
||||
|
||||
/** 删除 告警规则 */
|
||||
export const deleteRule = (id: number) => request.delete(`/Alert/v1/rule/delete/${id}`);
|
||||
export const deleteRule = (id: number) => request.delete(`/Alert/v1/rule/delete/${id}`)
|
||||
|
||||
/** 获取 告警模板列表 */
|
||||
export const fetchTemplateList = (data: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
keyword?: string;
|
||||
}) => request.get("/Alert/v1/template/list", { params: data });
|
||||
export const fetchTemplateList = (data: { page?: number; page_size?: number; keyword?: string }) =>
|
||||
request.get('/Alert/v1/template/list', { params: data })
|
||||
|
||||
/** 获取 告警级别列表 */
|
||||
export const fetchSeverityList = (data: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
enabled?: string;
|
||||
}) => request.get("/Alert/v1/severity/list", { params: data });
|
||||
export const fetchSeverityList = (data: { page?: number; page_size?: number; enabled?: string }) =>
|
||||
request.get('/Alert/v1/severity/list', { params: data })
|
||||
|
||||
/** 获取告警级别下拉选项(不分页),支持 keyword 模糊搜索与 enabled=true 过滤 */
|
||||
export const fetchSeverityOptions = (data?: {
|
||||
keyword?: string;
|
||||
enabled?: 'true' | 'false';
|
||||
}) =>
|
||||
request.get("/Alert/v1/severity/options", {
|
||||
export const fetchSeverityOptions = (data?: { keyword?: string; enabled?: 'true' | 'false' }) =>
|
||||
request.get('/Alert/v1/severity/options', {
|
||||
params: {
|
||||
keyword: data?.keyword || undefined,
|
||||
enabled: data?.enabled ?? 'true',
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
/** 获取工单模板下拉选项 */
|
||||
export const fetchFeedbackTemplateOptions = (data?: {
|
||||
status?: 'active' | 'inactive'
|
||||
}) => request.get('/Feedback/v1/templates/options', { params: data || {} });
|
||||
export const fetchFeedbackTemplateOptions = (data?: { status?: 'active' | 'inactive' }) =>
|
||||
request.get('/Feedback/v1/templates/options', { params: data || {} })
|
||||
|
||||
/** 告警策略选项项 */
|
||||
export interface PolicyOptionItem {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
name: string
|
||||
description: string
|
||||
enabled: boolean
|
||||
priority: number
|
||||
labels: string
|
||||
template_id: number
|
||||
auto_create_ticket: boolean
|
||||
feedback_template_id: number
|
||||
dispatch_rule: string
|
||||
}
|
||||
|
||||
/** 告警策略选项查询参数 */
|
||||
export interface PolicyOptionsParams {
|
||||
keyword?: string
|
||||
enabled?: boolean
|
||||
}
|
||||
|
||||
/** 获取告警策略下拉选项(不分页),支持 keyword 模糊搜索与 enabled 过滤 */
|
||||
export const fetchPolicyOptions = (params?: PolicyOptionsParams) => request.get<PolicyOptionItem[]>('/Alert/v1/policy/options', { params })
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { request } from "@/api/request";
|
||||
import { request } from '@/api/request'
|
||||
|
||||
/** 资产状态枚举 */
|
||||
export enum AssetStatus {
|
||||
IN_USE = 'in_use', // 在用
|
||||
IDLE = 'idle', // 闲置
|
||||
MAINTAIN = 'maintain', // 维修中
|
||||
SCRAP = 'scrap', // 待报废
|
||||
DISPOSED = 'disposed', // 已报废
|
||||
IN_USE = 'in_use', // 在用
|
||||
IDLE = 'idle', // 闲置
|
||||
MAINTAIN = 'maintain', // 维修中
|
||||
SCRAP = 'scrap', // 待报废
|
||||
DISPOSED = 'disposed', // 已报废
|
||||
}
|
||||
|
||||
/** 资产状态选项 */
|
||||
@@ -16,13 +16,13 @@ export const assetStatusOptions = [
|
||||
{ label: '维修中', value: AssetStatus.MAINTAIN },
|
||||
{ label: '待报废', value: AssetStatus.SCRAP },
|
||||
{ label: '已报废', value: AssetStatus.DISPOSED },
|
||||
];
|
||||
]
|
||||
|
||||
/** 获取资产状态文本 */
|
||||
export const getAssetStatusText = (status: string) => {
|
||||
const item = assetStatusOptions.find(opt => opt.value === status);
|
||||
return item?.label || status;
|
||||
};
|
||||
const item = assetStatusOptions.find((opt) => opt.value === status)
|
||||
return item?.label || status
|
||||
}
|
||||
|
||||
/** 获取资产状态颜色 */
|
||||
export const getAssetStatusColor = (status: string) => {
|
||||
@@ -32,113 +32,117 @@ export const getAssetStatusColor = (status: string) => {
|
||||
[AssetStatus.MAINTAIN]: 'orange',
|
||||
[AssetStatus.SCRAP]: 'red',
|
||||
[AssetStatus.DISPOSED]: 'gray',
|
||||
};
|
||||
return colorMap[status] || 'gray';
|
||||
};
|
||||
}
|
||||
return colorMap[status] || 'gray'
|
||||
}
|
||||
|
||||
/** 资产列表查询参数 */
|
||||
export interface AssetListParams {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
keyword?: string;
|
||||
status?: string;
|
||||
category_id?: number;
|
||||
supplier_id?: number;
|
||||
datacenter_id?: number;
|
||||
department?: string;
|
||||
sort?: string;
|
||||
order?: string;
|
||||
page?: number
|
||||
page_size?: number
|
||||
keyword?: string
|
||||
status?: string
|
||||
category_id?: number
|
||||
supplier_id?: number
|
||||
datacenter_id?: number
|
||||
floor_id?: number
|
||||
room_id?: number
|
||||
rack_id?: number
|
||||
department?: string
|
||||
sort?: string
|
||||
order?: string
|
||||
}
|
||||
|
||||
/** 资产表单数据 */
|
||||
export interface AssetForm {
|
||||
id?: number;
|
||||
asset_name: string;
|
||||
asset_code: string;
|
||||
category_id?: number;
|
||||
model?: string;
|
||||
manufacturer?: string;
|
||||
serial_number?: string;
|
||||
purchase_date?: string;
|
||||
original_value?: number;
|
||||
supplier_id?: number;
|
||||
warranty_period?: string;
|
||||
warranty_expiry?: string;
|
||||
department?: string;
|
||||
user?: string;
|
||||
status?: string;
|
||||
location?: string;
|
||||
datacenter_id?: number;
|
||||
floor_id?: number;
|
||||
rack_id?: number;
|
||||
unit_start?: number;
|
||||
unit_end?: number;
|
||||
qr_code?: string;
|
||||
rfid_tag?: string;
|
||||
asset_tag?: string;
|
||||
specifications?: string;
|
||||
description?: string;
|
||||
remarks?: string;
|
||||
id?: number
|
||||
asset_name: string
|
||||
asset_code: string
|
||||
category_id?: number
|
||||
model?: string
|
||||
manufacturer?: string
|
||||
serial_number?: string
|
||||
purchase_date?: string
|
||||
original_value?: number
|
||||
supplier_id?: number
|
||||
warranty_period?: string
|
||||
warranty_expiry?: string
|
||||
department?: string
|
||||
user?: string
|
||||
status?: string
|
||||
location?: string
|
||||
datacenter_id?: number
|
||||
floor_id?: number
|
||||
room_id?: number
|
||||
rack_id?: number
|
||||
unit_start?: number
|
||||
unit_end?: number
|
||||
qr_code?: string
|
||||
rfid_tag?: string
|
||||
asset_tag?: string
|
||||
specifications?: string
|
||||
description?: string
|
||||
remarks?: string
|
||||
}
|
||||
|
||||
/** 获取资产列表(分页) */
|
||||
export const fetchAssetList = (data?: AssetListParams) => {
|
||||
return request.post("/Assets/v1/asset/list", data || {});
|
||||
};
|
||||
return request.post('/Assets/v1/asset/list', data || {})
|
||||
}
|
||||
|
||||
/** 获取资产列表(不分页,下拉) */
|
||||
export const fetchAssetAll = (params?: { keyword?: string }) => {
|
||||
return request.get("/Assets/v1/asset/all", { params });
|
||||
};
|
||||
return request.get('/Assets/v1/asset/all', { params })
|
||||
}
|
||||
|
||||
/** 获取资产详情 */
|
||||
export const fetchAssetDetail = (id: number) => {
|
||||
return request.get(`/Assets/v1/asset/detail/${id}`);
|
||||
};
|
||||
return request.get(`/Assets/v1/asset/detail/${id}`)
|
||||
}
|
||||
|
||||
/** 创建资产 */
|
||||
export const createAsset = (data: AssetForm) => {
|
||||
return request.post("/Assets/v1/asset/create", data);
|
||||
};
|
||||
return request.post('/Assets/v1/asset/create', data)
|
||||
}
|
||||
|
||||
/** 更新资产 */
|
||||
export const updateAsset = (data: AssetForm) => {
|
||||
return request.put("/Assets/v1/asset/update", data);
|
||||
};
|
||||
return request.put('/Assets/v1/asset/update', data)
|
||||
}
|
||||
|
||||
/** 删除资产 */
|
||||
export const deleteAsset = (id: number) => {
|
||||
return request.delete(`/Assets/v1/asset/delete/${id}`);
|
||||
};
|
||||
return request.delete(`/Assets/v1/asset/delete/${id}`)
|
||||
}
|
||||
|
||||
/** 导出资产 */
|
||||
export const exportAssets = (keyword?: string) => {
|
||||
const params: any = {};
|
||||
if (keyword) params.keyword = keyword;
|
||||
return request.get("/Assets/v1/asset/export", { params });
|
||||
};
|
||||
const params: any = {}
|
||||
if (keyword) params.keyword = keyword
|
||||
return request.get('/Assets/v1/asset/export', { params })
|
||||
}
|
||||
|
||||
/** 获取资产分类列表(下拉) */
|
||||
export const fetchCategoryOptions = () => {
|
||||
return request.get("/Assets/v1/category/all");
|
||||
};
|
||||
return request.get('/Assets/v1/category/all')
|
||||
}
|
||||
|
||||
/** 获取供应商列表(下拉) */
|
||||
export const fetchSupplierOptions = () => {
|
||||
return request.get("/Assets/v1/supplier/all");
|
||||
};
|
||||
return request.get('/Assets/v1/supplier/all')
|
||||
}
|
||||
|
||||
/** 获取数据中心列表(下拉) */
|
||||
export const fetchDatacenterOptions = () => {
|
||||
return request.get("/Assets/v1/datacenter/list");
|
||||
};
|
||||
return request.get('/Assets/v1/datacenter/list')
|
||||
}
|
||||
|
||||
/** 根据数据中心获取楼层列表 */
|
||||
export const fetchFloorOptions = (datacenterId: number) => {
|
||||
return request.get(`/Assets/v1/datacenter/${datacenterId}`);
|
||||
};
|
||||
return request.get(`/Assets/v1/datacenter/${datacenterId}`)
|
||||
}
|
||||
|
||||
/** 获取机柜列表(下拉) */
|
||||
export const fetchRackOptions = (params?: { datacenter_id?: number; floor_id?: number }) => {
|
||||
return request.post("/Assets/v1/rack/list", params || {});
|
||||
};
|
||||
return request.post('/Assets/v1/rack/list', params || {})
|
||||
}
|
||||
|
||||
@@ -1,73 +1,69 @@
|
||||
import { request } from "@/api/request";
|
||||
import { request } from '@/api/request'
|
||||
|
||||
/** 获取机柜列表(分页) */
|
||||
export const fetchRackList = (data?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
keyword?: string;
|
||||
datacenter_id?: number;
|
||||
floor_id?: number;
|
||||
rack_type?: string;
|
||||
status?: string;
|
||||
sort?: string;
|
||||
order?: string;
|
||||
page?: number
|
||||
page_size?: number
|
||||
keyword?: string
|
||||
datacenter_id?: number
|
||||
floor_id?: number
|
||||
room_id?: number
|
||||
rack_type?: string
|
||||
status?: string
|
||||
sort?: string
|
||||
order?: string
|
||||
}) => {
|
||||
return request.post("/Assets/v1/rack/list", data || {});
|
||||
};
|
||||
return request.post('/Assets/v1/rack/list', data || {})
|
||||
}
|
||||
|
||||
/** 根据数据中心获取机柜列表(下拉,不分页) */
|
||||
export const fetchRackListByDatacenter = (
|
||||
datacenterId: number,
|
||||
params?: { name?: string }
|
||||
) => {
|
||||
return request.get(`/Assets/v1/rack/datacenter/${datacenterId}`, { params });
|
||||
};
|
||||
export const fetchRackListByDatacenter = (datacenterId: number, params?: { name?: string }) => {
|
||||
return request.get(`/Assets/v1/rack/datacenter/${datacenterId}`, { params })
|
||||
}
|
||||
|
||||
/** 根据楼层获取机柜列表(下拉,不分页) */
|
||||
export const fetchRackListByFloor = (
|
||||
floorId: number,
|
||||
params?: { name?: string }
|
||||
) => {
|
||||
return request.get(`/Assets/v1/rack/floor/${floorId}`, { params });
|
||||
};
|
||||
/** 根据楼层获取机柜列表(下拉,不分页)- 已废弃,请使用 fetchRackListByRoom */
|
||||
export const fetchRackListByFloor = (floorId: number, params?: { name?: string }) => {
|
||||
return request.get(`/Assets/v1/rack/floor/${floorId}`, { params })
|
||||
}
|
||||
|
||||
/** 根据机房获取机柜列表(下拉,不分页) */
|
||||
export const fetchRackListByRoom = (roomId: number, params?: { name?: string }) => {
|
||||
return request.get(`/Assets/v1/rack/room/${roomId}`, { params })
|
||||
}
|
||||
|
||||
/** 获取机柜详情 */
|
||||
export const fetchRackDetail = (id: number) => {
|
||||
return request.get(`/Assets/v1/rack/detail/${id}`);
|
||||
};
|
||||
return request.get(`/Assets/v1/rack/detail/${id}`)
|
||||
}
|
||||
|
||||
/** 创建机柜 */
|
||||
export const createRack = (data: any) => {
|
||||
return request.post("/Assets/v1/rack/create", data);
|
||||
};
|
||||
return request.post('/Assets/v1/rack/create', data)
|
||||
}
|
||||
|
||||
/** 更新机柜 */
|
||||
export const updateRack = (data: any) => {
|
||||
return request.put("/Assets/v1/rack/update", data);
|
||||
};
|
||||
return request.put('/Assets/v1/rack/update', data)
|
||||
}
|
||||
|
||||
/** 删除机柜 */
|
||||
export const deleteRack = (id: number) => {
|
||||
return request.delete(`/Assets/v1/rack/delete/${id}`);
|
||||
};
|
||||
return request.delete(`/Assets/v1/rack/delete/${id}`)
|
||||
}
|
||||
|
||||
/** 获取供应商列表(用于下拉选择) */
|
||||
export const fetchSupplierList = () => {
|
||||
return request.get("/Assets/v1/supplier/all");
|
||||
};
|
||||
return request.get('/Assets/v1/supplier/all')
|
||||
}
|
||||
|
||||
/** 获取数据中心列表(用于下拉选择) */
|
||||
export const fetchDatacenterList = (params?: { keyword?: string; name?: string }) => {
|
||||
const normalizedParams = params?.keyword
|
||||
? { ...params, name: params.name ?? params.keyword }
|
||||
: params
|
||||
return request.get("/Assets/v1/datacenter/all", { params: normalizedParams });
|
||||
};
|
||||
const normalizedParams = params?.keyword ? { ...params, name: params.name ?? params.keyword } : params
|
||||
return request.get('/Assets/v1/datacenter/all', { params: normalizedParams })
|
||||
}
|
||||
|
||||
/** 获取楼层列表(用于下拉选择) */
|
||||
export const fetchFloorListForSelect = (params?: { datacenter_id?: number; keyword?: string; name?: string }) => {
|
||||
const normalizedParams = params?.keyword
|
||||
? { ...params, name: params.name ?? params.keyword }
|
||||
: params
|
||||
return request.get("/Assets/v1/floor/all", { params: normalizedParams });
|
||||
};
|
||||
const normalizedParams = params?.keyword ? { ...params, name: params.name ?? params.keyword } : params
|
||||
return request.get('/Assets/v1/floor/all', { params: normalizedParams })
|
||||
}
|
||||
|
||||
155
src/api/ops/room-device.ts
Normal file
155
src/api/ops/room-device.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
import { request } from '@/api/request'
|
||||
|
||||
/** 机房设备服务项 */
|
||||
export interface RoomDeviceItem {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: string | null
|
||||
service_identity: string
|
||||
name: string
|
||||
description: string
|
||||
room_id: string
|
||||
device_category: string
|
||||
agent_config: string
|
||||
enabled: boolean
|
||||
collect_on: boolean
|
||||
collect_interval: number
|
||||
collect_last_result: string
|
||||
policy_ids?: number[]
|
||||
}
|
||||
|
||||
/** 机房设备列表响应 */
|
||||
export interface RoomDeviceListResponse {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
data: RoomDeviceItem[]
|
||||
}
|
||||
|
||||
/** 机房设备列表查询参数 */
|
||||
export interface RoomDeviceListParams {
|
||||
page?: number
|
||||
size?: number
|
||||
keyword?: string
|
||||
enabled?: boolean
|
||||
room_id?: string
|
||||
device_category?: string
|
||||
}
|
||||
|
||||
/** 机房设备创建数据 */
|
||||
export interface RoomDeviceCreateData {
|
||||
service_identity?: string
|
||||
name: string
|
||||
description?: string
|
||||
room_id: string
|
||||
device_category: string
|
||||
agent_config?: string
|
||||
enabled?: boolean
|
||||
collect_on?: boolean
|
||||
collect_interval?: number
|
||||
policy_ids?: number[]
|
||||
}
|
||||
|
||||
/** 机房设备更新数据 */
|
||||
export interface RoomDeviceUpdateData {
|
||||
name?: string
|
||||
description?: string
|
||||
room_id?: string
|
||||
device_category?: string
|
||||
agent_config?: string
|
||||
enabled?: boolean
|
||||
collect_on?: boolean
|
||||
collect_interval?: number
|
||||
policy_ids?: number[]
|
||||
}
|
||||
|
||||
/** 机房设备采集配置数据 */
|
||||
export interface RoomDeviceCollectData {
|
||||
collect_on?: boolean
|
||||
collect_interval?: number
|
||||
agent_config?: string
|
||||
}
|
||||
|
||||
/** 指标数据项 */
|
||||
export interface MetricItem {
|
||||
timestamp: string
|
||||
service_identity: string
|
||||
room_id: string
|
||||
device_category: string
|
||||
type?: string
|
||||
metric_name: string
|
||||
metric_value: number
|
||||
metric_unit?: string
|
||||
}
|
||||
|
||||
/** 指标上报数据 */
|
||||
export interface MetricsUploadData {
|
||||
metrics: MetricItem[]
|
||||
}
|
||||
|
||||
/** 获取机房设备列表(分页) */
|
||||
export const fetchRoomDeviceList = (params?: RoomDeviceListParams) => {
|
||||
return request.get<RoomDeviceListResponse>('/DC-Control/v1/room-devices', { params })
|
||||
}
|
||||
|
||||
/** 获取机房设备详情 */
|
||||
export const fetchRoomDeviceDetail = (id: number) => {
|
||||
return request.get<RoomDeviceItem>(`/DC-Control/v1/room-devices/${id}`)
|
||||
}
|
||||
|
||||
/** 创建机房设备 */
|
||||
export const createRoomDevice = (data: RoomDeviceCreateData) => {
|
||||
return request.post<{ message: string; id: number }>('/DC-Control/v1/room-devices', data)
|
||||
}
|
||||
|
||||
/** 更新机房设备 */
|
||||
export const updateRoomDevice = (id: number, data: RoomDeviceUpdateData) => {
|
||||
return request.put<{ message: string }>(`/DC-Control/v1/room-devices/${id}`, data)
|
||||
}
|
||||
|
||||
/** 删除机房设备 */
|
||||
export const deleteRoomDevice = (id: number) => {
|
||||
return request.delete<{ message: string }>(`/DC-Control/v1/room-devices/${id}`)
|
||||
}
|
||||
|
||||
/** 更新采集配置 */
|
||||
export const patchRoomDeviceCollect = (id: number, data: RoomDeviceCollectData) => {
|
||||
return request.patch<{ message: string }>(`/DC-Control/v1/room-devices/${id}/collect`, data)
|
||||
}
|
||||
|
||||
/** 查询最新指标 */
|
||||
export const fetchLatestMetrics = (serviceIdentity: string) => {
|
||||
return request.get<MetricItem[]>('/DC-Control/v1/room-devices/metrics/latest', {
|
||||
params: { service_identity: serviceIdentity },
|
||||
})
|
||||
}
|
||||
|
||||
/** 上报指标(匿名接口) */
|
||||
export const uploadMetrics = (data: MetricsUploadData) => {
|
||||
return request.post<{ message: string }>('/DC-Control/v1/room-devices/metrics/upload', data)
|
||||
}
|
||||
|
||||
/** 设备分类选项 */
|
||||
export const DEVICE_CATEGORY_OPTIONS = [
|
||||
{ label: '电力', value: 'power' },
|
||||
{ label: 'UPS', value: 'ups' },
|
||||
{ label: '空调', value: 'air_conditioner' },
|
||||
{ label: '温湿度', value: 'temp_humidity' },
|
||||
{ label: '消防', value: 'fire_control' },
|
||||
{ label: '门禁', value: 'access_control' },
|
||||
{ label: '漏水', value: 'water_leak' },
|
||||
{ label: '有害气体', value: 'hazardous_gas' },
|
||||
]
|
||||
|
||||
/** 设备分类映射 */
|
||||
export const DEVICE_CATEGORY_MAP: Record<string, string> = {
|
||||
power: '电力',
|
||||
ups: 'UPS',
|
||||
air_conditioner: '空调',
|
||||
temp_humidity: '温湿度',
|
||||
fire_control: '消防',
|
||||
access_control: '门禁',
|
||||
water_leak: '漏水',
|
||||
hazardous_gas: '有害气体',
|
||||
}
|
||||
87
src/api/ops/room.ts
Normal file
87
src/api/ops/room.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { request } from '@/api/request'
|
||||
|
||||
/** 机房项 */
|
||||
export interface RoomItem {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: string | null
|
||||
name: string
|
||||
code: string
|
||||
description?: string
|
||||
floor_id: number
|
||||
datacenter_id: number
|
||||
status?: string
|
||||
floor?: { id: number; name: string }
|
||||
datacenter?: { id: number; name: string }
|
||||
}
|
||||
|
||||
/** 机房列表响应 */
|
||||
export interface RoomListResponse {
|
||||
code: number
|
||||
details: {
|
||||
data: RoomItem[]
|
||||
total: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 机房列表查询参数 */
|
||||
export interface RoomListParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
keyword?: string
|
||||
datacenter_id?: number
|
||||
floor_id?: number
|
||||
status?: string
|
||||
}
|
||||
|
||||
/** 机房创建数据 */
|
||||
export interface RoomCreateData {
|
||||
name: string
|
||||
code: string
|
||||
description?: string
|
||||
floor_id: number
|
||||
datacenter_id: number
|
||||
status?: string
|
||||
}
|
||||
|
||||
/** 机房更新数据 */
|
||||
export interface RoomUpdateData {
|
||||
id: number
|
||||
name?: string
|
||||
code?: string
|
||||
description?: string
|
||||
floor_id?: number
|
||||
datacenter_id?: number
|
||||
status?: string
|
||||
}
|
||||
|
||||
/** 获取机房列表(分页) */
|
||||
export const fetchRoomList = (data?: RoomListParams) => {
|
||||
return request.post<RoomListResponse>('/Assets/v1/room/list', data || {})
|
||||
}
|
||||
|
||||
/** 获取机房详情 */
|
||||
export const fetchRoomDetail = (id: number) => {
|
||||
return request.get<RoomItem>(`/Assets/v1/room/detail/${id}`)
|
||||
}
|
||||
|
||||
/** 根据楼层获取机房列表(下拉,不分页) */
|
||||
export const fetchRoomListByFloor = (floorId: number, params?: { name?: string }) => {
|
||||
return request.get<RoomItem[]>(`/Assets/v1/room/floor/${floorId}`, { params })
|
||||
}
|
||||
|
||||
/** 创建机房 */
|
||||
export const createRoom = (data: RoomCreateData) => {
|
||||
return request.post('/Assets/v1/room/create', data)
|
||||
}
|
||||
|
||||
/** 更新机房 */
|
||||
export const updateRoom = (data: RoomUpdateData) => {
|
||||
return request.put('/Assets/v1/room/update', data)
|
||||
}
|
||||
|
||||
/** 删除机房 */
|
||||
export const deleteRoom = (id: number) => {
|
||||
return request.delete(`/Assets/v1/room/delete/${id}`)
|
||||
}
|
||||
Reference in New Issue
Block a user