🔨 优化主机逻辑.
This commit is contained in:
48
orion-visor-ui/src/api/asset/host-config.ts
Normal file
48
orion-visor-ui/src/api/asset/host-config.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 主机更新查询请求
|
||||
*/
|
||||
export interface HostUpdateQueryRequest {
|
||||
hostId: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机更新配置请求
|
||||
*/
|
||||
export interface HostUpdateConfigRequest {
|
||||
hostId: number;
|
||||
type: string;
|
||||
config: string;
|
||||
}
|
||||
|
||||
// 主机 SSH 配置
|
||||
export interface HostSshConfig {
|
||||
username?: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
authType?: string;
|
||||
keyId?: number;
|
||||
identityId?: number;
|
||||
connectTimeout?: number;
|
||||
charset?: string;
|
||||
fileNameCharset?: string;
|
||||
fileContentCharset?: string;
|
||||
useNewPassword?: boolean;
|
||||
hasPassword?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新主机配置
|
||||
*/
|
||||
export function updateHostConfig(request: HostUpdateConfigRequest) {
|
||||
return axios.put('/asset/host-config/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询主机配置
|
||||
*/
|
||||
export function getHostSshConfig<T>(request: HostUpdateQueryRequest) {
|
||||
return axios.post<T>('/asset/host-config/get', request);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import axios from 'axios';
|
||||
export interface HostExtraQueryRequest {
|
||||
hostId?: number;
|
||||
item: string;
|
||||
items?: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,6 +17,41 @@ export interface HostExtraUpdateRequest {
|
||||
extra: string;
|
||||
}
|
||||
|
||||
// SSH 额外配置
|
||||
export interface HostSshExtraSettingModel {
|
||||
authType: string;
|
||||
username: string;
|
||||
keyId: number;
|
||||
identityId: number;
|
||||
}
|
||||
|
||||
// 标签额外配置
|
||||
export interface HostLabelExtraSettingModel {
|
||||
alias: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
// 标签规格模型
|
||||
export interface HostSpecExtraModel {
|
||||
osName: string;
|
||||
cpuCore: number;
|
||||
cpuFrequency: number;
|
||||
cpuModel: string;
|
||||
memorySize: number;
|
||||
diskSize: number;
|
||||
inBandwidth: number;
|
||||
outBandwidth: number;
|
||||
publicIpAddress: Array<string>;
|
||||
privateIpAddress: Array<string>;
|
||||
chargePerson: string;
|
||||
createdTime: number;
|
||||
expiredTime: number;
|
||||
items: Array<{
|
||||
label: string;
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机拓展信息
|
||||
*/
|
||||
@@ -25,13 +59,6 @@ export function getHostExtraItem<T>(params: HostExtraQueryRequest) {
|
||||
return axios.get<T>('/asset/host-extra/get', { params });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个主机拓展信息
|
||||
*/
|
||||
export function getHostExtraItemList(request: HostExtraQueryRequest) {
|
||||
return axios.post<Record<string, Record<string, any>>>('/asset/host-extra/list', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改主机拓展信息
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import type { HostSpecExtraModel } from './host-extra';
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
@@ -10,15 +11,15 @@ export type HostType = 'SSH' | string | undefined;
|
||||
* 主机创建请求
|
||||
*/
|
||||
export interface HostCreateRequest {
|
||||
type?: string;
|
||||
types?: Array<string>;
|
||||
osType?: string;
|
||||
archType?: string;
|
||||
name?: string;
|
||||
code?: string;
|
||||
address?: string;
|
||||
port?: number;
|
||||
description?: string;
|
||||
tags?: Array<number>;
|
||||
groupIdList?: Array<number>;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,14 +37,6 @@ export interface HostUpdateStatusRequest {
|
||||
status: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机更新配置请求
|
||||
*/
|
||||
export interface HostUpdateConfigRequest {
|
||||
id: number;
|
||||
config: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机查询请求
|
||||
*/
|
||||
@@ -52,12 +45,15 @@ export interface HostQueryRequest extends Pagination, OrderDirection {
|
||||
id?: number;
|
||||
type?: string;
|
||||
osType?: string;
|
||||
archType?: string;
|
||||
name?: string;
|
||||
code?: string;
|
||||
address?: string;
|
||||
status?: string;
|
||||
tags?: Array<number>;
|
||||
queryTag?: boolean;
|
||||
queryGroup?: boolean;
|
||||
querySpec?: boolean;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
@@ -66,13 +62,14 @@ export interface HostQueryRequest extends Pagination, OrderDirection {
|
||||
*/
|
||||
export interface HostQueryResponse extends TableData, HostQueryResponseExtra {
|
||||
id: number;
|
||||
type: string;
|
||||
osType?: string;
|
||||
types: Array<string>;
|
||||
osType: string;
|
||||
archType: string;
|
||||
name: string;
|
||||
code: string;
|
||||
address: string;
|
||||
port: string;
|
||||
status: string;
|
||||
description: string;
|
||||
createTime: number;
|
||||
updateTime: number;
|
||||
creator: string;
|
||||
@@ -82,7 +79,7 @@ export interface HostQueryResponse extends TableData, HostQueryResponseExtra {
|
||||
color: string;
|
||||
tags: Array<{ id: number, name: string }>;
|
||||
groupIdList: Array<number>;
|
||||
description: string;
|
||||
spec: HostSpecExtraModel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,22 +89,15 @@ export interface HostQueryResponseExtra {
|
||||
editable: boolean;
|
||||
loading: boolean;
|
||||
modCount: number;
|
||||
extra?: Record<string, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机 配置查询响应
|
||||
* 主机测试连接请求
|
||||
*/
|
||||
export interface HostConfigQueryResponse extends HostConfigQueryResponseExtra {
|
||||
export interface HostTestConnectRequest {
|
||||
id: number;
|
||||
type: string;
|
||||
config: Record<string, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机配置拓展
|
||||
*/
|
||||
export interface HostConfigQueryResponseExtra {
|
||||
current: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,13 +121,6 @@ export function updateHostStatus(request: HostUpdateStatusRequest) {
|
||||
return axios.put('/asset/host/update-status', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 id 更新主机配置
|
||||
*/
|
||||
export function updateHostConfig(request: HostUpdateConfigRequest) {
|
||||
return axios.put('/asset/host/update-config', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询主机
|
||||
*/
|
||||
@@ -152,13 +135,6 @@ export function getHostList(type: HostType) {
|
||||
return axios.get<Array<HostQueryResponse>>('/asset/host/list', { params: { type } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 id 查询主机配置
|
||||
*/
|
||||
export function getHostConfig(id: number) {
|
||||
return axios.get<HostConfigQueryResponse>('/asset/host/get-config', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询主机
|
||||
*/
|
||||
@@ -191,3 +167,10 @@ export function batchDeleteHost(idList: Array<number>) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试连接主机
|
||||
*/
|
||||
export function testHostConnect(request: HostTestConnectRequest) {
|
||||
return axios.post('/asset/host/test-connect', request, { timeout: 60000 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user