Skip to content

Commit

Permalink
feat(frontend): 集群列表支持批量禁用/启用、删除集群 TencentBlueKing#7753
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves authored and hLinx committed Nov 20, 2024
1 parent be75875 commit f916c73
Show file tree
Hide file tree
Showing 55 changed files with 3,446 additions and 2,910 deletions.
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/common/const/clusterTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export enum ClusterTypes {
}
// sqlserver
export enum ClusterTypes {
SQLSERVER = 'sqlserver',
SQLSERVER_SINGLE = 'sqlserver_single', // SQLServer单节点版
SQLSERVER_HA = 'sqlserver_ha', // SQLServer主从版
}
Expand Down
3 changes: 2 additions & 1 deletion dbm-ui/frontend/src/components/db-table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@
getAllData: fetchAllData,
// 清空选择
clearSelected() {
bkTableRef.value?.clearSelection();
// bkTableRef.value?.clearSelection();
handleClearWholeSelect();
},
updateTableKey() {
tableKey.value = Date.now().toString();
Expand Down
16 changes: 16 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3633,5 +3633,21 @@
"DB名称支持通配符_如Data_区分大小写_多个使用英文逗号_分号或换行分隔": "DB名称支持通配符 %,如 Data%,区分大小写,多个使用英文逗号、分号或换行分隔",
"删除规则会创建单据,需此规则所有过往调用方审批后才执行删除。": "删除规则会创建单据,需此规则所有过往调用方审批后才执行删除。",
"不允许 *": "不允许 *",
"确定启用集群": "确定启用集群",
"确定禁用集群": "确定禁用集群",
"确定删除集群": "确定删除集群",
"仅可删除状态为“已禁用”的集群": "仅可删除状态为“已禁用”的集群",
"仅可启用状态为“已禁用”的集群": "仅可启用状态为“已禁用”的集群",
"仅可禁用状态为“已启用”的集群": "仅可禁用状态为“已启用”的集群",
"确定启用集群?": "确定启用集群?",
"确定禁用集群?": "确定禁用集群?",
"仅已启用集群可以提取 Key": "仅已启用集群可以提取 Key",
"仅已启用集群可以删除 Key": "仅已启用集群可以删除 Key",
"仅已启用集群可以备份": "仅已启用集群可以备份",
"仅已启用集群可以清档": "仅已启用集群可以清档",
"仅可订阅状态为“已启用”的集群": "仅可订阅状态为“已启用”的集群",
"仅可授权状态为“已启用”的集群": "仅可授权状态为“已启用”的集群",
"请先禁用集群": "请先禁用集群",
"无运维节点": "无运维节点",
"这行勿动!新增翻译请在上一行添加!": ""
}
6 changes: 5 additions & 1 deletion dbm-ui/frontend/src/services/model/es/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { uniq } from 'lodash';

import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types';

import { utcDisplayTime } from '@utils';
import { isRecentDays, utcDisplayTime } from '@utils';

import { t } from '@locales/index';

Expand Down Expand Up @@ -233,6 +233,10 @@ export default class Es {
}));
}

get isNew() {
return isRecentDays(this.create_at, 24);
}

initOperations(payload = [] as Es['operations']) {
if (!Array.isArray(payload)) {
return [];
Expand Down
6 changes: 5 additions & 1 deletion dbm-ui/frontend/src/services/model/hdfs/hdfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { uniq } from 'lodash';

import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types';

import { utcDisplayTime } from '@utils';
import { isRecentDays, utcDisplayTime } from '@utils';

import { t } from '@locales/index';

Expand Down Expand Up @@ -238,4 +238,8 @@ export default class Hdfs {
get isStarting() {
return Boolean(this.operations.find((item) => item.ticket_type === Hdfs.HDFS_ENABLE));
}

get isNew() {
return isRecentDays(this.create_at, 24);
}
}
6 changes: 5 additions & 1 deletion dbm-ui/frontend/src/services/model/mysql/tendbha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { uniq } from 'lodash';

import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types';

import { utcDisplayTime } from '@utils';
import { isRecentDays, utcDisplayTime } from '@utils';

import { t } from '@locales/index';

Expand Down Expand Up @@ -232,4 +232,8 @@ export default class Tendbha {
ticketId: item.ticket_id,
}));
}

get isNew() {
return isRecentDays(this.create_at, 24);
}
}
6 changes: 5 additions & 1 deletion dbm-ui/frontend/src/services/model/mysql/tendbsingle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { uniq } from 'lodash';

import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types';

import { utcDisplayTime } from '@utils';
import { isRecentDays, utcDisplayTime } from '@utils';

import { t } from '@locales/index';

Expand Down Expand Up @@ -210,4 +210,8 @@ export default class Tendbsingle {
ticketId: item.ticket_id,
}));
}

get isNew() {
return isRecentDays(this.create_at, 24);
}
}
12 changes: 6 additions & 6 deletions dbm-ui/frontend/src/services/model/redis/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export default class Redis {
static REDIS_PROXY_CLOSE = 'REDIS_PROXY_CLOSE';
static REDIS_PROXY_OPEN = 'REDIS_PROXY_OPEN';
static REDIS_INSTANCE_DESTROY = 'REDIS_INSTANCE_DESTROY';
static REDIS_INSTANCE_PROXY_CLOSE = 'REDIS_INSTANCE_PROXY_CLOSE';
static REDIS_INSTANCE_PROXY_OPEN = 'REDIS_INSTANCE_PROXY_OPEN';
static REDIS_INSTANCE_CLOSE = 'REDIS_INSTANCE_CLOSE';
static REDIS_INSTANCE_OPEN = 'REDIS_INSTANCE_OPEN';

static operationIconMap = {
[Redis.REDIS_PROXY_OPEN]: t('启用中'),
[Redis.REDIS_PROXY_CLOSE]: t('禁用中'),
[Redis.REDIS_DESTROY]: t('删除中'),
[Redis.REDIS_INSTANCE_PROXY_OPEN]: t('启用中'),
[Redis.REDIS_INSTANCE_PROXY_CLOSE]: t('禁用中'),
[Redis.REDIS_INSTANCE_OPEN]: t('启用中'),
[Redis.REDIS_INSTANCE_CLOSE]: t('禁用中'),
[Redis.REDIS_INSTANCE_DESTROY]: t('删除中'),
};

Expand All @@ -40,8 +40,8 @@ export default class Redis {
[Redis.REDIS_PROXY_CLOSE]: t('禁用任务执行中'),
[Redis.REDIS_PROXY_OPEN]: t('启用任务执行中'),
[Redis.REDIS_INSTANCE_DESTROY]: t('删除任务执行中'),
[Redis.REDIS_INSTANCE_PROXY_CLOSE]: t('禁用任务执行中'),
[Redis.REDIS_INSTANCE_PROXY_OPEN]: t('启用任务执行中'),
[Redis.REDIS_INSTANCE_CLOSE]: t('禁用任务执行中'),
[Redis.REDIS_INSTANCE_OPEN]: t('启用任务执行中'),
};

bk_biz_id: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<!--
* 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>
<BkDropdown
:key="renderKey"
v-bk-tooltips="{
disabled: !disabled,
content: t('请选择操作集群'),
}"
class="cluster-batch-operation"
:disabled="disabled"
:popover-options="popoverOptions"
@click.stop
@hide="() => (isShowDropdown = false)"
@show="() => (isShowDropdown = true)">
<BkButton :disabled="disabled">
{{ t('批量操作') }}
<DbIcon
class="cluster-batch-operation-icon ml-4"
:class="[{ 'cluster-batch-operation-icon-active': isShowDropdown }]"
type="up-big " />
</BkButton>
<template #content>
<BkDropdownMenu class="cluster-batch-operation-popover">
<Component
:is="content"
v-model:side-slider-show="sideSliderShow"
:selected="selected"
@success="handleSuccess">
</Component>
</BkDropdownMenu>
</template>
</BkDropdown>
</template>

<script lang="ts">
import _ from 'lodash';
import { useI18n } from 'vue-i18n';
import MongodbModel from '@services/model/mongodb/mongodb';
import TendbHaModel from '@services/model/mysql/tendbha';
import TendbSingleModel from '@services/model/mysql/tendbsingle';
import RedisModel from '@services/model/redis/redis';
import SqlserverHaModel from '@services/model/sqlserver/sqlserver-ha';
import SqlserverSingleModel from '@services/model/sqlserver/sqlserver-single';
import TendbClusterModel from '@services/model/tendbcluster/tendbcluster';
import { ClusterTypes } from '@common/const';
interface ClusterModelMap {
[ClusterTypes.TENDBSINGLE]: TendbSingleModel;
[ClusterTypes.TENDBHA]: TendbHaModel;
[ClusterTypes.TENDBCLUSTER]: TendbClusterModel;
[ClusterTypes.REDIS]: RedisModel;
[ClusterTypes.REDIS_INSTANCE]: RedisModel;
[ClusterTypes.MONGO_REPLICA_SET]: MongodbModel;
[ClusterTypes.MONGO_SHARED_CLUSTER]: MongodbModel;
[ClusterTypes.SQLSERVER_SINGLE]: SqlserverSingleModel;
[ClusterTypes.SQLSERVER_HA]: SqlserverHaModel;
}
</script>
<script setup lang="ts" generic="T extends keyof ClusterModelMap">
interface Props {
selected: ClusterModelMap[T][];
clusterType: T;
}
interface Emits {
(e: 'success'): void;
}
const props = defineProps<Props>();
const emits = defineEmits<Emits>();
const { t } = useI18n();
const contentModule = import.meta.glob<{
default: () => {
name: T;
};
}>('./components/*/Index.vue', {
eager: true,
});
const isShowDropdown = ref(false);
const sideSliderShow = ref(false);
const renderKey = ref(new Date().getTime());
const disabled = computed(() => props.selected.length === 0);
const content = computed(() => {
const renderModule = _.find(
Object.values(contentModule),
(moduleItem) => moduleItem.default.name === props.clusterType,
);
if (renderModule) {
return renderModule.default;
}
return null;
});
const popoverOptions = computed(() => ({
disableOutsideClick: sideSliderShow.value,
}));
watch(sideSliderShow, () => {
if (!sideSliderShow.value) {
renderKey.value = new Date().getTime();
}
});
const handleSuccess = () => {
emits('success');
};
</script>

<style lang="less">
.cluster-batch-operation-popover {
.bk-dropdown-item {
padding: 0;
.opration-button {
padding: 0 16px;
}
}
}
</style>

<style lang="less" scoped>
.cluster-batch-operation {
.cluster-batch-operation-icon {
transform: rotate(0);
transition: all 0.2s;
}
.cluster-batch-operation-icon-active {
transform: rotate(180deg);
}
}
</style>
Loading

0 comments on commit f916c73

Please sign in to comment.