Skip to content

Commit

Permalink
feat(frontend): 支持故障池、待回收池 #7881
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 26016
  • Loading branch information
royalpioneer authored and hLinx committed Dec 6, 2024
1 parent b6e8b9d commit 06d0a96
Show file tree
Hide file tree
Showing 28 changed files with 1,140 additions and 229 deletions.
26 changes: 8 additions & 18 deletions dbm-ui/frontend/src/layout/components/ResourceManage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
:opened-keys="[parentKey]"
@click="handleMenuChange">
<BkMenuGroup :name="t('资源管理')">
<BkMenuItem
key="resourceSpec"
v-db-console="'resourceManage.resourceSpec'">
<template #icon>
<DbIcon type="spec" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('资源规格管理') }}
</span>
</BkMenuItem>
<BkMenuItem
key="resourcePool"
v-db-console="'resourceManage.resourcePool'">
Expand All @@ -26,7 +14,7 @@
<span
v-overflow-tips.right
class="text-overflow">
{{ t('DB 资源池管理') }}
{{ t('资源池') }}
</span>
</BkMenuItem>
<BkMenuItem
Expand Down Expand Up @@ -54,15 +42,15 @@
</span>
</BkMenuItem>
<BkMenuItem
key="resourcePoolDirtyMachines"
v-db-console="'resourceManage.dirtyHostManage'">
key="resourceSpec"
v-db-console="'resourceManage.resourceSpec'">
<template #icon>
<DbIcon type="dirty-host" />
<DbIcon type="spec" />
</template>
<span
v-overflow-tips.right
class="text-overflow">
{{ t('污点主机处理') }}
{{ t('资源规格管理') }}
</span>
</BkMenuItem>
<BkMenuItem
Expand All @@ -77,6 +65,8 @@
{{ t('资源标签管理') }}
</span>
</BkMenuItem>
</BkMenuGroup>
<BkMenuGroup :name="t('其他')">
<BkMenuItem
key="resourcePoolOperationRecord"
v-db-console="'resourceManage.resourceOperationRecord'">
Expand Down Expand Up @@ -106,5 +96,5 @@
parentKey,
key: currentActiveKey,
routeLocation: handleMenuChange,
} = useActiveKey(menuRef as Ref<InstanceType<typeof Menu>>, 'resourceSpec');
} = useActiveKey(menuRef as Ref<InstanceType<typeof Menu>>, 'resourcePool');
</script>
15 changes: 12 additions & 3 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3671,8 +3671,8 @@
"撤销导入": "撤销导入",
"确认后,主机将从资源池移回原有模块": "确认后,主机将从资源池移回原有模块",
"所属DB": "所属DB",
"移入故障池": "移入故障池",
"移入待回收池": "移入待回收池",
"转入故障池": "转入故障池",
"转入待回收池": "转入待回收池",
"资源归属": "资源归属",
"确认批量将 {n} 台主机转入回收池?": "确认批量将 {n} 台主机转入回收池?",
"确认批量将 {n} 台主机转入故障池?": "确认批量将 {n} 台主机转入故障池?",
Expand All @@ -3681,7 +3681,7 @@
"资源标签": "资源标签",
"标签": "标签",
"仅支持同业务的主机": "仅支持同业务的主机",
"设置属性": "设置属性",
"设置主机属性": "设置主机属性",
"添加资源归属": "添加资源归属",
"转为公共资源": "转为公共资源",
"共n台": "共{0}台",
Expand Down Expand Up @@ -3725,5 +3725,14 @@
"已选 IP": "已选 IP",
"业务资源池": "业务资源池",
"冷/热节点": "冷/热节点",
"退回公共资源池": "退回公共资源池",
"确认转入业务资源池?": "确认转入业务资源池?",
"转入业务资源池": "转入业务资源池",
"从 CMDB 的 n 业务空闲机导入": "从 CMDB 的 {0} 业务空闲机导入",
"重新设置资源归属": "重新设置资源归属",
"暂无主机,你通过以下方法获取主机至“ n -> 空闲机池 -> 空闲机模块": "暂无主机,你通过以下方法获取主机至“ {0} -> 空闲机池 -> 空闲机模块",
"确认退回公共资源池?": "确认退回公共资源池?",
"确认后,主机不再归属当前业务": "确认后,主机不再归属当前业务",
"从 n 业务 CMDB 空闲机模块导入": "从 {0} 业务 CMDB 空闲机模块导入",
"这行勿动!新增翻译请在上一行添加!": ""
}
8 changes: 7 additions & 1 deletion dbm-ui/frontend/src/services/source/dbdirty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ export function deleteDirtyRecords(params: { bk_host_ids: number[] }) {
/**
* 故障池、待回收池列表
*/
export function getMachinePool(params: { limit?: number; offset?: number; ips?: string; pool: 'fault' | 'recycle' }) {
export function getMachinePool(params: {
limit?: number;
offset?: number;
ips?: string;
pool: 'fault' | 'recycle';
bk_biz_id?: number;
}) {
return http.get<ListBase<FaultOrRecycleMachineModel[]>>(`${path}/query_machine_pool/`, params).then((res) => ({
...res,
results: res.results.map((item: FaultOrRecycleMachineModel) => new FaultOrRecycleMachineModel(item)),
Expand Down
4 changes: 3 additions & 1 deletion dbm-ui/frontend/src/services/source/dbresourceResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function fetchList(params: Record<string, any>, payload = {} as IRequestP
/**
* 获取DBA业务下的主机信息
*/
export function fetchListDbaHost(params: { limit: number; offset: number; search_content: string }) {
export function fetchListDbaHost(params: { limit: number; offset: number; search_content: string; bk_biz_id: number }) {
return http
.get<{
total: number;
Expand All @@ -105,6 +105,7 @@ export function fetchListDbaHost(params: { limit: number; offset: number; search
search_content: params.search_content,
start: params.offset,
page_size: params.limit,
bk_biz_id: params.bk_biz_id,
})
.then((data) => ({
count: data.total,
Expand Down Expand Up @@ -212,6 +213,7 @@ export function getSummaryList(params: {
machine_type?: string;
cluster_type?: string;
spec_id_list?: number[];
enable_spec?: boolean;
};
}) {
return http.get<SummaryModel[]>(`${path}/resource_summary/`, params).then((data) => ({
Expand Down
26 changes: 12 additions & 14 deletions dbm-ui/frontend/src/views/resource-manage/pool/business/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
<div class="pool-container">
<Teleport to="#dbContentTitleAppend">
<BkTag
class="ml-8"
class="ml-8 mr-8"
theme="info">
{{ t('业务') }}
</BkTag>
<BkButton
v-show="activeTab === ResourcePool.public"
class="ml-8"
theme="primary"
@click="linkToBusiness">
<DbIcon type="add" />
{{ t('导入主机') }}
</BkButton>
<ImportHostBtn
class="w-88"
@export-host="handleImportHost" />
</Teleport>
<BkTab
v-model:active="activeTab"
Expand All @@ -44,6 +39,7 @@
ref="listRef"
:type="activeTab" />
</div>
<ImportHost v-model:is-show="isShowImportHost" />
</div>
</template>

Expand All @@ -52,6 +48,8 @@

import { useDebouncedRef } from '@hooks';

import ImportHost from '../components/host-list/components/import-host/Index.vue';
import ImportHostBtn from '../components/host-list/components/ImportHostBtn.vue';
import HostList from '../components/host-list/Index.vue';
import { ResourcePool } from '../type';

Expand All @@ -61,6 +59,8 @@
const activeTab = useDebouncedRef(route.params.page as ResourcePool);
const listRef = useTemplateRef('listRef');

const isShowImportHost = ref(false);

const panels = [
{
name: 'business',
Expand All @@ -80,11 +80,9 @@
});
};

const linkToBusiness = () => {
activeTab.value = ResourcePool.business;
setTimeout(() => {
listRef.value?.handleImportHost();
}, 1000);
// 导入主机
const handleImportHost = () => {
isShowImportHost.value = true;
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
const dataSource = (params: FaultOrRecycleMachineModel) => getMachinePool({
...params,
pool: isFaultPool.value ? 'fault' : 'recycle'
pool: isFaultPool.value ? 'fault' : 'recycle',
bk_biz_id: undefined,
});
const tableColumn = [
{
Expand Down
Loading

0 comments on commit 06d0a96

Please sign in to comment.