diff --git a/orion-visor-ui/src/api/asset/host-config.ts b/orion-visor-ui/src/api/asset/host-config.ts new file mode 100644 index 00000000..97f97f32 --- /dev/null +++ b/orion-visor-ui/src/api/asset/host-config.ts @@ -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(request: HostUpdateQueryRequest) { + return axios.post('/asset/host-config/get', request); +} diff --git a/orion-visor-ui/src/api/asset/host-extra.ts b/orion-visor-ui/src/api/asset/host-extra.ts index a2a1e67e..23f791d2 100644 --- a/orion-visor-ui/src/api/asset/host-extra.ts +++ b/orion-visor-ui/src/api/asset/host-extra.ts @@ -6,7 +6,6 @@ import axios from 'axios'; export interface HostExtraQueryRequest { hostId?: number; item: string; - items?: Array; } /** @@ -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; + privateIpAddress: Array; + chargePerson: string; + createdTime: number; + expiredTime: number; + items: Array<{ + label: string; + value: string; + }>; +} + /** * 获取主机拓展信息 */ @@ -25,13 +59,6 @@ export function getHostExtraItem(params: HostExtraQueryRequest) { return axios.get('/asset/host-extra/get', { params }); } -/** - * 获取多个主机拓展信息 - */ -export function getHostExtraItemList(request: HostExtraQueryRequest) { - return axios.post>>('/asset/host-extra/list', request); -} - /** * 修改主机拓展信息 */ diff --git a/orion-visor-ui/src/api/asset/host.ts b/orion-visor-ui/src/api/asset/host.ts index 14fdc6cf..6e28d705 100644 --- a/orion-visor-ui/src/api/asset/host.ts +++ b/orion-visor-ui/src/api/asset/host.ts @@ -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; osType?: string; + archType?: string; name?: string; code?: string; address?: string; - port?: number; + description?: string; tags?: Array; groupIdList?: Array; - 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; 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; + 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; - description: string; + spec: HostSpecExtraModel; } /** @@ -92,22 +89,15 @@ export interface HostQueryResponseExtra { editable: boolean; loading: boolean; modCount: number; + extra?: Record; } /** - * 主机 配置查询响应 + * 主机测试连接请求 */ -export interface HostConfigQueryResponse extends HostConfigQueryResponseExtra { +export interface HostTestConnectRequest { id: number; type: string; - config: Record; -} - -/** - * 主机配置拓展 - */ -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>('/asset/host/list', { params: { type } }); } -/** - * 通过 id 查询主机配置 - */ -export function getHostConfig(id: number) { - return axios.get('/asset/host/get-config', { params: { id } }); -} - /** * 分页查询主机 */ @@ -191,3 +167,10 @@ export function batchDeleteHost(idList: Array) { } }); } + +/** + * 测试连接主机 + */ +export function testHostConnect(request: HostTestConnectRequest) { + return axios.post('/asset/host/test-connect', request, { timeout: 60000 }); +} diff --git a/orion-visor-ui/src/assets/images/icon/os_darwin.svg b/orion-visor-ui/src/assets/images/icon/os_darwin.svg new file mode 100644 index 00000000..facf14e6 --- /dev/null +++ b/orion-visor-ui/src/assets/images/icon/os_darwin.svg @@ -0,0 +1,6 @@ + + + diff --git a/orion-visor-ui/src/components/view/exec-editor/const.ts b/orion-visor-ui/src/components/view/exec-editor/const.ts index 900613df..3cfb9d60 100644 --- a/orion-visor-ui/src/components/view/exec-editor/const.ts +++ b/orion-visor-ui/src/components/view/exec-editor/const.ts @@ -51,7 +51,10 @@ export const builtinParams: Array = [ desc: '执行主机用户名' }, { name: 'osType', - desc: '执行主机系统版本' + desc: '执行主机系统类型' + }, { + name: 'archType', + desc: '执行主机系统架构' }, { name: 'charset', desc: 'SSH 编码集' diff --git a/orion-visor-ui/src/store/modules/cache/index.ts b/orion-visor-ui/src/store/modules/cache/index.ts index 2267e6f7..c541e2c6 100644 --- a/orion-visor-ui/src/store/modules/cache/index.ts +++ b/orion-visor-ui/src/store/modules/cache/index.ts @@ -6,14 +6,16 @@ import type { HostType } from '@/api/asset/host'; import { getHostList } from '@/api/asset/host'; import type { PreferenceType } from '@/api/user/preference'; import { getPreference } from '@/api/user/preference'; +import type { HostGroupQueryResponse } from '@/api/asset/host-group'; +import { getHostGroupTree } from '@/api/asset/host-group'; import usePermission from '@/hooks/permission'; import { defineStore } from 'pinia'; +import { flatNodes } from '@/utils/tree'; import { getUserList } from '@/api/user/user'; import { getRoleList } from '@/api/user/role'; import { getDictKeyList } from '@/api/system/dict-key'; import { getHostKeyList } from '@/api/asset/host-key'; import { getHostIdentityList } from '@/api/asset/host-identity'; -import { getHostGroupTree } from '@/api/asset/host-group'; import { getMenuList } from '@/api/system/menu'; import { getCurrentAuthorizedHost, getCurrentAuthorizedHostIdentity, getCurrentAuthorizedHostKey } from '@/api/asset/asset-authorized-data'; import { getCommandSnippetGroupList } from '@/api/asset/command-snippet-group'; @@ -98,6 +100,14 @@ export default defineStore('cache', { return await this.load('hostGroups', getHostGroupTree, ['asset:host-group:update', 'asset:host:query'], force); }, + // 获取主机分组列表 + async loadHostGroupList(force = false) { + const arr: Array = []; + // 展开节点 + flatNodes(await this.loadHostGroupTree(force), arr); + return arr; + }, + // 获取主机列表 async loadHosts(type: HostType = '', force = false) { return await this.load(`host_${type || 'ALL'}`, () => getHostList(type), ['asset:host:query'], force); diff --git a/orion-visor-ui/src/utils/index.ts b/orion-visor-ui/src/utils/index.ts index 17f9e280..81733805 100644 --- a/orion-visor-ui/src/utils/index.ts +++ b/orion-visor-ui/src/utils/index.ts @@ -167,6 +167,15 @@ export const sleep = (ms: number) => { return new Promise(resolve => setTimeout(resolve, ms)); }; +// 添加后缀 +export const addSuffix = (value: any, suffix: string) => { + if (value === undefined || value === '') { + return ''; + } else { + return `${value}${suffix}`; + } +}; + /** * 获取当前页面的缩放值 */ diff --git a/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue b/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue index dba246f0..f91432e9 100644 --- a/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue +++ b/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue @@ -29,20 +29,17 @@ - - - - @@ -131,24 +138,42 @@ {{ record.description || '-' }} - -