Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): mongo这里的变更脚本执行提供下载地址 #8771
Browse files Browse the repository at this point in the history
hLinx committed Dec 26, 2024
1 parent a72fa96 commit ed89283
Showing 13 changed files with 467 additions and 600 deletions.
27 changes: 7 additions & 20 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
@@ -3864,26 +3864,13 @@
"后端存储规格:": "后端存储规格:",
"SQLServer起始端口:": "SQLServer起始端口:",
"高可用部署": "高可用部署",
"迁移提交成功": "迁移提交成功",
"集群架构:将集群的部分实例迁移到新机器,迁移保持规格、版本不变;主从架构:主从实例成对迁移到新机器上,可选择部分实例迁移,也可整机所有实例一起迁移。": "集群架构:将集群的部分实例迁移到新机器,迁移保持规格、版本不变;主从架构:主从实例成对迁移到新机器上,可选择部分实例迁移,也可整机所有实例一起迁移。",
"迁移": "迁移",
"实例迁移": "实例迁移",
"如 TendisCache 等,迁移过程保持规格、版本不变": "如 TendisCache 等,迁移过程保持规格、版本不变",
"支持部分或整机所有实例成对迁移至新主机,版本规格可变": "支持部分或整机所有实例成对迁移至新主机,版本规格可变",
"主从架构": "主从架构",
"只迁移目标实例": "只迁移目标实例",
"主机关联的所有实例一并迁移": "主机关联的所有实例一并迁移",
"整机迁移": "整机迁移",
"目标 Master 实例": "目标 Master 实例",
"实例选择": "实例选择",
"目标 Master 主机": "目标 Master 主机",
"关联的实例": "关联的实例",
"关联的主从实例": "关联的主从实例",
"目标实例输入格式有误": "目标实例输入格式有误",
"目标实例重复": "目标实例重复",
"Master 实例": "Master 实例",
"请先选择主机": "请先选择主机",
"集群或实例状态异常,不可选择": "集群或实例状态异常,不可选择",
"目标集群:": "目标集群:",
"目标 DB:": "目标 DB:",
"目标表名:": "目标表名:",
"where 条件:": "where 条件:",
"导出数据:": "导出数据:",
"脚本来源:": "脚本来源:",
"脚本执行内容:": "脚本执行内容:",
"这行勿动!新增翻译请在上一行添加!": ""

}
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/utils/downloadUrl.ts
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ export const downloadUrl = (url: string) => {
const eleLink = document.createElement('a');
eleLink.style.display = 'none';
eleLink.href = url;
eleLink.target = '_blank';

// 触发点击
document.body.appendChild(eleLink);
Original file line number Diff line number Diff line change
@@ -60,7 +60,6 @@
:data="state.data"
:height="460"
:is-anomalies="isAnomalies"
:row-height="56"
@refresh="fetchKeyFiles"
@selection-change="handleTableSelected">
<BkTableColumn
Original file line number Diff line number Diff line change
@@ -19,11 +19,17 @@
keypath="m_耗时_t"
scope="global">
<span style="color: #ea3636">{{ t('执行失败') }}</span>

<CostTimer
:is-timing="false"
:start-time="utcTimeToSeconds(data.start_time)"
:value="data.cost_time" />
</I18nT>
<template v-if="ticketDetail.ticket_type === TicketTypes.MONGODB_EXEC_SCRIPT_APPLY">
<span> ,</span>
<!-- prettier-ignore -->
<MongodbExecScriptDownloadFile :details="(data.details as ComponentProps<typeof MongodbExecScriptDownloadFile>['details'])" />
</template>
<template v-if="data.url">
<span> ,</span>
<a
@@ -58,13 +64,16 @@
</StatusFailed>
</template>
<script setup lang="ts">
import type { ComponentProps } from 'vue-component-type-helpers';
import { useI18n } from 'vue-i18n';
import FlowMode from '@services/model/ticket/flow';
import TicketModel from '@services/model/ticket/ticket';
import { useUserProfile } from '@stores';
import { TicketTypes } from '@common/const';
import CostTimer from '@components/cost-timer/CostTimer.vue';
import ProcessFailedTerminate from '@views/ticket-center/common/action-confirm/ProcessFailedTerminate.vue';
@@ -74,6 +83,8 @@
import StatusFailed from '../flow-type-common/StatusFailed.vue';
import MongodbExecScriptDownloadFile from './components/MongodbExecScriptDownloadFile.vue';
interface Props {
data: FlowMode;
ticketDetail: TicketModel<unknown>;
Original file line number Diff line number Diff line change
@@ -14,11 +14,17 @@
:start-time="utcTimeToSeconds(data.start_time)"
:value="data.cost_time" />
</I18nT>
<template v-if="ticketDetail.ticket_type === TicketTypes.MONGODB_EXEC_SCRIPT_APPLY">
<span> ,</span>
<!-- prettier-ignore -->
<MongodbExecScriptDownloadFile :details="(data.details as ComponentProps<typeof MongodbExecScriptDownloadFile>['details'])" />
</template>
<template v-if="ticketDetail.ticket_type === TicketTypes.REDIS_KEYS_EXTRACT">
<span> ,</span>
<FlowRedisKeyExtract :id="data.flow_obj_id" />
<RedisKeysExtractFile :id="data.flow_obj_id" />
</template>
<template v-if="ticketDetail.ticket_type === TicketTypes.MYSQL_DUMP_DATA">
<template
v-if="[TicketTypes.MYSQL_DUMP_DATA, TicketTypes.TENDBCLUSTER_DUMP_DATA].includes(ticketDetail.ticket_type)">
<span> ,</span>
<!-- prettier-ignore -->
<MysqlDumpDataDownload :details="(data.details as ComponentProps<typeof MysqlDumpDataDownload>['details'])" />
@@ -48,13 +54,13 @@
import CostTimer from '@components/cost-timer/CostTimer.vue';
import FlowRedisKeyExtract from '@views/db-manage/common/FlowRedisKeyExtract.vue';
import { utcTimeToSeconds } from '@utils';
import DbTimeLineItem from '../time-line/TimeLineItem.vue';
import MongodbExecScriptDownloadFile from './components/MongodbExecScriptDownloadFile.vue';
import MysqlDumpDataDownload from './components/MysqlDumpDataDownload.vue';
import RedisKeysExtractFile from './components/RedisKeysExtractFile.vue';
interface Props {
data: FlowMode<unknown>;
Original file line number Diff line number Diff line change
@@ -10,6 +10,11 @@
:start-time="utcTimeToSeconds(data.start_time)"
:value="data.cost_time" />
</I18nT>
<template v-if="ticketDetail.ticket_type === TicketTypes.MONGODB_EXEC_SCRIPT_APPLY">
<span> ,</span>
<!-- prettier-ignore -->
<MongodbExecScriptDownloadFile :details="(data.details as ComponentProps<typeof MongodbExecScriptDownloadFile>['details'])" />
</template>
<template v-if="data.url">
<span> ,</span>
<a
@@ -22,18 +27,25 @@
</StatusTerminated>
</template>
<script setup lang="ts">
import type { ComponentProps } from 'vue-component-type-helpers';
import { useI18n } from 'vue-i18n';
import FlowMode from '@services/model/ticket/flow';
import TicketModel from '@services/model/ticket/ticket';
import { TicketTypes } from '@common/const';
import CostTimer from '@components/cost-timer/CostTimer.vue';
import { utcTimeToSeconds } from '@utils';
import StatusTerminated from '../flow-type-common/StatusTerminated.vue';
import MongodbExecScriptDownloadFile from './components/MongodbExecScriptDownloadFile.vue';
interface Props {
data: FlowMode;
ticketDetail: TicketModel<unknown>;
}
defineProps<Props>();
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<BkButton
text
theme="primary"
@click="handleShowFile">
{{ t('查看结果文件') }}
</BkButton>
<BkDialog
v-model:is-show="isShow"
:title="t('查看结果文件')"
:width="1140">
<BkTable
:data="details.ticket_data.rules"
:height="460">
<BkTableColumn
field="path"
:label="t('路径')" />
<BkTableColumn
:label="t('操作')"
:width="100">
<template #default="{ data: rowData }: { data: Props['details']['ticket_data']['rules'][number] }">
<BkButton
text
theme="primary"
@click="handleDownloadFile(rowData.path)">
{{ t('下载') }}
</BkButton>
</template>
</BkTableColumn>
</BkTable>
<template #footer>
<BkButton @click="handleClose">{{ t('关闭') }}</BkButton>
</template>
</BkDialog>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { createBkrepoAccessToken } from '@services/source/storage';
import { downloadUrl, generateBkRepoDownloadUrl } from '@utils';
interface Props {
details: {
ticket_data: {
rules: {
cluster_id: number;
path: string;
}[];
};
};
}
defineProps<Props>();
const { t } = useI18n();
const isShow = ref(false);
const handleShowFile = () => {
isShow.value = true;
};
const handleDownloadFile = (path: string) => {
createBkrepoAccessToken({ file_path: path }).then((tokenResult) => {
const url = generateBkRepoDownloadUrl(tokenResult);
downloadUrl(url);
});
};
const handleClose = () => {
isShow.value = false;
};
</script>
Loading

0 comments on commit ed89283

Please sign in to comment.