diff --git a/dbm-ui/frontend/src/components/db-popconfirm/index.vue b/dbm-ui/frontend/src/components/db-popconfirm/index.vue index 2b645a42aa..643678f48b 100644 --- a/dbm-ui/frontend/src/components/db-popconfirm/index.vue +++ b/dbm-ui/frontend/src/components/db-popconfirm/index.vue @@ -21,19 +21,21 @@
+ :style="contentStyle">
{{ title }}
- {{ content }} + + {{ content }} +
{{ $t('确认') }} @@ -51,15 +53,20 @@ interface Props { title: string; - content: string; + content?: string; placement?: Placement; + width?: number; confirmHandler: () => Promise | void; cancelHandler?: () => Promise | void; + theme?: 'primary' | 'danger'; } const props = withDefaults(defineProps(), { placement: 'top', + content: '', + width: 280, cancelHandler: () => Promise.resolve(), + theme: 'primary', }); defineOptions({ @@ -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() diff --git a/dbm-ui/frontend/src/components/db-table/index.vue b/dbm-ui/frontend/src/components/db-table/index.vue index c95ca7b674..e305f69617 100644 --- a/dbm-ui/frontend/src/components/db-table/index.vue +++ b/dbm-ui/frontend/src/components/db-table/index.vue @@ -606,8 +606,8 @@ getAllData: fetchAllData, // 清空选择 clearSelected() { - // bkTableRef.value?.clearSelection(); - handleClearWholeSelect(); + rowSelectMemo.value = {}; + bkTableRef.value?.clearSelection(); }, updateTableKey() { tableKey.value = Date.now().toString(); diff --git a/dbm-ui/frontend/src/layout/components/ResourceManage.vue b/dbm-ui/frontend/src/layout/components/ResourceManage.vue index 90efa287e7..e5fbc94aa3 100644 --- a/dbm-ui/frontend/src/layout/components/ResourceManage.vue +++ b/dbm-ui/frontend/src/layout/components/ResourceManage.vue @@ -29,6 +29,30 @@ {{ t('DB 资源池管理') }} + + + + {{ t('待回收池') }} + + + + + + {{ t('故障池') }} + + diff --git a/dbm-ui/frontend/src/locales/zh-cn.json b/dbm-ui/frontend/src/locales/zh-cn.json index e3afefcf5c..43559a4aff 100644 --- a/dbm-ui/frontend/src/locales/zh-cn.json +++ b/dbm-ui/frontend/src/locales/zh-cn.json @@ -3705,5 +3705,23 @@ "确认批量将 {n} 台主机转入业务资源池?": "确认批量将 {n} 台主机转入业务资源池?", "确认转入待故障池?": "确认转入待故障池?", "跳转管理页": "跳转管理页", + "确认批量回收 {n} 台主机?": "确认批量回收 {n} 台主机?", + "回收": "回收", + "导入资源池": "导入资源池", + "确认回收该机器?": "确认回收该机器?", + "待回收池": "待回收池", + "故障池": "故障池", + "磁盘总容量(G)": "磁盘总容量(G)", + "确认后,主机将从系统中删除": "确认后,主机将从系统中删除", + "批量导入资源池": "批量导入资源池", + "批量回收": "批量回收", + "故障资源池": "故障资源池", + "确认后,主机将从系统中删除,请谨慎操作!": "确认后,主机将从系统中删除,请谨慎操作!", + "确认批量将 {n} 台主机转入待回收池?": "确认批量将 {n} 台主机转入待回收池?", + "批量转入回收池": "批量转入回收池", + "转入回收池": "转入回收池", + "新建标签": "新建标签", + "所有 IP": "所有 IP", + "已选 IP": "已选 IP", "这行勿动!新增翻译请在上一行添加!": "" } diff --git a/dbm-ui/frontend/src/services/model/db-resource/FaultOrRecycleMachine.ts b/dbm-ui/frontend/src/services/model/db-resource/FaultOrRecycleMachine.ts new file mode 100644 index 0000000000..3d1d32b51e --- /dev/null +++ b/dbm-ui/frontend/src/services/model/db-resource/FaultOrRecycleMachine.ts @@ -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; + } +} diff --git a/dbm-ui/frontend/src/services/model/function-controller/functionController.ts b/dbm-ui/frontend/src/services/model/function-controller/functionController.ts index fa854d06f7..4122f9f843 100644 --- a/dbm-ui/frontend/src/services/model/function-controller/functionController.ts +++ b/dbm-ui/frontend/src/services/model/function-controller/functionController.ts @@ -214,6 +214,8 @@ export default class FunctionController { resourceManage: ControllerItem; 'resourceManage.resourceSpec': ControllerItem; 'resourceManage.resourcePool': ControllerItem; + 'resourceManage.faultPool': ControllerItem; + 'resourceManage.toRecyclePool': ControllerItem; 'resourceManage.dirtyHostManage': ControllerItem; 'resourceManage.resourceOperationRecord': ControllerItem; bizConfigManage: ControllerItem; diff --git a/dbm-ui/frontend/src/services/source/dbdirty.ts b/dbm-ui/frontend/src/services/source/dbdirty.ts index 27f937abee..1d8fdf07f0 100644 --- a/dbm-ui/frontend/src/services/source/dbdirty.ts +++ b/dbm-ui/frontend/src/services/source/dbdirty.ts @@ -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'; @@ -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>(`${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); +} diff --git a/dbm-ui/frontend/src/services/source/dbresourceResource.ts b/dbm-ui/frontend/src/services/source/dbresourceResource.ts index a97c52ae4b..5454cd464a 100644 --- a/dbm-ui/frontend/src/services/source/dbresourceResource.ts +++ b/dbm-ui/frontend/src/services/source/dbresourceResource.ts @@ -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); } diff --git a/dbm-ui/frontend/src/services/source/tag.ts b/dbm-ui/frontend/src/services/source/tag.ts index 14c2f7a146..649ace1376 100644 --- a/dbm-ui/frontend/src/services/source/tag.ts +++ b/dbm-ui/frontend/src/services/source/tag.ts @@ -15,6 +15,7 @@ export function listTag(params: { bk_biz_id?: number; limit?: number; offset?: number; + ordering?: string; }) { return http.get>(`${path}`, params).then((res) => ({ ...res, diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/Index.vue new file mode 100644 index 0000000000..61a43cc329 --- /dev/null +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/Index.vue @@ -0,0 +1,398 @@ + + + + + + + diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/Index.vue new file mode 100644 index 0000000000..baf9c0eef7 --- /dev/null +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/Index.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/components/FormPanel.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/components/FormPanel.vue new file mode 100644 index 0000000000..ad176c0e19 --- /dev/null +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/components/FormPanel.vue @@ -0,0 +1,151 @@ + + + + + + + diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/components/ListPanel.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/components/ListPanel.vue new file mode 100644 index 0000000000..6233c7064d --- /dev/null +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/BatchImportResourcePool/components/ListPanel.vue @@ -0,0 +1,265 @@ + + + + + diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/ImportResourcePool.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/ImportResourcePool.vue new file mode 100644 index 0000000000..449263c269 --- /dev/null +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/ImportResourcePool.vue @@ -0,0 +1,205 @@ + + + + + diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/search.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/search.vue new file mode 100644 index 0000000000..b172dc2d70 --- /dev/null +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/fault-or-recycle-list/components/search.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/Index.vue index a49fe2bfb6..2baef51252 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/Index.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/Index.vue @@ -224,7 +224,7 @@ ...params, }); - const searchParams: Record = {}; + let searchParams: Record = {}; let selectionListWholeDataMemo: DbResourceModel[] = []; const tableColumn = [ { @@ -252,10 +252,10 @@
{t('所属业务')} : {data.for_biz_display} + theme={(data.for_biz.bk_biz_id === 0 || !data.for_biz.bk_biz_name) ? 'success' : undefined}>{t('所属业务')} : {data.forBizDisplay} {t('所属DB')} : {data.resource_type_display} + theme={(!data.resource_type || data.resource_type === 'PUBLIC') ? 'success' : undefined}>{t('所属DB')} : {data.resourceTypeDisplay} { data.labels && Array.isArray(data.labels) && ( @@ -393,7 +393,8 @@ }; const handleSearch = (params: Record) => { - tableRef.value.fetchData(params); + searchParams = {...searchParams, ...params}; + tableRef.value.fetchData(searchParams); }; // 导入主机 diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/batch-assign/components/FormPanel.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/batch-assign/components/FormPanel.vue index 5c4efa5a92..8632b86401 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/batch-assign/components/FormPanel.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/batch-assign/components/FormPanel.vue @@ -74,7 +74,7 @@ import { listTag } from '@services/source/tag'; import type { BizItem } from '@services/types'; - import TagSelector from '../../tag-selector/Index.vue'; + import TagSelector from '@views/resource-manage/pool/components/tag-selector/Index.vue'; interface Props { bizId: number; diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/import-host/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/import-host/Index.vue index 389572c4a2..09d9f055c5 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/import-host/Index.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/components/host-list/components/import-host/Index.vue @@ -39,20 +39,14 @@