Skip to content

Commit

Permalink
feat(frontend): redis安装module TencentBlueKing#8020
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 25565
  • Loading branch information
JustaCattt authored and jinquantianxia committed Dec 2, 2024
1 parent c307315 commit c04cce5
Show file tree
Hide file tree
Showing 24 changed files with 991 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/common/const/clusterTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export enum ClusterTypes {
// redis
export enum ClusterTypes {
REDIS = 'redis', // Redis
PREDIXY_REDIS_CLUSTER = 'PredixyRedisCluster', // Redis集群
PREDIXY_REDIS_CLUSTER = 'PredixyRedisCluster', // RedisCluster集群
PREDIXY_TENDISPLUS_CLUSTER = 'PredixyTendisplusCluster', // Tendisplus存储版集群
TWEMPROXY_REDIS_INSTANCE = 'TwemproxyRedisInstance', // TendisCache集群
TWEMPROXY_TENDIS_SSD_INSTANCE = 'TwemproxyTendisSSDInstance', // TendisSSD集群
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/common/const/ticketTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export enum TicketTypes {
REDIS_INSTANCE_OPEN = 'REDIS_INSTANCE_OPEN', // redis 主从集群启用
REDIS_INSTANCE_CLOSE = 'REDIS_INSTANCE_CLOSE', // redis 主从集群禁用
REDIS_INSTANCE_DESTROY = 'REDIS_INSTANCE_DESTROY', // redis 主从集群删除
REDIS_CLUSTER_LOAD_MODULES = 'REDIS_CLUSTER_LOAD_MODULES', // redis 安装Module
}
export enum TicketTypes {
TENDBCLUSTER_APPLY = 'TENDBCLUSTER_APPLY',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<BkOption
v-for="(item, index) in list"
:key="index"
:disabled="item.disabled"
:label="item.label"
:value="item.value"
@click="handleOptionClick(item.value)">
Expand All @@ -64,6 +65,7 @@
export interface IListItem {
value: IKey;
label: string;
disabled?: boolean;
[x: string]: any;
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
generateRedisDataCopyCheckRepairCloneData,
generateRedisDataCopyCloneData,
generateRedisDataStructureCloneData,
generateRedisInstallModule,
generateRedisMasterSlaveSwitchCloneData,
generateRedisOperationCloneData,
generateRedisProxyScaleDownCloneData,
Expand Down Expand Up @@ -91,6 +92,7 @@ export const generateCloneDataHandlerMap = {
[TicketTypes.REDIS_KEYS_DELETE]: generateRedisOperationCloneData, // Redis 删除Key
[TicketTypes.REDIS_BACKUP]: generateRedisOperationCloneData, // Redis 集群备份
[TicketTypes.REDIS_PURGE]: generateRedisOperationCloneData,
[TicketTypes.REDIS_CLUSTER_LOAD_MODULES]: generateRedisInstallModule, // Redis 安装Module
[TicketTypes.MYSQL_AUTHORIZE_RULES]: generateMysqlAuthorizeRuleCloneData, // Mysql 集群授权
[TicketTypes.MYSQL_IMPORT_SQLFILE]: generateMysqlImportSqlFileCloneData, // Mysql SQL变更执行
[TicketTypes.MYSQL_CHECKSUM]: generateMysqlChecksumCloneData, // Mysql 数据校验
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './clusterTypeUpdate';
export * from './dataCopy';
export * from './dataCopyCheckRepair';
export * from './dataStructure';
export * from './installModule';
export * from './masterSlaveSwitch';
export * from './operation';
export * from './proxyScaleDown';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
*
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
* the specific language governing permissions and limitations under the License.
*/
import type { RedisInstallModuleDetails } from '@services/model/ticket/details/redis';
import TicketModel from '@services/model/ticket/ticket';

import { random } from '@utils';

// Redis 安装Module
export function generateRedisInstallModule(ticketData: TicketModel<RedisInstallModuleDetails>) {
const { clusters, infos } = ticketData.details;
return Promise.resolve({
tableDataList: infos.map((info) => {
const cluster = clusters[info.cluster_id];
return {
rowKey: random(),
isLoading: false,
srcCluster: cluster.immute_domain,
clusterId: info.cluster_id,
bkCloudId: cluster.bk_cloud_id,
clusterType: cluster.cluster_type,
clusterTypeName: cluster.cluster_type_name,
dbVersion: info.db_version,
loadModules: info.load_modules,
};
}),
remark: ticketData.remark,
});
}
6 changes: 6 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3662,5 +3662,11 @@
"源集群不能为空": "源集群不能为空",
"源集群不存在": "源集群不存在",
"源集群重复": "源集群重复",
"为集群安装扩展 Module,仅 RedisCluster、Redis 主从 支持安装 Module。": "为集群安装扩展 Module,仅 RedisCluster、Redis 主从 支持安装 Module。",
"安装 Module": "安装 Module",
"已安装": "已安装",
"请选择Module": "请选择Module",
"安装 Module任务提交成功": "安装 Module任务提交成功",
"仅允许同一管控区域的集群一起安装module": "仅允许同一管控区域的集群一起安装module",
"这行勿动!新增翻译请在上一行添加!": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ interface ControllerData {
'redis.instanceManage': ControllerItem<string>;
'redis.haClusterManage': ControllerItem<string>;
'redis.haInstanceManage': ControllerItem<string>;
'redis.toolbox.installModule': ControllerItem<string>;
'redis.toolbox.capacityChange': ControllerItem<string>;
'redis.toolbox.proxyScaleUp': ControllerItem<string>;
'redis.toolbox.proxyScaleDown': ControllerItem<string>;
Expand Down Expand Up @@ -284,6 +285,7 @@ export default class FunctionController {
'redis.instanceManage': ControllerItem<string>;
'redis.haClusterManage': ControllerItem<string>;
'redis.haInstanceManage': ControllerItem<string>;
'redis.toolbox.installModule': ControllerItem<string>;
'redis.toolbox.capacityChange': ControllerItem<string>;
'redis.toolbox.proxyScaleUp': ControllerItem<string>;
'redis.toolbox.proxyScaleDown': ControllerItem<string>;
Expand Down
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/services/model/redis/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default class Redis {
machine_pair_cnt: number;
major_version: string;
master_domain: string;
module_names: string[];
operations: ClusterListOperation[];
permission: {
access_entry_edit: boolean;
Expand Down Expand Up @@ -122,6 +123,7 @@ export default class Redis {
this.machine_pair_cnt = payload.machine_pair_cnt;
this.major_version = payload.major_version;
this.master_domain = payload.master_domain;
this.module_names = payload.module_names || [];
this.operations = payload.operations || [];
this.permission = payload.permission || {};
this.phase = payload.phase;
Expand Down
11 changes: 11 additions & 0 deletions dbm-ui/frontend/src/services/model/ticket/details/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,14 @@ export interface RedisVersionUpgrade extends DetailBase {
target_version: string;
}[];
}

// redis 安装Module
export interface RedisInstallModuleDetails extends DetailBase {
bk_cloud_id: number;
clusters: DetailClusters;
infos: {
cluster_id: number;
db_version: string;
load_modules: string[];
}[];
}
9 changes: 9 additions & 0 deletions dbm-ui/frontend/src/services/source/redisToolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,12 @@ export function getRedisClusterCapacityUpdateInfo(params: {
err_msg: string;
}>(`${getRootPath()}/get_cluster_capacity_update_info/`, params);
}

/**
* 查询集群模块信息
*/
export function getRedisClusterModuleInfo(params: { cluster_id: number; version: string }) {
return http.get<{
results: Record<string, boolean>;
}>(`${getRootPath()}/get_cluster_module_info/`, params);
}
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}
49 changes: 49 additions & 0 deletions dbm-ui/frontend/src/views/db-manage/redis/install-module/Index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
*
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License athttps://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
* the specific language governing permissions and limitations under the License.
-->

<template>
<Component :is="component" />
</template>
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useRoute } from 'vue-router';

import Page1 from './pages/page1/Index.vue';
import Page2 from './pages/page2/Index.vue';

const route = useRoute();

const comMap = {
ticket: Page1,
success: Page2,
};

const page = ref('');

const component = computed(() => {
if (comMap[page.value as keyof typeof comMap]) {
return comMap[page.value as keyof typeof comMap];
}
return Page1;
});

watch(
route,
() => {
page.value = route.params.page as string;
},
{
immediate: true,
},
);
</script>
Loading

0 comments on commit c04cce5

Please sign in to comment.