Skip to content

Commit

Permalink
feat(frontend): 支持故障池、待回收池 #7881
Browse files Browse the repository at this point in the history
  • Loading branch information
royalpioneer authored and iSecloud committed Nov 27, 2024
1 parent 5bc7744 commit f452854
Show file tree
Hide file tree
Showing 29 changed files with 1,490 additions and 64 deletions.
20 changes: 16 additions & 4 deletions dbm-ui/frontend/src/components/db-popconfirm/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@
</div>
<div
ref="popRef"
style="width: 280px; padding: 15px 10px">
:style="contentStyle">
<div style="font-size: 16px; line-height: 20px; color: #313238">
{{ title }}
</div>
<div style="margin-top: 10px; font-size: 12px; color: #63656e">
{{ content }}
<slot name="content">
{{ content }}
</slot>
</div>
<div style="margin-top: 16px; text-align: right">
<BkButton
class="mr8"
:loading="isConfirmLoading"
size="small"
theme="primary"
:theme="theme"
@click="handleConfirm">
{{ $t('确认') }}
</BkButton>
Expand All @@ -51,15 +53,20 @@

interface Props {
title: string;
content: string;
content?: string;
placement?: Placement;
width?: number;
confirmHandler: () => Promise<any> | void;
cancelHandler?: () => Promise<any> | void;
theme?: 'primary' | 'danger';
}

const props = withDefaults(defineProps<Props>(), {
placement: 'top',
content: '',
width: 280,
cancelHandler: () => Promise.resolve(),
theme: 'primary',
});

defineOptions({
Expand All @@ -72,6 +79,11 @@
const popRef = ref();
const isConfirmLoading = ref(false);

const contentStyle = computed(() => ({
width: `${props.width}px`,
padding: '15px 10px',
}));

const handleConfirm = () => {
isConfirmLoading.value = true;
Promise.resolve()
Expand Down
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/components/db-table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@
getAllData: fetchAllData,
// 清空选择
clearSelected() {
// bkTableRef.value?.clearSelection();
handleClearWholeSelect();
rowSelectMemo.value = {};
bkTableRef.value?.clearSelection();
},
updateTableKey() {
tableKey.value = Date.now().toString();
Expand Down
24 changes: 24 additions & 0 deletions dbm-ui/frontend/src/layout/components/ResourceManage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@
{{ t('DB 资源池管理') }}
</span>
</BkMenuItem>
<BkMenuItem
key="toRecyclePool"
v-db-console="'resourceManage.toRecyclePool'">
<template #icon>
<DbIcon type="daihuishou" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('待回收池') }}
</span>
</BkMenuItem>
<BkMenuItem
key="faultPool"
v-db-console="'resourceManage.faultPool'">
<template #icon>
<DbIcon type="guzhangji" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('故障池') }}
</span>
</BkMenuItem>
<BkMenuItem
key="resourcePoolDirtyMachines"
v-db-console="'resourceManage.dirtyHostManage'">
Expand Down
18 changes: 18 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3705,5 +3705,23 @@
"确认批量将 {n} 台主机转入业务资源池?": "确认批量将 {n} 台主机转入业务资源池?",
"确认转入待故障池?": "确认转入待故障池?",
"跳转管理页": "跳转管理页",
"确认批量回收 {n} 台主机?": "确认批量回收 {n} 台主机?",
"回收": "回收",
"导入资源池": "导入资源池",
"确认回收该机器?": "确认回收该机器?",
"待回收池": "待回收池",
"故障池": "故障池",
"磁盘总容量(G)": "磁盘总容量(G)",
"确认后,主机将从系统中删除": "确认后,主机将从系统中删除",
"批量导入资源池": "批量导入资源池",
"批量回收": "批量回收",
"故障资源池": "故障资源池",
"确认后,主机将从系统中删除,请谨慎操作!": "确认后,主机将从系统中删除,请谨慎操作!",
"确认批量将 {n} 台主机转入待回收池?": "确认批量将 {n} 台主机转入待回收池?",
"批量转入回收池": "批量转入回收池",
"转入回收池": "转入回收池",
"新建标签": "新建标签",
"所有 IP": "所有 IP",
"已选 IP": "已选 IP",
"这行勿动!新增翻译请在上一行添加!": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.
*/
export default class FaultOrRecycleMachine {
agent_status: number;
bk_biz_id: number;
bk_cloud_id: number;
bk_cpu: number;
bk_disk: number;
bk_host_id: number;
bk_mem: number;
city: string;
create_at: string;
creator: string;
device_class: string;
ip: string;
os_name: string;
pool: string;
rack_id: string;
sub_zone: string;
ticket: string;
update_at: string;
updater: string;

constructor(payload = {} as FaultOrRecycleMachine) {
this.agent_status = payload.agent_status;
this.bk_biz_id = payload.bk_biz_id;
this.bk_cloud_id = payload.bk_cloud_id;
this.bk_cpu = payload.bk_cpu;
this.bk_disk = payload.bk_disk;
this.bk_host_id = payload.bk_host_id;
this.bk_mem = payload.bk_mem;
this.city = payload.city;
this.create_at = payload.create_at;
this.creator = payload.creator;
this.device_class = payload.device_class;
this.ip = payload.ip;
this.os_name = payload.os_name;
this.pool = payload.pool;
this.rack_id = payload.rack_id;
this.sub_zone = payload.sub_zone;
this.ticket = payload.ticket;
this.update_at = payload.update_at;
this.updater = payload.updater;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export default class FunctionController {
resourceManage: ControllerItem<string>;
'resourceManage.resourceSpec': ControllerItem<string>;
'resourceManage.resourcePool': ControllerItem<string>;
'resourceManage.faultPool': ControllerItem<string>;
'resourceManage.toRecyclePool': ControllerItem<string>;
'resourceManage.dirtyHostManage': ControllerItem<string>;
'resourceManage.resourceOperationRecord': ControllerItem<string>;
bizConfigManage: ControllerItem<string>;
Expand Down
22 changes: 22 additions & 0 deletions dbm-ui/frontend/src/services/source/dbdirty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

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

import http from '../http';
Expand Down Expand Up @@ -52,3 +53,24 @@ export function transferDirtyMachines(params: { bk_host_ids: number[] }) {
export function deleteDirtyRecords(params: { bk_host_ids: number[] }) {
return http.delete(`${path}/delete_dirty_records/`, params);
}

/**
* 故障池、待回收池列表
*/
export function getMachinePool(params: { limit?: number; offset?: number; ips?: string; pool: 'fault' | 'recycle' }) {
return http.get<ListBase<FaultOrRecycleMachineModel[]>>(`${path}/query_machine_pool/`, params).then((res) => ({
...res,
results: res.results.map((item: FaultOrRecycleMachineModel) => new FaultOrRecycleMachineModel(item)),
}));
}

/**
* 将主机转移至待回收/故障池模块
*/
export function transferMachinePool(params: {
bk_host_ids: number[];
source: 'fault' | 'recycle';
target: 'fault' | 'recycle' | 'recycled';
}) {
return http.post(`${path}/transfer_hosts_to_pool/`, params);
}
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/services/source/dbresourceResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function importResource(params: {
host_id: number;
bk_cloud_id: number;
}>;
labels: number;
labels: number[];
}) {
return http.post(`${path}/import/`, params);
}
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/services/source/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function listTag(params: {
bk_biz_id?: number;
limit?: number;
offset?: number;
ordering?: string;
}) {
return http.get<ListBase<ResourceTagModel[]>>(`${path}`, params).then((res) => ({
...res,
Expand Down
Loading

0 comments on commit f452854

Please sign in to comment.