Skip to content

Commit

Permalink
perf(frontend): mongodb工具箱重构_全库备份 #8498
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves committed Dec 12, 2024
1 parent 8f44114 commit 45c375b
Show file tree
Hide file tree
Showing 15 changed files with 704 additions and 18 deletions.
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/components/cluster-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
getResourceList: getTendbsingleList,
tableContent: TendbSingleTable,
resultContent: ResultPreview,
showPreviewResultTitle: true,
},
[ClusterTypes.MONGO_REPLICA_SET]: {
id: ClusterTypes.MONGO_REPLICA_SET,
Expand All @@ -333,6 +334,7 @@
getResourceList: getMongoList,
tableContent: MongoTable,
resultContent: ResultPreview,
showPreviewResultTitle: true,
},
[ClusterTypes.MONGO_SHARED_CLUSTER]: {
id: ClusterTypes.MONGO_SHARED_CLUSTER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-->

<template>
<FixedColumn>
<EditableTableColumn label="操作">
<div class="action-box">
<div
v-if="showAdd"
Expand All @@ -37,12 +37,17 @@
<DbIcon type="copy-2" />
</div>
</div>
</FixedColumn>
</EditableTableColumn>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n';

import FixedColumn from '@components/render-table/columns/fixed-column/index.vue';
import {
// Block as EditBlock,
Column as EditableTableColumn,
// Row as EditableTableRow,
} from '@components/editable-table/Index.vue';
// import FixedColumn from '@components/render-table/columns/fixed-column/index.vue';

interface Props {
showAdd?: boolean;
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export * from './useTableSettings';
export * from './useTagsOverflow';
export * from './useTaskCount';
export * from './useTicketCloneInfo';
export * from './useTicketDetail';
export * from './useTicketMessage';
export * from './useTimeZoneFormat';
export * from './useUrlSearach';
68 changes: 68 additions & 0 deletions dbm-ui/frontend/src/hooks/useTicketDetail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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 { useRequest } from 'vue-request';
import { useRoute } from 'vue-router';

import type { DetailBase } from '@services/model/ticket/details/common';
import TicketModel from '@services/model/ticket/ticket';
import { getTicketDetails } from '@services/source/ticket';

import { TicketTypes } from '@common/const';

export function useTicketDetail<T extends DetailBase>(
ticketType: TicketTypes,
options: {
onSuccess: (data: TicketModel<T>) => void;
},
) {
const route = useRoute();
const { ticketId } = route.query;

if (!ticketId) {
return;
}

useRequest(getTicketDetails, {
defaultParams: [{ id: Number(ticketId) }, { permission: 'catch' }],
onSuccess(ticketData) {
if (ticketType !== ticketData.ticket_type) {
return;
}
options.onSuccess(ticketData as TicketModel<T>);
},
});
}

// export function useTicketDetail(
// ticketType: TicketTypes | TicketTypes[],
// options: {
// onSuccess: (data: TicketModel<unknown>, matchingType: TicketTypes) => void;
// },
// ) {
// const route = useRoute();
// const { ticketId } = route.query;
// const { onSuccess } = options;
// if (!ticketId) {
// return;
// }
// useRequest(getTicketDetails, {
// defaultParams: [{ id: Number(ticketId) }, { permission: 'catch' }],
// onSuccess(ticketData) {
// const ticketTypeList = Array.isArray(ticketType) ? ticketType : [ticketType];
// if (!ticketTypeList.includes(ticketData.ticket_type)) {
// return;
// }
// onSuccess(ticketData, ticketData.ticket_type);
// },
// });
// }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { DetailBase, DetailClusters } from '../common';

export interface DbBackupDetails extends DetailBase {
clusters: DetailClusters;
file_tag: string;
infos: {
cluster_id: number;
}[];
oplog: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './MONGODB_FULL_BACKUP';
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/services/model/ticket/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { t } from '@locales/index';

import type { DetailBase } from './details/common';

export type * as Mongodb from './details/mongodb';
export type * as Mysql from './details/mysql';
export type * as Redis from './details/redis';
export type * as Sqlserver from './details/sqlserver';
Expand Down
18 changes: 18 additions & 0 deletions dbm-ui/frontend/src/views/db-manage/common/TicketRemark.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<BkFormItem :label="t('备注')">
<BkInput
v-model="modelValue"
:maxlength="500"
:placeholder="t('请提供更多有用信息申请信息_以获得更快审批')"
style="width: 700px"
type="textarea" />
</BkFormItem>
</template>

<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const modelValue = defineModel<string>();
</script>
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="com" />
</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 com = 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 45c375b

Please sign in to comment.