Skip to content

Commit 071818d

Browse files
royalpioneeriSecloud
authored andcommitted
feat(frontend): 支持故障池、待回收池 #7881
1 parent 0b8364f commit 071818d

File tree

29 files changed

+1490
-64
lines changed

29 files changed

+1490
-64
lines changed

dbm-ui/frontend/src/components/db-popconfirm/index.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@
2121
</div>
2222
<div
2323
ref="popRef"
24-
style="width: 280px; padding: 15px 10px">
24+
:style="contentStyle">
2525
<div style="font-size: 16px; line-height: 20px; color: #313238">
2626
{{ title }}
2727
</div>
2828
<div style="margin-top: 10px; font-size: 12px; color: #63656e">
29-
{{ content }}
29+
<slot name="content">
30+
{{ content }}
31+
</slot>
3032
</div>
3133
<div style="margin-top: 16px; text-align: right">
3234
<BkButton
3335
class="mr8"
3436
:loading="isConfirmLoading"
3537
size="small"
36-
theme="primary"
38+
:theme="theme"
3739
@click="handleConfirm">
3840
{{ $t('确认') }}
3941
</BkButton>
@@ -51,15 +53,20 @@
5153
5254
interface Props {
5355
title: string;
54-
content: string;
56+
content?: string;
5557
placement?: Placement;
58+
width?: number;
5659
confirmHandler: () => Promise<any> | void;
5760
cancelHandler?: () => Promise<any> | void;
61+
theme?: 'primary' | 'danger';
5862
}
5963
6064
const props = withDefaults(defineProps<Props>(), {
6165
placement: 'top',
66+
content: '',
67+
width: 280,
6268
cancelHandler: () => Promise.resolve(),
69+
theme: 'primary',
6370
});
6471
6572
defineOptions({
@@ -72,6 +79,11 @@
7279
const popRef = ref();
7380
const isConfirmLoading = ref(false);
7481
82+
const contentStyle = computed(() => ({
83+
width: `${props.width}px`,
84+
padding: '15px 10px',
85+
}));
86+
7587
const handleConfirm = () => {
7688
isConfirmLoading.value = true;
7789
Promise.resolve()

dbm-ui/frontend/src/components/db-table/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@
606606
getAllData: fetchAllData,
607607
// 清空选择
608608
clearSelected() {
609-
// bkTableRef.value?.clearSelection();
610-
handleClearWholeSelect();
609+
rowSelectMemo.value = {};
610+
bkTableRef.value?.clearSelection();
611611
},
612612
updateTableKey() {
613613
tableKey.value = Date.now().toString();

dbm-ui/frontend/src/layout/components/ResourceManage.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@
2929
{{ t('DB 资源池管理') }}
3030
</span>
3131
</BkMenuItem>
32+
<BkMenuItem
33+
key="toRecyclePool"
34+
v-db-console="'resourceManage.toRecyclePool'">
35+
<template #icon>
36+
<DbIcon type="daihuishou" />
37+
</template>
38+
<span
39+
v-overflow-tips.right
40+
class="text-overflow">
41+
{{ t('待回收池') }}
42+
</span>
43+
</BkMenuItem>
44+
<BkMenuItem
45+
key="faultPool"
46+
v-db-console="'resourceManage.faultPool'">
47+
<template #icon>
48+
<DbIcon type="guzhangji" />
49+
</template>
50+
<span
51+
v-overflow-tips.right
52+
class="text-overflow">
53+
{{ t('故障池') }}
54+
</span>
55+
</BkMenuItem>
3256
<BkMenuItem
3357
key="resourcePoolDirtyMachines"
3458
v-db-console="'resourceManage.dirtyHostManage'">

dbm-ui/frontend/src/locales/zh-cn.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,5 +3705,23 @@
37053705
"确认批量将 {n} 台主机转入业务资源池?": "确认批量将 {n} 台主机转入业务资源池?",
37063706
"确认转入待故障池?": "确认转入待故障池?",
37073707
"跳转管理页": "跳转管理页",
3708+
"确认批量回收 {n} 台主机?": "确认批量回收 {n} 台主机?",
3709+
"回收": "回收",
3710+
"导入资源池": "导入资源池",
3711+
"确认回收该机器?": "确认回收该机器?",
3712+
"待回收池": "待回收池",
3713+
"故障池": "故障池",
3714+
"磁盘总容量(G)": "磁盘总容量(G)",
3715+
"确认后,主机将从系统中删除": "确认后,主机将从系统中删除",
3716+
"批量导入资源池": "批量导入资源池",
3717+
"批量回收": "批量回收",
3718+
"故障资源池": "故障资源池",
3719+
"确认后,主机将从系统中删除,请谨慎操作!": "确认后,主机将从系统中删除,请谨慎操作!",
3720+
"确认批量将 {n} 台主机转入待回收池?": "确认批量将 {n} 台主机转入待回收池?",
3721+
"批量转入回收池": "批量转入回收池",
3722+
"转入回收池": "转入回收池",
3723+
"新建标签": "新建标签",
3724+
"所有 IP": "所有 IP",
3725+
"已选 IP": "已选 IP",
37083726
"这行勿动!新增翻译请在上一行添加!": ""
37093727
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
3+
*
4+
* Copyright (C) 2017-2023 THL A29 Limited; a Tencent company. All rights reserved.
5+
*
6+
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at https://opensource.org/licenses/MIT
8+
*
9+
* Unless required by applicable law or agreed to in writing; software distributed under the License is distributed
10+
* on an "AS IS" BASIS; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND; either express or implied. See the License for
11+
* the specific language governing permissions and limitations under the License.
12+
*/
13+
export default class FaultOrRecycleMachine {
14+
agent_status: number;
15+
bk_biz_id: number;
16+
bk_cloud_id: number;
17+
bk_cpu: number;
18+
bk_disk: number;
19+
bk_host_id: number;
20+
bk_mem: number;
21+
city: string;
22+
create_at: string;
23+
creator: string;
24+
device_class: string;
25+
ip: string;
26+
os_name: string;
27+
pool: string;
28+
rack_id: string;
29+
sub_zone: string;
30+
ticket: string;
31+
update_at: string;
32+
updater: string;
33+
34+
constructor(payload = {} as FaultOrRecycleMachine) {
35+
this.agent_status = payload.agent_status;
36+
this.bk_biz_id = payload.bk_biz_id;
37+
this.bk_cloud_id = payload.bk_cloud_id;
38+
this.bk_cpu = payload.bk_cpu;
39+
this.bk_disk = payload.bk_disk;
40+
this.bk_host_id = payload.bk_host_id;
41+
this.bk_mem = payload.bk_mem;
42+
this.city = payload.city;
43+
this.create_at = payload.create_at;
44+
this.creator = payload.creator;
45+
this.device_class = payload.device_class;
46+
this.ip = payload.ip;
47+
this.os_name = payload.os_name;
48+
this.pool = payload.pool;
49+
this.rack_id = payload.rack_id;
50+
this.sub_zone = payload.sub_zone;
51+
this.ticket = payload.ticket;
52+
this.update_at = payload.update_at;
53+
this.updater = payload.updater;
54+
}
55+
}

dbm-ui/frontend/src/services/model/function-controller/functionController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ export default class FunctionController {
214214
resourceManage: ControllerItem<string>;
215215
'resourceManage.resourceSpec': ControllerItem<string>;
216216
'resourceManage.resourcePool': ControllerItem<string>;
217+
'resourceManage.faultPool': ControllerItem<string>;
218+
'resourceManage.toRecyclePool': ControllerItem<string>;
217219
'resourceManage.dirtyHostManage': ControllerItem<string>;
218220
'resourceManage.resourceOperationRecord': ControllerItem<string>;
219221
bizConfigManage: ControllerItem<string>;

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
import DirtyMachinesModel from '@services/model/db-resource/dirtyMachines';
15+
import FaultOrRecycleMachineModel from '@services/model/db-resource/FaultOrRecycleMachine';
1516
import type { ListBase } from '@services/types';
1617

1718
import http from '../http';
@@ -52,3 +53,24 @@ export function transferDirtyMachines(params: { bk_host_ids: number[] }) {
5253
export function deleteDirtyRecords(params: { bk_host_ids: number[] }) {
5354
return http.delete(`${path}/delete_dirty_records/`, params);
5455
}
56+
57+
/**
58+
* 故障池、待回收池列表
59+
*/
60+
export function getMachinePool(params: { limit?: number; offset?: number; ips?: string; pool: 'fault' | 'recycle' }) {
61+
return http.get<ListBase<FaultOrRecycleMachineModel[]>>(`${path}/query_machine_pool/`, params).then((res) => ({
62+
...res,
63+
results: res.results.map((item: FaultOrRecycleMachineModel) => new FaultOrRecycleMachineModel(item)),
64+
}));
65+
}
66+
67+
/**
68+
* 将主机转移至待回收/故障池模块
69+
*/
70+
export function transferMachinePool(params: {
71+
bk_host_ids: number[];
72+
source: 'fault' | 'recycle';
73+
target: 'fault' | 'recycle' | 'recycled';
74+
}) {
75+
return http.post(`${path}/transfer_hosts_to_pool/`, params);
76+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function importResource(params: {
7171
host_id: number;
7272
bk_cloud_id: number;
7373
}>;
74-
labels: number;
74+
labels: number[];
7575
}) {
7676
return http.post(`${path}/import/`, params);
7777
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function listTag(params: {
1515
bk_biz_id?: number;
1616
limit?: number;
1717
offset?: number;
18+
ordering?: string;
1819
}) {
1920
return http.get<ListBase<ResourceTagModel[]>>(`${path}`, params).then((res) => ({
2021
...res,

0 commit comments

Comments
 (0)