Skip to content

Commit

Permalink
feat(frontend): 资源池统计视图 TencentBlueKing#6519
Browse files Browse the repository at this point in the history
  • Loading branch information
JustaCattt committed Oct 10, 2024
1 parent 8c44a01 commit 68278e0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 38 deletions.
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/services/model/db-resource/DbResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ export default class DbResource {
return this.agent_status === 0;
}

get for_biz_display() {
get forBizDisplay() {
if (this.for_biz.bk_biz_id === 0 || !this.for_biz.bk_biz_name) {
return t('公共资源池');
}
return this.for_biz.bk_biz_name;
}

get resource_type_display() {
get resourceTypeDisplay() {
if (!this.resource_type || this.resource_type === 'PUBLIC') {
return t('通用');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@
},
{
label: t('所属业务'),
field: 'for_biz_display',
field: 'forBizDisplay',
width: 170,
render: ({ data }: {data: DbResourceModel}) => data.for_biz_display || '--',
render: ({ data }: {data: DbResourceModel}) => data.forBizDisplay || '--',
},
{
label: t('所属DB类型'),
field: 'resource_type_display',
field: 'resourceTypeDisplay',
width: 150,
render: ({ data }: {data: DbResourceModel}) => data.resource_type_display || '--',
render: ({ data }: {data: DbResourceModel}) => data.resourceTypeDisplay || '--',
},
{
label: t('机架'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,10 @@

useRequest(getBizs, {
onSuccess(data) {
const cloneData = data.map((item) => ({
bk_biz_id: item.bk_biz_id,
display_name: item.display_name,
}));
cloneData.unshift({
bk_biz_id: 0,
display_name: t('公共资源池'),
});
bizList.value = cloneData;
bizList.value = [
{ bk_biz_id: 0, display_name: t('公共资源池') },
...data.map(({ bk_biz_id, display_name }) => ({ bk_biz_id, display_name })),
];
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@

useRequest(fetchDbTypeList, {
onSuccess(data) {
const cloneData = data;
cloneData.unshift({
id: 'PUBLIC',
name: t('通用'),
});
dbTypeList.value = cloneData;
dbTypeList.value = [{ id: 'PUBLIC', name: t('通用') }, ...data];
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,10 @@
useRequest(getBizs, {
onSuccess(data) {
const cloneData = data.map((item) => ({
bk_biz_id: item.bk_biz_id,
display_name: item.display_name,
}));
cloneData.unshift({
bk_biz_id: 0,
display_name: t('公共资源池'),
});
bizList.value = cloneData;
bizList.value = [
{ bk_biz_id: 0, display_name: t('公共资源池') },
...data.map(({ bk_biz_id, display_name }) => ({ bk_biz_id, display_name })),
];
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@
useRequest(fetchDbTypeList, {
onSuccess(data) {
const cloneData = data;
cloneData.unshift({
id: 'PUBLIC',
name: t('通用'),
});
dbTypeList.value = cloneData;
dbTypeList.value = [{ id: 'PUBLIC', name: t('通用') }, ...data];
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
const citiyList = ref<CityItem[]>([]);
const cityCode = ref('');
const subzoneIds = ref<string[]>([]);
const renderSubzoneList = computed(() =>
(subzoneList.value || []).filter((item) => item.bk_city_code === cityCode.value),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
<script setup lang="ts">
import { useRequest } from 'vue-request';
import { type ClusterTypeInfoItem, clusterTypeInfos, ClusterTypes } from '@common/const';
import { getResourceSpecList } from '@services/source/dbresourceSpec';
import { getResourceSpecList } from '@/services/source/dbresourceSpec';
import { type ClusterTypeInfoItem, clusterTypeInfos, ClusterTypes } from '@common/const';
interface Props {
model: Record<string, string>;
Expand All @@ -72,6 +72,7 @@
const machineType = ref('');
const specIdList = ref<string[]>([]);
const clusterMachineList = ref<ClusterTypeInfoItem['machineList']>([]);
const clusterTypeList = computed(
() => Object.values(clusterTypeInfos).filter((item) => item.dbType === props.model.db_type) || [],
);
Expand Down

0 comments on commit 68278e0

Please sign in to comment.