From b4b2f19a74d3f0daa700b7ffab79178a1977ac59 Mon Sep 17 00:00:00 2001 From: chenwenchang <479999519@qq.com> Date: Tue, 10 Sep 2024 11:11:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E8=B5=84=E6=BA=90=E6=B1=A0?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=A7=86=E5=9B=BE=20#6519=20#=20Reviewed,=20?= =?UTF-8?q?transaction=20id:=2017883?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/common/const/clusterTypeInfos.ts | 177 +++++++++- .../src/services/model/db-resource/summary.ts | 45 +-- .../model/resource-spec/resourceSpec.ts | 8 +- .../src/views/resource-manage/pool/Index.vue | 12 +- .../com-factory/components/ForBiz.vue | 4 - .../com-factory/components/ResourceType.vue | 4 - .../com-factory/components/SpecId.vue | 240 +------------ .../components/field-input/Index.vue | 3 - .../pool/summary-view/components/Export.vue | 5 +- .../pool/summary-view/components/List.vue | 18 +- .../components/search-box/components/Biz.vue | 7 - .../components/search-box/components/Db.vue | 14 +- .../search-box/components/Region.vue | 17 +- .../components/search-box/components/Spec.vue | 227 +------------ .../src/views/resource-manage/spec/Index.vue | 315 +----------------- 15 files changed, 261 insertions(+), 835 deletions(-) diff --git a/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts b/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts index fbafeb7df4..83c4b76bc1 100644 --- a/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts +++ b/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts @@ -4,18 +4,23 @@ import { t } from '@locales/index'; import { ClusterTypes } from './clusterTypes'; import { DBTypes } from './dbTypes'; +import { MachineTypes } from './machineTypes'; -interface InfoItem { +export interface ClusterTypeInfoItem { id: ClusterTypes; name: string; dbType: DBTypes; moduleId: ExtractedControllerDataKeys; + machineList: { + id: MachineTypes; + name: string; + }[]; } type InfoType = { - [x in ClusterTypes]?: InfoItem; + [x in ClusterTypes]?: ClusterTypeInfoItem; }; type RequiredInfoType = { - [x in ClusterTypes]: InfoItem; + [x in ClusterTypes]: ClusterTypeInfoItem; }; const mysql: InfoType = { @@ -24,18 +29,47 @@ const mysql: InfoType = { name: t('MySQL单节点'), dbType: DBTypes.MYSQL, moduleId: 'mysql', + machineList: [ + { + id: MachineTypes.SINGLE, + name: t('后端存储机型'), + }, + ], }, [ClusterTypes.TENDBHA]: { id: ClusterTypes.TENDBHA, name: t('MySQL主从'), dbType: DBTypes.MYSQL, moduleId: 'mysql', + machineList: [ + { + id: MachineTypes.BACKEND, + name: t('后端存储机型'), + }, + { + id: MachineTypes.PROXY, + name: t('Proxy机型'), + }, + ], }, +}; + +const spider: InfoType = { [ClusterTypes.TENDBCLUSTER]: { id: ClusterTypes.TENDBCLUSTER, name: 'TenDBCluster', - dbType: DBTypes.MYSQL, + dbType: DBTypes.TENDBCLUSTER, moduleId: 'mysql', + machineList: [ + { + id: MachineTypes.SPIDER, + name: t('接入层Master'), + }, + { + id: MachineTypes.REMOTE, + name: t('后端存储规格'), + }, + ], }, }; @@ -45,30 +79,76 @@ const redis: InfoType = { name: 'TendisCache', dbType: DBTypes.REDIS, moduleId: 'redis', + machineList: [ + { + id: MachineTypes.TENDISCACHE, + name: t('后端存储机型'), + }, + { + id: MachineTypes.TWEMPROXY, + name: t('Proxy机型'), + }, + ], }, [ClusterTypes.TWEMPROXY_TENDIS_SSD_INSTANCE]: { id: ClusterTypes.TWEMPROXY_TENDIS_SSD_INSTANCE, name: 'TendisSSD', dbType: DBTypes.REDIS, moduleId: 'redis', + machineList: [ + { + id: MachineTypes.TENDISSSD, + name: t('后端存储机型'), + }, + { + id: MachineTypes.TWEMPROXY, + name: t('Proxy机型'), + }, + ], }, [ClusterTypes.PREDIXY_TENDISPLUS_CLUSTER]: { id: ClusterTypes.PREDIXY_TENDISPLUS_CLUSTER, name: 'Tendisplus', dbType: DBTypes.REDIS, moduleId: 'redis', + machineList: [ + { + id: MachineTypes.TENDISPLUS, + name: t('后端存储机型'), + }, + { + id: MachineTypes.PREDIXY, + name: t('Proxy机型'), + }, + ], }, [ClusterTypes.PREDIXY_REDIS_CLUSTER]: { id: ClusterTypes.PREDIXY_REDIS_CLUSTER, name: 'RedisCluster', dbType: DBTypes.REDIS, moduleId: 'redis', + machineList: [ + { + id: MachineTypes.TENDISCACHE, + name: t('后端存储机型'), + }, + { + id: MachineTypes.PREDIXY, + name: t('Proxy机型'), + }, + ], }, [ClusterTypes.REDIS_INSTANCE]: { id: ClusterTypes.REDIS_INSTANCE, name: t('Redis主从'), dbType: DBTypes.REDIS, moduleId: 'redis', + machineList: [ + { + id: MachineTypes.TENDISCACHE, + name: t('后端存储机型'), + }, + ], }, }; @@ -78,42 +158,98 @@ const bigdata: InfoType = { name: 'ES', dbType: DBTypes.ES, moduleId: 'bigdata', + machineList: [ + { + id: MachineTypes.ES_MASTER, + name: t('Master节点规格'), + }, + { + id: MachineTypes.ES_CLIENT, + name: t('Client节点规格'), + }, + { + id: MachineTypes.ES_DATANODE, + name: t('冷_热节点规格'), + }, + ], }, [ClusterTypes.KAFKA]: { id: ClusterTypes.KAFKA, name: 'Kafka', dbType: DBTypes.KAFKA, moduleId: 'bigdata', + machineList: [ + { + id: MachineTypes.ZOOKEEPER, + name: t('Zookeeper节点规格'), + }, + { + id: MachineTypes.BROKER, + name: t('Broker节点规格'), + }, + ], }, [ClusterTypes.HDFS]: { id: ClusterTypes.HDFS, name: 'HDFS', dbType: DBTypes.HDFS, moduleId: 'bigdata', + machineList: [ + { + id: MachineTypes.HDFS_DATANODE, + name: t('DataNode节点规格'), + }, + { + id: MachineTypes.HDFS_MASTER, + name: t('NameNode_Zookeeper_JournalNode节点规格'), + }, + ], }, [ClusterTypes.INFLUXDB]: { id: ClusterTypes.INFLUXDB, name: 'InfuxDB', dbType: DBTypes.INFLUXDB, moduleId: 'bigdata', + machineList: [ + { + id: MachineTypes.INFLUXDB, + name: t('后端存储机型'), + }, + ], }, [ClusterTypes.PULSAR]: { id: ClusterTypes.PULSAR, name: 'Pulsar', dbType: DBTypes.PULSAR, moduleId: 'bigdata', + machineList: [ + { + id: MachineTypes.PULSAR_BOOKKEEPER, + name: t('Bookkeeper节点规格'), + }, + { + id: MachineTypes.PULSAR_ZOOKEEPER, + name: t('Zookeeper节点规格'), + }, + { + id: MachineTypes.PULSAR_BROKER, + name: t('Broker节点规格'), + }, + ], }, [ClusterTypes.RIAK]: { id: ClusterTypes.RIAK, name: 'Riak', dbType: DBTypes.RIAK, moduleId: 'bigdata', + machineList: [], }, [ClusterTypes.DORIS]: { id: ClusterTypes.DORIS, name: 'Doris', dbType: DBTypes.DORIS, moduleId: 'bigdata', + machineList: [], }, }; @@ -123,12 +259,32 @@ const mongo: InfoType = { name: t('Mongo副本集'), dbType: DBTypes.MONGODB, moduleId: 'mongodb', + machineList: [ + { + id: MachineTypes.MONGODB, + name: t('Mongodb规格'), + }, + ], }, [ClusterTypes.MONGO_SHARED_CLUSTER]: { id: ClusterTypes.MONGO_SHARED_CLUSTER, name: t('Mongo 分片集群'), dbType: DBTypes.MONGODB, moduleId: 'mongodb', + machineList: [ + { + id: MachineTypes.MONGOS, + name: t('Mongos规格'), + }, + { + id: MachineTypes.MONGODB, + name: t('ConfigSvr规格'), + }, + { + id: MachineTypes.MONGO_CONFIG, + name: t('ShardSvr规格'), + }, + ], }, }; @@ -138,12 +294,24 @@ const sqlserver: InfoType = { name: t('SQLServer单节点'), dbType: DBTypes.SQLSERVER, moduleId: 'sqlserver', + machineList: [ + { + id: MachineTypes.SQLSERVER_SINGLE, + name: t('单节点规格'), + }, + ], }, [ClusterTypes.SQLSERVER_HA]: { id: ClusterTypes.SQLSERVER_HA, name: t('SQLServer主从'), dbType: DBTypes.SQLSERVER, moduleId: 'sqlserver', + machineList: [ + { + id: MachineTypes.SQLSERVER_HA, + name: t('主从规格'), + }, + ], }, }; @@ -152,6 +320,7 @@ const sqlserver: InfoType = { */ export const clusterTypeInfos: RequiredInfoType = { ...mysql, + ...spider, ...redis, ...bigdata, ...mongo, diff --git a/dbm-ui/frontend/src/services/model/db-resource/summary.ts b/dbm-ui/frontend/src/services/model/db-resource/summary.ts index da83206fa3..d2e09ec06d 100644 --- a/dbm-ui/frontend/src/services/model/db-resource/summary.ts +++ b/dbm-ui/frontend/src/services/model/db-resource/summary.ts @@ -11,9 +11,7 @@ * the specific language governing permissions and limitations under the License. */ -import { MachineTypes } from '@common/const'; - -import { t } from '@locales/index'; +import { clusterTypeInfos, ClusterTypes, MachineTypes } from '@common/const'; export default class Summary { dedicated_biz: number; @@ -21,6 +19,7 @@ export default class Summary { city: string; spec_id?: number; spec_name?: string; + spec_cluster_type?: ClusterTypes; spec_machine_type?: MachineTypes; device_class?: string; disk_summary?: string; @@ -34,6 +33,7 @@ export default class Summary { this.city = payload.city; this.spec_id = payload.spec_id; this.spec_name = payload.spec_name; + this.spec_cluster_type = payload.spec_cluster_type; this.spec_machine_type = payload.spec_machine_type; this.device_class = payload.device_class; this.disk_summary = payload.disk_summary; @@ -46,38 +46,13 @@ export default class Summary { return `${this.device_class} (${this.disk_summary})`; } - get spec_machine_display() { - const machineTypeMap: Record = { - [MachineTypes.SINGLE]: t('后端存储机型'), - [MachineTypes.SPIDER]: t('接入层Master'), - [MachineTypes.REMOTE]: t('后端存储规格'), - [MachineTypes.PROXY]: t('Proxy机型'), - [MachineTypes.BACKEND]: t('后端存储机型'), - [MachineTypes.PREDIXY]: t('Proxy机型'), - [MachineTypes.TWEMPROXY]: t('Proxy机型'), - [MachineTypes.INFLUXDB]: t('后端存储机型'), - [MachineTypes.RIAK]: t('后端存储机型'), - [MachineTypes.BROKER]: t('Broker节点规格'), - [MachineTypes.ZOOKEEPER]: t('Zookeeper节点规格'), - [MachineTypes.REDIS]: t('后端存储机型'), - [MachineTypes.TENDISCACHE]: t('后端存储机型'), - [MachineTypes.TENDISSSD]: t('后端存储机型'), - [MachineTypes.TENDISPLUS]: t('后端存储机型'), - [MachineTypes.ES_DATANODE]: t('冷_热节点规格'), - [MachineTypes.ES_MASTER]: t('Master节点规格'), - [MachineTypes.ES_CLIENT]: t('Client节点规格'), - [MachineTypes.HDFS_MASTER]: t('NameNode_Zookeeper_JournalNode节点规格'), - [MachineTypes.HDFS_DATANODE]: t('DataNode节点规格'), - [MachineTypes.MONGOS]: t('Mongos规格'), - [MachineTypes.MONGODB]: t('ShardSvr规格'), - [MachineTypes.MONGO_CONFIG]: t('ConfigSvr规格'), - [MachineTypes.SQLSERVER_HA]: t('后端存储机型'), - [MachineTypes.SQLSERVER_SINGLE]: t('后端存储机型'), - [MachineTypes.PULSAR_BROKER]: t('Broker节点规格'), - [MachineTypes.PULSAR_BOOKKEEPER]: t('Bookkeeper节点规格'), - [MachineTypes.PULSAR_ZOOKEEPER]: t('Zookeeper节点规格'), - }; - return this.spec_machine_type ? machineTypeMap[this.spec_machine_type] : ''; + get spec_type_display() { + if (!this.spec_cluster_type || !this.spec_machine_type) { + return '--'; + } + const { name, machineList } = clusterTypeInfos[this.spec_cluster_type]; + const matchMachine = machineList.find(({ id }) => id === this.spec_machine_type); + return matchMachine ? `${name} - ${matchMachine.name}` : '--'; } get sub_zone_detail_display() { diff --git a/dbm-ui/frontend/src/services/model/resource-spec/resourceSpec.ts b/dbm-ui/frontend/src/services/model/resource-spec/resourceSpec.ts index 4217b007e6..61a2e7d899 100644 --- a/dbm-ui/frontend/src/services/model/resource-spec/resourceSpec.ts +++ b/dbm-ui/frontend/src/services/model/resource-spec/resourceSpec.ts @@ -12,6 +12,8 @@ */ import { differenceInSeconds } from 'date-fns'; +import type { ClusterTypes, DBTypes, MachineTypes } from '@common/const'; + import { utcDisplayTime } from '@utils'; export default class ResourceSpec { @@ -33,8 +35,9 @@ export default class ResourceSpec { creator: string; desc: string; enable: boolean; - spec_cluster_type: string; - spec_machine_type: string; + spec_db_type: DBTypes; + spec_cluster_type: ClusterTypes; + spec_machine_type: MachineTypes; spec_name: string; update_at: string; updater: string; @@ -60,6 +63,7 @@ export default class ResourceSpec { this.creator = payload.creator; this.desc = payload.desc; this.enable = payload.enable; + this.spec_db_type = payload.spec_db_type; this.spec_cluster_type = payload.spec_cluster_type; this.spec_machine_type = payload.spec_machine_type; this.spec_name = payload.spec_name; diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/Index.vue index 8916a77ad1..4d92293e69 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/Index.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/Index.vue @@ -23,9 +23,7 @@ :name="item.name" />
- - - +
@@ -51,7 +49,7 @@ }, ]; - const active = useDebouncedRef(route.query.tab || 'summary-view'); + const active = useDebouncedRef((route.query.tab as string) || 'summary-view'); const renderComponentMap = { 'summary-view': SummaryView, @@ -63,11 +61,7 @@ watch( () => route.query, () => { - console.log(route.query, 'route.query'); - - if (route.query.tab) { - active.value = route.query.tab; - } + active.value = (route.query.tab as string) || 'summary-view'; }, ); diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/ForBiz.vue b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/ForBiz.vue index 55fbbc4180..6f80744fd9 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/ForBiz.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/ForBiz.vue @@ -20,10 +20,6 @@ :placeholder="t('请选择专用业务')" show-selected-icon @change="handleChange"> - - + v-for="item in Object.values(clusterTypeInfos)" + :key="item.id" + :label="item.name" + :value="item.id" /> + :key="item.id" + :label="item.name" + :value="item.id" />