From 47c34e11006e2a565b3e41203ba48dbd828ad280 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Tue, 18 Oct 2022 16:52:29 +0800 Subject: [PATCH] fix: update the qos policy column in the floating ip list page 1. Update the qos policy name in the floating ip list page, if the user has the admin role, the user can fetch all the qos polices 2. Update the qos policy column title, and support qos policy id and name in the download data Change-Id: I96a18f24ef2f2e6c09d56eb5ae980202c31b98dd --- src/locales/en.json | 1 + src/locales/zh.json | 1 + .../network/containers/FloatingIp/index.jsx | 2 +- src/stores/neutron/floatingIp.js | 45 +++++++++++-------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index abcd5971..56d5953a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1863,6 +1863,7 @@ "QoS Policy": "QoS Policy", "QoS Policy Detail": "QoS Policy Detail", "QoS Policy ID": "QoS Policy ID", + "QoS Policy ID/Name": "QoS Policy ID/Name", "QoS Spec": "QoS Spec", "QoS Spec ID": "QoS Spec ID", "QoS Specs": "QoS Specs", diff --git a/src/locales/zh.json b/src/locales/zh.json index c163889e..2e47d273 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -1863,6 +1863,7 @@ "QoS Policy": "QoS策略", "QoS Policy Detail": "QoS策略详情", "QoS Policy ID": "QoS策略ID", + "QoS Policy ID/Name": "QoS策略ID/名称", "QoS Spec": "QoS规格", "QoS Spec ID": "QoS规格ID", "QoS Specs": "QoS规格", diff --git a/src/pages/network/containers/FloatingIp/index.jsx b/src/pages/network/containers/FloatingIp/index.jsx index bc6e8ef2..f1bd7388 100644 --- a/src/pages/network/containers/FloatingIp/index.jsx +++ b/src/pages/network/containers/FloatingIp/index.jsx @@ -260,7 +260,7 @@ export class FloatingIps extends Base { boldName: true, }, { - title: t('QoS Policy'), + title: t('QoS Policy ID/Name'), dataIndex: 'qos_policy_name', isLink: true, routeName: this.getRouteName('networkQosDetail'), diff --git a/src/stores/neutron/floatingIp.js b/src/stores/neutron/floatingIp.js index 6b6d99a0..c18b531d 100644 --- a/src/stores/neutron/floatingIp.js +++ b/src/stores/neutron/floatingIp.js @@ -18,7 +18,6 @@ import { action, observable } from 'mobx'; import globalRouterStore from 'stores/neutron/router'; import globalServerStore from 'stores/nova/instance'; import globalLbaasStore from 'stores/octavia/loadbalancer'; -import globalQoSPolicyStore from 'stores/neutron/qos-policy'; import { qosEndpoint } from 'client/client/constants'; export class FloatingIpStore extends Base { @@ -26,6 +25,10 @@ export class FloatingIpStore extends Base { return client.neutron.floatingips; } + get qosClient() { + return client.neutron.qosPolicies; + } + get listFilterByProject() { return true; } @@ -59,6 +62,19 @@ export class FloatingIpStore extends Base { async listDidFetch(items, allProjects, filters) { const { qos_policy_id } = filters; + const hasQos = items.find((it) => !!it.qos_policy_id); + if (hasQos && this.enableQos) { + const qosResult = await this.qosClient.list(); + const { policies = [] } = qosResult || {}; + items.forEach((it) => { + if (it.qos_policy_id) { + const qosItem = policies.find((p) => p.id === it.qos_policy_id); + if (qosItem) { + it.qos_policy_name = qosItem.name; + } + } + }); + } if (!qos_policy_id) { return items; } @@ -75,26 +91,17 @@ export class FloatingIpStore extends Base { timeFilter, ...filters } = {}) { - const qosReq = this.enableQos ? globalQoSPolicyStore.fetchList() : null; - const [qosResult, allData] = await Promise.all([ - qosReq, - this.fetchListByPage({ - limit, - page, - sortKey, - sortOrder, - conditions, - timeFilter, - ...filters, - }), - ]); - const qosPolicies = qosResult || []; + const allData = await this.fetchListByPage({ + limit, + page, + sortKey, + sortOrder, + conditions, + timeFilter, + ...filters, + }); const promises = []; allData.forEach((data) => { - const qos = qosPolicies.find((it) => it.id === data.qos_policy_id); - if (qos) { - data.qos_policy_name = qos.name; - } if ( data.port_details && data.port_details.device_owner === 'network:router_gateway'