Skip to content

Commit e7063f1

Browse files
3octavesygcyao
authored andcommitted
perf(frontend): redis工具箱重构 TencentBlueKing#8840
1 parent 3cf6ae5 commit e7063f1

File tree

77 files changed

+9690
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+9690
-480
lines changed

dbm-ui/frontend/src/components/instance-selector/components/redis/table/Index.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,13 @@
340340
if (activePanel?.value) {
341341
emits('change', {
342342
...props.lastValues,
343-
[activePanel.value]: Object.values(checkedMap.value).map((item) => ({
344-
...item,
345-
// 兼容历史遗留问题(对 bk_cloud_id, bk_cloud_name 的特殊处理)
346-
bk_cloud_id: item.host_info?.cloud_id || 0,
347-
bk_cloud_name: item.host_info?.cloud_area?.name || '--',
348-
})),
343+
[activePanel.value]: Object.values(checkedMap.value).map((item) =>
344+
Object.assign(item, {
345+
// 兼容历史遗留问题(对 bk_cloud_id, bk_cloud_name 的特殊处理)
346+
bk_cloud_id: item.host_info?.cloud_id || 0,
347+
bk_cloud_name: item.host_info?.cloud_area?.name || '--',
348+
}),
349+
),
349350
});
350351
}
351352
};

dbm-ui/frontend/src/services/model/redis/redis.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default class Redis extends ClusterBase {
5050
bk_biz_name: string;
5151
bk_cloud_id: number;
5252
bk_cloud_name: string;
53+
city: string;
5354
cluster_access_port: number;
5455
cluster_alias: string;
5556
cluster_capacity: number;
@@ -107,6 +108,7 @@ export default class Redis extends ClusterBase {
107108
this.bk_biz_id = payload.bk_biz_id;
108109
this.bk_biz_name = payload.bk_biz_name;
109110
this.bk_cloud_id = payload.bk_cloud_id;
111+
this.city = payload.city;
110112
this.bk_cloud_name = payload.bk_cloud_name;
111113
this.cluster_subzons = payload.cluster_subzons || [];
112114
this.cluster_access_port = payload.cluster_access_port;

dbm-ui/frontend/src/services/model/ticket/details/redis/clusterDataCopy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export interface ClusterDataCopy extends DetailBase {
88
};
99
dts_copy_type: 'copy_to_other_system' | 'diff_app_diff_cluster' | 'one_app_diff_cluster' | 'user_built_to_dbm';
1010
infos: {
11-
dst_bk_biz_id: number;
12-
dst_cluster: number;
11+
dst_bk_biz_id: number | string;
12+
dst_cluster: number | string;
1313
key_black_regex: string; // 排除key
1414
key_white_regex: string; // 包含key
15-
src_cluster: number;
15+
src_cluster: number | string;
1616
src_cluster_password: string;
1717
src_cluster_type: string;
1818
}[];

dbm-ui/frontend/src/services/model/ticket/details/redis/clusterShardNumUpdate.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import RedisModel from '@services/model/redis/redis';
2+
13
import { Affinity } from '@common/const';
24

35
import type { DetailBase, DetailClusters, DetailSpecs } from '../common';
@@ -11,11 +13,15 @@ export interface ClusterShardNumUpdate extends DetailBase {
1113
infos: {
1214
capacity: number;
1315
cluster_shard_num: number;
16+
cluster_spec?: RedisModel['cluster_spec']; // 展示字段,需兼容旧单据,下同
17+
cluster_stats?: RedisModel['cluster_stats']; // 展示字段
1418
current_shard_num: number;
1519
current_spec_id: string;
1620
db_version: string;
1721
future_capacity: number;
22+
machine_pair_cnt?: number; // 展示字段
1823
online_switch_type: 'user_confirm';
24+
proxy?: RedisModel['proxy']; // 展示字段
1925
resource_spec: {
2026
backend_group: {
2127
affinity: Affinity.CROS_SUBZONE;

dbm-ui/frontend/src/services/model/ticket/details/redis/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export * from './dataStructureTaskDelete';
1313
export * from './destroy';
1414
export * from './hotKeyAnalyse';
1515
export * from './insApply';
16+
export * from './installModule';
1617
export * from './instanceDestroy';
1718
export * from './instanceProxyClose';
1819
export * from './instanceProxyOpen';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { DetailBase, DetailClusters } from '../common';
2+
3+
export interface InstallModule extends DetailBase {
4+
bk_cloud_id: number;
5+
clusters: DetailClusters;
6+
infos: {
7+
cluster_id: number;
8+
db_version: string;
9+
load_modules: string[];
10+
}[];
11+
}

dbm-ui/frontend/src/services/source/redisDts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const getRootPath = () => `/apis/redis/bizs/${window.PROJECT_CONFIG.BIZ_ID}/dts`
2222
export function getRedisDTSHistoryJobs(params: {
2323
cluster_name?: string;
2424
end_time?: string;
25+
id?: number;
2526
page?: number;
2627
page_size?: number;
2728
start_time?: string;
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
<template>
2+
<div
3+
ref="rootRef"
4+
v-bind="$attrs"
5+
@click.stop="">
6+
<BkButton
7+
v-bk-tooltips="t('统一设置:将该列统一设置为相同的值')"
8+
text
9+
theme="primary"
10+
@click="handleShow">
11+
<DbIcon type="bulk-edit" />
12+
</BkButton>
13+
</div>
14+
<div style="display: none">
15+
<div
16+
ref="popRef"
17+
class="batch-edit-column-select-new">
18+
<div class="main-title">{{ t('统一设置') }}{{ label }}</div>
19+
<div
20+
v-if="mode === 'default'"
21+
class="title-spot mb-6"
22+
style="font-weight: normal">
23+
<span>{{ label }}</span> <span class="required" />
24+
</div>
25+
<slot />
26+
<div class="footer-box">
27+
<BkButton
28+
size="small"
29+
style="margin-left: auto"
30+
theme="primary"
31+
@click="handleConfirm">
32+
{{ t('确认') }}
33+
</BkButton>
34+
<BkButton
35+
class="ml-8"
36+
size="small"
37+
@click="handleCancel">
38+
{{ t('取消') }}
39+
</BkButton>
40+
</div>
41+
</div>
42+
</div>
43+
</template>
44+
45+
<script lang="ts">
46+
import tippy, { type Instance, type Props as TippyProps, type SingleTarget } from 'tippy.js';
47+
import { useI18n } from 'vue-i18n';
48+
49+
// import BatchEditDatePick from './edit/DatePicker.vue';
50+
// import BatchEditInput from './edit/Input.vue';
51+
import BatchEditNumberInput from './edit/NumberInput.vue';
52+
import BatchEditSelect from './edit/Select.vue';
53+
import BatchEditTagInput from './edit/TagInput.vue';
54+
// import BatchEditTextarea from './edit/Textarea.vue';
55+
56+
interface Props {
57+
cancelHandler?: () => Promise<any> | void;
58+
confirmHandler: () => Promise<any> | void;
59+
label: string;
60+
mode?: 'default' | 'custom';
61+
}
62+
63+
let tippyInstance: Instance | undefined;
64+
65+
const createTippy = (target: SingleTarget, options: TippyProps) => {
66+
if (!tippyInstance) {
67+
tippyInstance = tippy(target, options);
68+
}
69+
};
70+
export {
71+
// BatchEditDatePick,
72+
// BatchEditInput,
73+
BatchEditNumberInput,
74+
BatchEditSelect,
75+
BatchEditTagInput,
76+
// BatchEditTextarea,
77+
};
78+
</script>
79+
<script setup lang="ts">
80+
const props = withDefaults(defineProps<Props>(), {
81+
cancelHandler: () => Promise.resolve(),
82+
mode: 'default',
83+
});
84+
85+
const { t } = useI18n();
86+
87+
const rootRef = useTemplateRef('rootRef');
88+
const popRef = useTemplateRef('popRef');
89+
90+
const getTippyOptions = (): TippyProps => ({
91+
appendTo: () => document.body,
92+
arrow: true,
93+
content: popRef.value,
94+
hideOnClick: false,
95+
interactive: true,
96+
maxWidth: 'none',
97+
offset: [0, 12],
98+
placement: 'top-start',
99+
popperOptions: {
100+
modifiers: [
101+
{
102+
name: 'flip',
103+
options: {
104+
allowedAutoPlacements: ['top-start', 'top-end'],
105+
fallbackPlacements: ['top', 'bottom'],
106+
},
107+
},
108+
],
109+
strategy: 'fixed',
110+
},
111+
theme: 'light batch-edit-column-theme',
112+
trigger: 'click',
113+
zIndex: 999,
114+
});
115+
116+
const handleShow = () => {
117+
destroyTippy();
118+
const tippyTarget = rootRef.value!.children[0];
119+
if (tippyTarget) {
120+
createTippy(tippyTarget as SingleTarget, getTippyOptions());
121+
tippyInstance!.show();
122+
}
123+
};
124+
125+
const handleConfirm = () => {
126+
// tag-input 组件内为200ms后失焦处理失焦的回调,这里将任务添加至失焦回调后,以获取最新值
127+
setTimeout(() => {
128+
Promise.resolve()
129+
.then(() => props.confirmHandler())
130+
.then(() => {
131+
tippyInstance!.hide();
132+
});
133+
}, 210);
134+
};
135+
136+
const handleCancel = () => {
137+
Promise.resolve()
138+
.then(() => props.cancelHandler())
139+
.then(() => {
140+
tippyInstance!.hide();
141+
});
142+
};
143+
144+
const destroyTippy = () => {
145+
if (tippyInstance) {
146+
tippyInstance.hide();
147+
tippyInstance.unmount();
148+
tippyInstance.destroy();
149+
tippyInstance = undefined;
150+
}
151+
};
152+
153+
onBeforeUnmount(() => {
154+
destroyTippy();
155+
});
156+
</script>
157+
158+
<style lang="less">
159+
.batch-edit-column-select-new {
160+
width: 395px;
161+
162+
.main-title {
163+
margin-bottom: 20px;
164+
font-size: 16px;
165+
color: #313238;
166+
}
167+
168+
.footer-box {
169+
margin-top: 30px;
170+
text-align: end;
171+
172+
button {
173+
width: 60px;
174+
}
175+
}
176+
}
177+
178+
.tippy-box[data-theme~='batch-edit-column-theme'] {
179+
padding: 16px;
180+
background-color: #fff;
181+
border: 1px solid #dcdee5 !important;
182+
border-radius: 4px !important;
183+
box-shadow: 0 0 6px 0 #dcdee5 !important;
184+
185+
.tippy-content {
186+
padding: 0;
187+
background-color: #fff;
188+
}
189+
}
190+
</style>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<template>
2+
<BkDatePicker
3+
v-model="modelValue"
4+
v-bind="attrs"
5+
:clearable="false"
6+
style="width: 100%"
7+
type="datetime" />
8+
</template>
9+
10+
<script setup lang="ts" generic="T extends [string, string] | [Date, Date] | string | Date">
11+
const modelValue = defineModel<T>();
12+
13+
const attrs = useAttrs();
14+
</script>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<BkInput
3+
v-bind="attrs"
4+
ref="inputRef"
5+
v-model="modelValue"
6+
clearable />
7+
</template>
8+
<script setup lang="ts">
9+
const modelValue = defineModel<string>();
10+
11+
const attrs = useAttrs();
12+
</script>

0 commit comments

Comments
 (0)