From c639048695cad8003eaee2f3473fe590eae602d3 Mon Sep 17 00:00:00 2001 From: chenwenchang <479999519@qq.com> Date: Wed, 11 Sep 2024 10:40:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(frontend):=20=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA=E4=BC=98=E5=8C=96=20#6834?= =?UTF-8?q?=20#=20Reviewed,=20transaction=20id:=2018063?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/cluster-entry-config/Index.vue | 105 ++++---- .../cluster-entry-config/MultipleInput.vue | 126 ---------- .../cluster-entry-config/RenderBindIps.vue | 231 ++++++++++++++++++ .../render-instances/RenderInstances.vue | 72 ++++-- dbm-ui/frontend/src/locales/zh-cn.json | 2 +- .../model/sqlserver/sqlserver-ha-cluster.ts | 1 + .../sqlserver/sqlserver-single-cluster.ts | 1 + dbm-ui/frontend/src/services/source/spider.ts | 11 + .../es-manage/list/components/list/Index.vue | 27 +- .../list/components/list/Index.vue | 28 +-- .../list/components/list/Index.vue | 26 +- .../mysql/ha-cluster-list/components/List.vue | 59 +++-- .../single-cluster-list/components/List.vue | 29 ++- .../list/components/list/Index.vue | 28 +-- .../redis/list-ha/components/list/Index.vue | 24 +- .../redis/list/components/list/Index.vue | 27 +- .../list/components/list/Index.vue | 88 ++++--- .../ha-cluster-list/components/List.vue | 37 ++- .../single-cluster/components/List.vue | 24 +- 19 files changed, 558 insertions(+), 388 deletions(-) delete mode 100644 dbm-ui/frontend/src/components/cluster-entry-config/MultipleInput.vue create mode 100644 dbm-ui/frontend/src/components/cluster-entry-config/RenderBindIps.vue diff --git a/dbm-ui/frontend/src/components/cluster-entry-config/Index.vue b/dbm-ui/frontend/src/components/cluster-entry-config/Index.vue index c28901eff8..ba88d6b918 100644 --- a/dbm-ui/frontend/src/components/cluster-entry-config/Index.vue +++ b/dbm-ui/frontend/src/components/cluster-entry-config/Index.vue @@ -13,9 +13,11 @@ @@ -60,7 +48,6 @@ | SqlServerSingleClusterDetailModel "> import { useI18n } from 'vue-i18n'; - import { useRequest } from 'vue-request'; import EsModel from '@services/model/es/es'; import HdfsModel from '@services/model/hdfs/hdfs'; @@ -69,16 +56,16 @@ import SpiderModel from '@services/model/spider/spider'; import SqlServerHaClusterDetailModel from '@services/model/sqlserver/sqlserver-ha-cluster-detail'; import SqlServerSingleClusterDetailModel from '@services/model/sqlserver/sqlserver-single-cluster-detail'; - import { updateClusterEntryConfig } from '@services/source/clusters'; import type { ResourceItem, ResourceRedisItem } from '@services/types'; - import { messageError, messageSuccess } from '@utils'; + import type { DBTypes } from '@common/const'; - import MultipleInput, { checkIp } from './MultipleInput.vue'; + import RenderBindIps from './RenderBindIps.vue'; export interface RowData { type: string, entry: string, + role: string, ips: string, port: number, } @@ -89,12 +76,16 @@ interface Props { id?: number + dbConsole: string; + resource: DBTypes; + permission: boolean; getDetailInfo: (params: any) => Promise } - type UpdateClusterEntryConfigParams = ServiceParameters; - - const props = defineProps(); + const props = withDefaults(defineProps(), { + id: 0, + disabled: true, + }); const emits = defineEmits(); @@ -112,27 +103,39 @@ { label: t('访问入口'), field: 'entry', + width: 263, showOverflowTooltip: true, + render: ({ data }: {data: RowData}) => { + if (data.role === 'master_entry') { + return ( + <> + { t('主') }{ data.entry } + + ) + } + return ( + <> + { t('从') }{ data.entry } + + ) + }, }, { label: 'Bind IP', field: 'ips', - render: ({ data }: {data: RowData}) => , + width: 263, + render: ({ data }: {data: RowData}) => ( + + ) }, ]; - const { run: runUpdateClusterEntryConfig } = useRequest(updateClusterEntryConfig, { - manual: true, - onSuccess: () => { - messageSuccess(t('修改成功')); - emits('success'); - handleClose(); - }, - onError: () => { - messageError(t('修改失败')); - }, - }); - watch(() => props.id, (id) => { if (id) { fetchResources(); @@ -150,6 +153,7 @@ tableData.value = res.cluster_entry_details.map(item => ({ type: item.cluster_entry_type, entry: item.entry, + role: item.role, ips: item.target_details.map(row => row.ip).join('\n'), port: item.target_details[0].port, })); @@ -168,29 +172,9 @@ isShow.value = false; }; - const handleConfirm = () => { - if (!props.id) { - return; - } - const dnsData = tableData.value.filter(item => item.type === 'dns'); - const isChecked = dnsData.every(item => item.ips.split('\n').every(ip => checkIp(ip))); - if (isChecked) { - const details = dnsData.reduce((results, item) => { - const obj = { - cluster_entry_type: item.type, - domain_name: item.entry, - target_instances: item.ips.split('\n').map(row => `${row}#${item.port}`), - }; - results.push(obj); - return results; - }, [] as UpdateClusterEntryConfigParams['cluster_entry_details']); - const params = { - cluster_id: props.id, - cluster_entry_details: details, - }; - runUpdateClusterEntryConfig(params); - } - }; + const handleSuccess = () => { + emits('success'); + } diff --git a/dbm-ui/frontend/src/components/cluster-entry-config/MultipleInput.vue b/dbm-ui/frontend/src/components/cluster-entry-config/MultipleInput.vue deleted file mode 100644 index 740f316609..0000000000 --- a/dbm-ui/frontend/src/components/cluster-entry-config/MultipleInput.vue +++ /dev/null @@ -1,126 +0,0 @@ - - - - diff --git a/dbm-ui/frontend/src/components/cluster-entry-config/RenderBindIps.vue b/dbm-ui/frontend/src/components/cluster-entry-config/RenderBindIps.vue new file mode 100644 index 0000000000..73c9507538 --- /dev/null +++ b/dbm-ui/frontend/src/components/cluster-entry-config/RenderBindIps.vue @@ -0,0 +1,231 @@ + + + + diff --git a/dbm-ui/frontend/src/components/render-instances/RenderInstances.vue b/dbm-ui/frontend/src/components/render-instances/RenderInstances.vue index c98879269e..386e3a07ec 100644 --- a/dbm-ui/frontend/src/components/render-instances/RenderInstances.vue +++ b/dbm-ui/frontend/src/components/render-instances/RenderInstances.vue @@ -35,6 +35,18 @@ size="small"> {{ t('不可用') }} + + + {{ item.displayName }} + +