From 6a7615e2948ff77cf148bf96d48969db176bc211 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Thu, 7 Mar 2024 15:54:51 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=8E=88=E6=9D=83=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E9=80=89=E6=8B=A9=E6=A8=A1=E6=80=81=E6=A1=86.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asset/authorized-host-modal/index.vue | 82 ------ .../components/host-group.vue | 124 ++++++++ .../components/host-table.vue | 101 +++++++ .../host/authorized-host-modal/index.vue | 273 ++++++++++++++++++ .../host/authorized-host-modal/types/const.ts | 15 + .../types/table.columns.ts | 22 ++ orion-ops-ui/src/types/form.ts | 13 +- orion-ops-ui/src/types/options.ts | 24 ++ .../grant/components/host-identity-grant.vue | 15 +- .../asset/grant/components/host-key-grant.vue | 15 +- .../host-list/components/host-card-list.vue | 4 +- .../host-list/components/host-form-modal.vue | 4 +- .../asset/host-list/components/host-table.vue | 10 +- .../{host.card.fields.ts => card.fields.ts} | 0 .../{host.form.rules.ts => form.rules.ts} | 0 ...host.table.columns.ts => table.columns.ts} | 0 .../src/views/dashboard/workplace/index.vue | 2 - .../new-connection/host-list-view.vue | 92 +++--- .../components/new-connection/hosts-view.vue | 32 +- .../new-connection/new-connection-view.vue | 41 +-- 20 files changed, 680 insertions(+), 189 deletions(-) delete mode 100644 orion-ops-ui/src/components/asset/authorized-host-modal/index.vue create mode 100644 orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-group.vue create mode 100644 orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-table.vue create mode 100644 orion-ops-ui/src/components/asset/host/authorized-host-modal/index.vue create mode 100644 orion-ops-ui/src/components/asset/host/authorized-host-modal/types/const.ts create mode 100644 orion-ops-ui/src/components/asset/host/authorized-host-modal/types/table.columns.ts create mode 100644 orion-ops-ui/src/types/options.ts rename orion-ops-ui/src/views/asset/host-list/types/{host.card.fields.ts => card.fields.ts} (100%) rename orion-ops-ui/src/views/asset/host-list/types/{host.form.rules.ts => form.rules.ts} (100%) rename orion-ops-ui/src/views/asset/host-list/types/{host.table.columns.ts => table.columns.ts} (100%) diff --git a/orion-ops-ui/src/components/asset/authorized-host-modal/index.vue b/orion-ops-ui/src/components/asset/authorized-host-modal/index.vue deleted file mode 100644 index 13cb232d..00000000 --- a/orion-ops-ui/src/components/asset/authorized-host-modal/index.vue +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - diff --git a/orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-group.vue b/orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-group.vue new file mode 100644 index 00000000..2789458b --- /dev/null +++ b/orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-group.vue @@ -0,0 +1,124 @@ + + + + + + + diff --git a/orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-table.vue b/orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-table.vue new file mode 100644 index 00000000..e23665b7 --- /dev/null +++ b/orion-ops-ui/src/components/asset/host/authorized-host-modal/components/host-table.vue @@ -0,0 +1,101 @@ + + + + + + + diff --git a/orion-ops-ui/src/components/asset/host/authorized-host-modal/index.vue b/orion-ops-ui/src/components/asset/host/authorized-host-modal/index.vue new file mode 100644 index 00000000..bf2958d1 --- /dev/null +++ b/orion-ops-ui/src/components/asset/host/authorized-host-modal/index.vue @@ -0,0 +1,273 @@ + + + + + + + diff --git a/orion-ops-ui/src/components/asset/host/authorized-host-modal/types/const.ts b/orion-ops-ui/src/components/asset/host/authorized-host-modal/types/const.ts new file mode 100644 index 00000000..ef57d029 --- /dev/null +++ b/orion-ops-ui/src/components/asset/host/authorized-host-modal/types/const.ts @@ -0,0 +1,15 @@ +// 新建连接类型 +export const NewConnectionType = { + GROUP: 'group', + LIST: 'list', + FAVORITE: 'favorite', + LATEST: 'latest' +}; + +// 新建连接类型 +export const newConnectionTypeKey = 'hostNewConnectionType'; + +// 加载的字典值 +export const dictKeys = [ + newConnectionTypeKey, +]; diff --git a/orion-ops-ui/src/components/asset/host/authorized-host-modal/types/table.columns.ts b/orion-ops-ui/src/components/asset/host/authorized-host-modal/types/table.columns.ts new file mode 100644 index 00000000..d0ee6680 --- /dev/null +++ b/orion-ops-ui/src/components/asset/host/authorized-host-modal/types/table.columns.ts @@ -0,0 +1,22 @@ +import type { TableColumnData } from '@arco-design/web-vue/es/table/interface'; + +const columns = [ + { + title: '主机名称', + dataIndex: 'name', + slotName: 'name', + ellipsis: true, + tooltip: true + }, { + title: '主机地址', + dataIndex: 'address', + slotName: 'address', + }, { + title: '主机标签', + dataIndex: 'tags', + slotName: 'tags', + align: 'left', + }, +] as TableColumnData[]; + +export default columns; diff --git a/orion-ops-ui/src/types/form.ts b/orion-ops-ui/src/types/form.ts index d8079d10..78341a8b 100644 --- a/orion-ops-ui/src/types/form.ts +++ b/orion-ops-ui/src/types/form.ts @@ -1,4 +1,4 @@ -import type { TreeNodeData } from '@arco-design/web-vue'; +import type { SelectOptionData, TreeNodeData } from '@arco-design/web-vue'; // 通过 label 进行过滤 export const labelFilter = (searchValue: string, option: { label: string }) => { @@ -9,3 +9,14 @@ export const labelFilter = (searchValue: string, option: { label: string }) => { export const titleFilter = (searchValue: string, option: TreeNodeData) => { return (option.title as string).toLowerCase().indexOf(searchValue.toLowerCase()) > -1; }; + +// 通过 tag label 进行过滤 +export const tagLabelFilter = (searchValue: string, option: SelectOptionData) => { + if (searchValue.startsWith('@')) { + // tag 过滤 + return option.isTag && (option.label as string).toLowerCase().startsWith(searchValue.substring(1, searchValue.length).toLowerCase()); + } else { + // 文本过滤 + return !option.isTag && (option.label as string).toLowerCase().indexOf(searchValue.toLowerCase()) > -1; + } +}; diff --git a/orion-ops-ui/src/types/options.ts b/orion-ops-ui/src/types/options.ts new file mode 100644 index 00000000..9eb4c2e9 --- /dev/null +++ b/orion-ops-ui/src/types/options.ts @@ -0,0 +1,24 @@ +import type { SelectOptionData } from '@arco-design/web-vue'; +import type { HostQueryResponse } from '@/api/asset/host'; + +// 获取认证主机过滤器选项 +export const getAuthorizedHostOptions = (list: Array): Array => { + const options: Array = []; + // 添加 tags + const tagNames = list.map(s => s.tags) + .filter(s => s?.length) + .flat(1) + .sort((o1, o2) => o1.id - o2.id) + .map(s => s.name); + [...new Set(tagNames)].map(value => { + return { label: value, value: `@${value}`, isTag: true }; + }).forEach(s => options.push(s)); + // 添加主机信息 + const hostMeta = list.map(s => { + return [s.name, s.code, s.address, s.alias]; + }).filter(Boolean).flat(1); + [...new Set(hostMeta)].map(value => { + return { label: value, value }; + }).forEach(s => options.push(s)); + return options; +}; diff --git a/orion-ops-ui/src/views/asset/grant/components/host-identity-grant.vue b/orion-ops-ui/src/views/asset/grant/components/host-identity-grant.vue index cbb543c6..ae197291 100644 --- a/orion-ops-ui/src/views/asset/grant/components/host-identity-grant.vue +++ b/orion-ops-ui/src/views/asset/grant/components/host-identity-grant.vue @@ -9,10 +9,12 @@ :columns="hostIdentityColumns" v-model:selected-keys="selectedKeys" :row-selection="rowSelection" + row-class="pointer" :sticky-header="true" :data="hostIdentities" :pagination="false" - :bordered="false"> + :bordered="false" + @row-click="clickRow">