From 5ad07c694f210b7348460574a320e5fdab8bf211 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Mon, 8 Aug 2022 11:25:15 +0800 Subject: [PATCH] fix: fix the networks,ports and security groups 1. fix the ports and security groups to link 2. show the networks of the zun container Change-Id: Idc89319379b68822c67c9c036bc3b7cb8cbef15a --- .../Containers/Detail/BaseDetail.jsx | 36 +++++++++++++++++-- src/stores/zun/containers.js | 15 ++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/pages/container-service/containers/Containers/Detail/BaseDetail.jsx b/src/pages/container-service/containers/Containers/Detail/BaseDetail.jsx index 49adcd88..7069c1da 100644 --- a/src/pages/container-service/containers/Containers/Detail/BaseDetail.jsx +++ b/src/pages/container-service/containers/Containers/Detail/BaseDetail.jsx @@ -156,15 +156,47 @@ export class BaseDetail extends Base { dataIndex: 'addresses', render: this.stringifyContent, }, + { + label: t('Networks'), + dataIndex: 'networks', + render: (value = []) => ( + <> + {value.map((it) => { + const link = this.getLinkRender('networkDetail', it, { + id: it, + }); + return
{link}
; + })} + + ), + }, { label: t('Ports'), dataIndex: 'ports', - render: this.stringifyContent, + render: (value = []) => ( + <> + {value.map((it) => { + const link = this.getLinkRender('virtualAdapterDetail', it, { + id: it, + }); + return
{link}
; + })} + + ), }, { label: t('Security Groups'), dataIndex: 'security_groups', - render: this.stringifyContent, + render: (value = []) => ( + <> + {value.map((it) => { + const link = this.getLinkRender('securityGroupDetail', it, { + id: it, + }); + return
{link}
; + })} + + ), }, ]; diff --git a/src/stores/zun/containers.js b/src/stores/zun/containers.js index 041bfedd..f9510344 100644 --- a/src/stores/zun/containers.js +++ b/src/stores/zun/containers.js @@ -15,6 +15,7 @@ import Base from 'stores/base'; import client from 'client'; import { action } from 'mobx'; +import { isEmpty } from 'lodash'; export class ContainersStore extends Base { get client() { @@ -77,12 +78,22 @@ export class ContainersStore extends Base { } async detailDidFetch(item) { - const { uuid, status } = item; + const { uuid, status, addresses = {} } = item; let stats = {}; if (status === 'Running') { stats = (await this.client.stats.list(uuid)) || {}; } - return { ...item, stats }; + const networks = Object.keys(addresses); + let { ports = [] } = item; + if (isEmpty(ports)) { + ports = Object.values(addresses) + .reduce((ret, cur) => { + ret = ret.concat(cur); + return ret; + }, []) + .map((it) => it.port); + } + return { ...item, stats, networks, ports }; } async fetchLogs(id) {