Skip to content

Commit

Permalink
feat(frontend): 资源池统计视图 TencentBlueKing#6519
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 19694
  • Loading branch information
JustaCattt committed Oct 9, 2024
1 parent befed7a commit 3098952
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 146 deletions.
9 changes: 5 additions & 4 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3438,13 +3438,11 @@
"复制所属集群": "复制所属集群",
"公共资源池": "公共资源池",
"统计视图": "统计视图",
"分布情况": "分布情况",
"规格类型": "规格类型",
"机型(硬盘)": "机型(硬盘)",
"CPU 内存": "CPU 内存",
"园区分布(台)": "园区分布(台)",
"地域 - 园区": "地域 - 园区",
"Mongo 分片集群": "Mongo 分片集群",
"所属DB类型": "所属DB类型",
"请选择所属业务": "请选择所属业务",
"请选择所属DB类型": "请选择所属DB类型",
Expand All @@ -3453,8 +3451,11 @@
"导出列表内容": "导出列表内容",
"数量(台)": "数量(台)",
"主机列表": "主机列表",
"所属业务 + 地域 + 规格": "所属业务 + 地域 + 规格",
"所属业务 + 地域 + 机型(硬盘)": "所属业务 + 地域 + 机型(硬盘)",
"资源分布统计": "资源分布统计",
"地域 + 规格": "地域 + 规格",
"地域 + 机型(硬盘)": "地域 + 机型(硬盘)",
"资源分布统计(地域 + 规格)": "资源分布统计(地域 + 规格)",
"资源分布统计(地域 + 机型)": "资源分布统计(地域 + 机型)",
"主机数量 - 按DB类型统计": "主机数量 - 按DB类型统计",
"这行勿动!新增翻译请在上一行添加!": ""
}
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/services/model/db-resource/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export default class Summary {
}

get subzoneDetailDisplay() {
return `${Object.entries(this.sub_zone_detail)
.map(([zone, count]) => `${zone}: ${count}`)
return `${Object.values(this.sub_zone_detail)
.map((item) => `${item.name}: ${item.count}`)
.join(', ')};`;
}
}
2 changes: 0 additions & 2 deletions dbm-ui/frontend/src/services/source/dbresourceResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ export function updateResource(params: {
for_biz: number;
rack_id: string;
resource_type: string;
set_empty_biz: boolean;
set_empty_resource_type: boolean;
storage_device: Record<string, { size: number; disk_type: string }>;
}) {
return http.post(`${path}/update/`, params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@

import { useUrlSearch } from '@hooks';

import { useGlobalBizs } from '@stores';

import EmptyStatus from '@components/empty-status/EmptyStatus.vue';

import {
Expand Down Expand Up @@ -206,7 +204,6 @@
});

const { t } = useI18n();
const { currentBizId } = useGlobalBizs();

const rootRef = ref();
const bkTableRef = ref();
Expand Down Expand Up @@ -292,7 +289,6 @@
.then(() => {
isLoading.value = loading;
const params = {
bk_biz_id: currentBizId,
offset: (pagination.current - 1) * pagination.limit,
limit: pagination.limit,
...paramsMemo,
Expand Down Expand Up @@ -400,7 +396,6 @@
// 跨页全选
const handleWholeSelect = () => {
props.dataSource({
bk_biz_id: currentBizId,
offset: (pagination.current - 1) * pagination.limit,
limit: -1,
...paramsMemo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@
<div class="com-input">
<BkSelect
v-model="formData.for_biz"
:disabled="formData.set_empty_biz"
filterable>
<BkOption
v-for="bizItem in bizList"
:key="bizItem.bk_biz_id"
:label="bizItem.display_name"
:value="bizItem.bk_biz_id" />
</BkSelect>
<BkCheckbox
v-model="formData.set_empty_biz"
class="ml-12"
@change="handleEmptyBizChange">
{{ t('无限制') }}
</BkCheckbox>
</div>
</DbFormItem>
<DbFormItem
Expand All @@ -45,20 +38,13 @@
<div class="com-input">
<BkSelect
v-model="formData.resource_type"
:disabled="formData.set_empty_resource_type"
filterable>
<BkOption
v-for="item in dbTypeList"
:key="item.id"
:label="item.name"
:value="item.id" />
</BkSelect>
<BkCheckbox
v-model="formData.set_empty_resource_type"
class="ml-12"
@change="handleEmptyResourceTypeChange">
{{ t('无限制') }}
</BkCheckbox>
</div>
</DbFormItem>
<DbFormItem :label="t('磁盘')">
Expand Down Expand Up @@ -119,8 +105,6 @@
rack_id: '',
resource_type: '',
storage_spec: [] as IStorageSpecItem[],
set_empty_biz: false,
set_empty_resource_type: false,
});
const formRef = ref();
Expand All @@ -140,14 +124,7 @@
const formData = reactive(genDefaultData());
const isSubmitDisabled = computed(
() =>
!(
formData.for_biz ||
formData.resource_type ||
formData.storage_spec.length > 0 ||
formData.set_empty_biz ||
formData.set_empty_resource_type
),
() => !(formData.for_biz || formData.resource_type || formData.storage_spec.length > 0),
);
useRequest(getBizs, {
Expand Down Expand Up @@ -175,14 +152,6 @@
},
});
const handleEmptyBizChange = () => {
formData.for_biz = '0';
};
const handleEmptyResourceTypeChange = () => {
formData.resource_type = '';
};
const handleSubmit = () => {
isSubmiting.value = true;
formRef.value
Expand All @@ -200,11 +169,9 @@
);
return updateResource({
bk_host_ids: props.data.map((item) => ~~item),
for_biz: formData.set_empty_biz ? 0 : Number(formData.for_biz),
for_biz: Number(formData.for_biz),
rack_id: formData.rack_id,
resource_type: formData.set_empty_resource_type ? '' : formData.resource_type,
set_empty_biz: formData.set_empty_biz,
set_empty_resource_type: formData.set_empty_resource_type,
resource_type: formData.resource_type,
storage_device: storageDevice,
}).then(() => {
window.changeConfirm = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

interface Props {
modelValue: IStorageSpecItem[],
isEdit: boolean,
isRequired: boolean
isEdit?: boolean,
isRequired?: boolean
}

interface Emits {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,13 @@
<div class="com-input">
<BkSelect
v-model="formData.for_biz"
:disabled="isSetEmptyBiz"
filterable>
<BkOption
v-for="bizItem in bizList"
:key="bizItem.bk_biz_id"
:label="bizItem.display_name"
:value="bizItem.bk_biz_id" />
</BkSelect>
<BkCheckbox
v-model="isSetEmptyBiz"
class="ml-12"
@change="handleEmptyBizChange">
{{ t('无限制') }}
</BkCheckbox>
</div>
</BkFormItem>
<BkFormItem
Expand All @@ -121,20 +114,13 @@
<div class="com-input">
<BkSelect
v-model="formData.resource_type"
:disabled="isSetEmptyResourceType"
filterable>
<BkOption
v-for="item in dbTypeList"
:key="item.id"
:label="item.name"
:value="item.id" />
</BkSelect>
<BkCheckbox
v-model="isSetEmptyResourceType"
class="ml-12"
@change="handleEmptyResourceTypeChange">
{{ t('无限制') }}
</BkCheckbox>
</div>
</BkFormItem>
</DbForm>
Expand Down Expand Up @@ -172,8 +158,6 @@

const formRef = ref();
const isShowHostActionPop = ref(false);
const isSetEmptyBiz = ref(false);
const isSetEmptyResourceType = ref(false);
const formData = reactive({
for_biz: '',
resource_type: '',
Expand Down Expand Up @@ -289,19 +273,11 @@
emits('update:hostList', hostListResult);
};

const handleEmptyBizChange = () => {
formData.for_biz = '0';
};

const handleEmptyResourceTypeChange = () => {
formData.resource_type = '';
};

defineExpose<Expose>({
getValue() {
return formRef.value.validate().then(() => ({
for_biz: isSetEmptyBiz.value ? 0 : Number(formData.for_biz),
resource_type: isSetEmptyResourceType.value ? '' : formData.resource_type,
for_biz: Number(formData.for_biz),
resource_type: formData.resource_type,
}));
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@
const subzoneIds = ref<string[]>([]);
const citiyList = ref<CityItem[]>([]);

const filterSubzoneList = computed(() => {
if (!cityCode.value) {
return [];
}
return (subzoneList.value || []).filter((item) => item.bk_city_code === cityCode.value);
});
const filterSubzoneList = computed(() =>
(subzoneList.value || []).filter((item) => item.bk_city_code === cityCode.value),
);

useRequest(getInfrasCities, {
onSuccess(data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
import { getBizs } from '@services/source/cmdb';

interface Props {
defaultValue?: number;
defaultValue?: string;
simple?: boolean;
}
interface Emits {
(e: 'change', value: number): void;
(e: 'change', value: number | undefined): void;
(e: 'submit'): void;
(e: 'cancel'): void;
}

const props = withDefaults(defineProps<Props>(), {
defaultValue: 0,
defaultValue: '',
simple: false,
});

Expand All @@ -71,14 +71,15 @@

const { t } = useI18n();

const localValue = ref('0');
const bizList = shallowRef<
{
bk_biz_id: number;
display_name: string;
}[]
>([]);

const localValue = computed(() => Number(props.defaultValue) || '');

useRequest(getBizs, {
onSuccess(data) {
const cloneData = data.map((item) => ({
Expand All @@ -93,24 +94,14 @@
},
});

watch(
() => props.defaultValue,
() => {
localValue.value = `${props.defaultValue}`;
},
{
immediate: true,
},
);

const handleSubmit = () => {
emits('submit');
};
const handleCancel = () => {
emits('cancel');
};

const handleChange = (value: string) => {
emits('change', Number(value));
const handleChange = (value: Props['defaultValue']) => {
emits('change', value ? Number(value) : undefined);
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}

withDefaults(defineProps<Props>(), {
defaultValue: 'PUBLIC',
defaultValue: '',
simple: false,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
<template v-if="isShowMore">
<div class="row">
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'mount_point')"
:ref="(el: any) => initInputRefCallback(el, 'os_type')"
:model="localValueMemo"
name="mount_point"
name="os_type"
@change="handleChange" />
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'cpu')"
Expand All @@ -70,11 +70,7 @@
:model="localValueMemo"
name="mem"
@change="handleChange" />
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'disk')"
:model="localValueMemo"
name="disk"
@change="handleChange" />
<div style="flex: 1" />
</div>
<div class="row">
<ComFactory
Expand All @@ -83,9 +79,14 @@
name="disk_type"
@change="handleChange" />
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'os_type')"
:ref="(el: any) => initInputRefCallback(el, 'disk')"
:model="localValueMemo"
name="os_type"
name="disk"
@change="handleChange" />
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'mount_point')"
:model="localValueMemo"
name="mount_point"
@change="handleChange" />
<div style="flex: 1" />
</div>
Expand Down
Loading

0 comments on commit 3098952

Please sign in to comment.