From 983af51a917429f13dbc452c9df8863a03c34bef Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Wed, 21 Jul 2021 15:14:32 +0800 Subject: [PATCH] fix: Fix show qos name in volume type list page Fix show qos name in volume type list page Change-Id: I51f9ee503c4742b47ef95b1a282738af1178f129 --- .../VolumeType/VolumeType/index.jsx | 10 ++++---- src/stores/cinder/volume-type.js | 25 +++++++++++++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/pages/storage/containers/VolumeType/VolumeType/index.jsx b/src/pages/storage/containers/VolumeType/VolumeType/index.jsx index ed1ac302..5e076286 100644 --- a/src/pages/storage/containers/VolumeType/VolumeType/index.jsx +++ b/src/pages/storage/containers/VolumeType/VolumeType/index.jsx @@ -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'), diff --git a/src/stores/cinder/volume-type.js b/src/stores/cinder/volume-type.js index c93a93f3..a50fa194 100644 --- a/src/stores/cinder/volume-type.js +++ b/src/stores/cinder/volume-type.js @@ -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; }