Merge "fix: fix the networks,ports and security groups"

This commit is contained in:
Zuul 2022-08-08 09:59:50 +00:00 committed by Gerrit Code Review
commit 406a16c844
2 changed files with 47 additions and 4 deletions

View File

@ -156,15 +156,47 @@ export class BaseDetail extends Base {
dataIndex: 'addresses', dataIndex: 'addresses',
render: this.stringifyContent, render: this.stringifyContent,
}, },
{
label: t('Networks'),
dataIndex: 'networks',
render: (value = []) => (
<>
{value.map((it) => {
const link = this.getLinkRender('networkDetail', it, {
id: it,
});
return <div key={it}>{link}</div>;
})}
</>
),
},
{ {
label: t('Ports'), label: t('Ports'),
dataIndex: 'ports', dataIndex: 'ports',
render: this.stringifyContent, render: (value = []) => (
<>
{value.map((it) => {
const link = this.getLinkRender('virtualAdapterDetail', it, {
id: it,
});
return <div key={it}>{link}</div>;
})}
</>
),
}, },
{ {
label: t('Security Groups'), label: t('Security Groups'),
dataIndex: 'security_groups', dataIndex: 'security_groups',
render: this.stringifyContent, render: (value = []) => (
<>
{value.map((it) => {
const link = this.getLinkRender('securityGroupDetail', it, {
id: it,
});
return <div key={it}>{link}</div>;
})}
</>
),
}, },
]; ];

View File

@ -15,6 +15,7 @@
import Base from 'stores/base'; import Base from 'stores/base';
import client from 'client'; import client from 'client';
import { action } from 'mobx'; import { action } from 'mobx';
import { isEmpty } from 'lodash';
export class ContainersStore extends Base { export class ContainersStore extends Base {
get client() { get client() {
@ -77,12 +78,22 @@ export class ContainersStore extends Base {
} }
async detailDidFetch(item) { async detailDidFetch(item) {
const { uuid, status } = item; const { uuid, status, addresses = {} } = item;
let stats = {}; let stats = {};
if (status === 'Running') { if (status === 'Running') {
stats = (await this.client.stats.list(uuid)) || {}; 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) { async fetchLogs(id) {