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

View File

@ -34,14 +34,7 @@ export class VolumeTypeStore extends Base {
get paramsFuncPage() { get paramsFuncPage() {
return (params) => { return (params) => {
const { const { current, showEncryption, showQoS, ...rest } = params;
current,
showEncryption,
showQoS,
withPrice,
resourceType,
...rest
} = params;
return rest; 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) { if (!showEncryption) {
return items; return items;
} }