fix: Fix show qos name in volume type list page

Fix show qos name in volume type list page

Change-Id: I51f9ee503c4742b47ef95b1a282738af1178f129
This commit is contained in:
zhangjingwei 2021-07-21 15:14:32 +08:00 committed by Jingwei.Zhang
parent 20a309ef83
commit 983af51a91
2 changed files with 22 additions and 13 deletions

View File

@ -57,6 +57,7 @@ export default class VolumeType extends Base {
const newParams = {
...params,
showEncryption: true,
showQoS: true,
};
if (has(params, 'is_public')) {
return newParams;
@ -81,11 +82,10 @@ export default class VolumeType extends Base {
},
{
title: t('Associated QoS Spec'),
// TODO: api init qos_specs_name
// dataIndex: 'qos_specs_name',
dataIndex: 'qos_specs_id',
copyable: true,
valueRender: 'noValue',
dataIndex: 'qos_specs_name',
isName: true,
linkPrefix: '/storage/volume-type-admin/qos/detail/',
idKey: 'qos_specs_id',
},
{
title: t('Encryption'),

View File

@ -34,14 +34,7 @@ export class VolumeTypeStore extends Base {
get paramsFuncPage() {
return (params) => {
const {
current,
showEncryption,
showQoS,
withPrice,
resourceType,
...rest
} = params;
const { current, showEncryption, showQoS, ...rest } = params;
return rest;
};
}
@ -82,6 +75,22 @@ export class VolumeTypeStore extends Base {
});
}
}
if (showQoS) {
const qosIds = uniq(
items.filter((it) => !!it.qos_specs_id).map((it) => it.qos_specs_id)
);
if (qosIds.length) {
const qosReqs = qosIds.map((id) => client.cinder.qosSpecs.show(id));
const qosResults = await Promise.all(qosReqs);
const qosItems = qosResults.map((it) => it.qos_specs);
items.forEach((it) => {
if (it.qos_specs_id) {
it.qos_specs = qosItems.find((qos) => qos.id === it.qos_specs_id);
it.qos_specs_name = (it.qos_specs || {}).name;
}
});
}
}
if (!showEncryption) {
return items;
}