Skip to content

fix(frontend): 分区执行合并处理步骤 #10201 #10207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/services/source/partitionManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ interface IDryRunData {
shard_name: string;
}
// 分区策略前置执行
export const dryRun = function (params: { cluster_id: number; cluster_type: string; config_id: number }) {
export const dryRun = function (params: { cluster_id: number; config_id: number }) {
const { currentBizId } = useGlobalBizs();
return http.post<Record<number, IDryRunData[]>>('/apis/partition/dry_run/', {
bk_biz_id: currentBizId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
@clear-search="handleClearSearch"
@selection="handleTableSelection"
@setting-change="handleSettingChange" />
<DryRun
v-model="isShowDryRun"
:cluster-id="operationData?.cluster_id || operationDryRunDataClusterId"
:operation-dry-run-data="operationDryRunData"
:partition-data="operationData" />
<PartitionOperation
v-model:is-show="isShowOperation"
:data="operationData"
Expand All @@ -60,36 +55,47 @@
</div>
</template>
<script setup lang="tsx">
import _ from 'lodash';
import { ref, shallowRef } from 'vue';
import { useI18n } from 'vue-i18n';

import type PartitionModel from '@services/model/partition/partition';
import { batchRemove, disablePartition, dryRun, enablePartition, getList } from '@services/source/partitionManage';
import {
batchRemove,
disablePartition,
dryRun,
enablePartition,
execute,
getList,
} from '@services/source/partitionManage';

import { useTicketMessage } from '@hooks';

import { ClusterTypes } from '@common/const';
import { batchSplitRegex } from '@common/regex';

import { getSearchSelectorParams, messageSuccess } from '@utils';

import DryRun from './components/DryRun.vue';
import ExecuteLog from './components/ExecuteLog.vue';
import PartitionOperation from './components/Operation.vue';
import useTableSetting from './hooks/useTableSetting';

const { t } = useI18n();
type DryRunData = ServiceReturnType<typeof dryRun>;

const { t } = useI18n();
const ticketMessage = useTicketMessage();
const { handleChange: handleSettingChange, setting: tableSetting } = useTableSetting();

const tableRef = ref();
const searchValues = ref([]);
const isShowOperation = ref(false);
const isShowExecuteLog = ref(false);
const isShowDryRun = ref(false);
const executeLoadingMap = ref<Record<number, boolean>>({});
const selectionList = shallowRef<number[]>([]);
const operationData = shallowRef<PartitionModel>();
const operationDryRunDataClusterId = ref(0);
const operationDryRunData = shallowRef<ServiceReturnType<typeof dryRun>>();

const operationData = shallowRef<PartitionModel>();
const operationDryRunData = shallowRef<DryRunData>();
const selectionList = shallowRef<number[]>([]);

const serachData = [
{
Expand Down Expand Up @@ -400,9 +406,29 @@
};

// 执行
const handleExecute = (payload: PartitionModel) => {
isShowDryRun.value = true;
operationData.value = payload;
const handleExecute = async (data: PartitionModel) => {
executeLoadingMap.value[data.id] = true;
operationData.value = data;
try {
const dryRunResults = await dryRun({
cluster_id: data.cluster_id,
config_id: data.id,
});
const dryRunData = Object.keys(dryRunResults).reduce<DryRunData>(
(result, configId) =>
Object.assign(result, {
[configId]: _.filter(dryRunResults[Number(configId)], (item) => !item.message),
}),
{},
);
const executeResult = await execute({
cluster_id: data.cluster_id,
partition_objects: dryRunData,
});
ticketMessage(executeResult.map((item) => item.id).join(','));
} finally {
executeLoadingMap.value[data.id] = false;
}
};
// 编辑
const handleEdit = (payload: PartitionModel) => {
Expand All @@ -421,12 +447,16 @@
fetchData();
};
// 新建成功
const handleOperationCreateSuccess = (payload: ServiceReturnType<typeof dryRun>, clusterId: number) => {
const handleOperationCreateSuccess = async (payload: DryRunData, clusterId: number) => {
fetchData();
operationDryRunData.value = payload;
operationDryRunDataClusterId.value = clusterId;
operationData.value = undefined;
isShowDryRun.value = true;
const executeResult = await execute({
cluster_id: clusterId,
partition_objects: payload,
});
ticketMessage(executeResult.map((item) => item.id).join(','));
};

const handleDisable = (payload: PartitionModel) => {
Expand All @@ -450,8 +480,9 @@
};

const handleClone = (payload: PartitionModel) => {
operationData.value = payload;
operationData.value.id = 0;
const rowDataClone = _.cloneDeep(payload);
rowDataClone.id = 0;
operationData.value = rowDataClone;
isShowOperation.value = true;
};

Expand Down
Loading
Loading