feat: Add filter for fip port forwarding & fix download

1. add filter for fip port forwarding
2. fix for download
3. make external_port not hideable

Change-Id: I549925ee1403de99e9a543936bb4f4d44e764b4e
This commit is contained in:
zhuyue 2021-09-01 16:30:35 +08:00
parent cd917640eb
commit 08c558a3ef
2 changed files with 40 additions and 9 deletions

View File

@ -22,6 +22,7 @@ import actionConfigs from './actions';
export default class PortForwarding extends Base { export default class PortForwarding extends Base {
init() { init() {
this.store = new PortForwardingStore(); this.store = new PortForwardingStore();
this.downloadStore = new PortForwardingStore();
} }
get policy() { get policy() {
@ -32,11 +33,7 @@ export default class PortForwarding extends Base {
return t('port forwardings'); return t('port forwardings');
} }
get isFilterByBackend() { updateFetchParamsByPage = (params) => {
return true;
}
updateFetchParams = (params) => {
const { id, all_projects, ...rest } = params; const { id, all_projects, ...rest } = params;
return { return {
fipId: id, fipId: id,
@ -45,6 +42,10 @@ export default class PortForwarding extends Base {
}; };
}; };
get isFilterByBackend() {
return true;
}
get actionConfigs() { get actionConfigs() {
return this.isAdminPage return this.isAdminPage
? actionConfigs.actionConfigsAdmin ? actionConfigs.actionConfigsAdmin
@ -55,7 +56,6 @@ export default class PortForwarding extends Base {
{ {
title: t('External Port'), title: t('External Port'),
dataIndex: 'external_port', dataIndex: 'external_port',
isHideable: true,
}, },
{ {
title: t('Internal Ip Address'), title: t('Internal Ip Address'),
@ -75,6 +75,25 @@ export default class PortForwarding extends Base {
]; ];
get searchFilters() { get searchFilters() {
return []; return [
{
label: t('Protocol'),
name: 'protocol',
options: [
{
label: 'TCP',
key: 'tcp',
},
{
label: 'UDP',
key: 'udp',
},
],
},
{
label: t('External Port'),
name: 'external_port',
},
];
} }
} }

View File

@ -163,8 +163,8 @@ export default class FloatingIps extends Base {
<Row className={styles.popover_row} gutter={[8, 8]}> <Row className={styles.popover_row} gutter={[8, 8]}>
{record.port_forwardings {record.port_forwardings
.sort((a, b) => a.external_port - b.external_port) .sort((a, b) => a.external_port - b.external_port)
.map((i) => ( .map((i, idx) => (
<Col span={24}> <Col span={24} key={`pfw-${idx}`}>
{`${record.floating_ip_address}:${i.external_port} => ${i.internal_ip_address}:${i.internal_port}`} {`${record.floating_ip_address}:${i.external_port} => ${i.internal_ip_address}:${i.internal_port}`}
</Col> </Col>
))} ))}
@ -180,6 +180,18 @@ export default class FloatingIps extends Base {
} }
return resource_name || ''; return resource_name || '';
}, },
stringify: (resource_name, record) => {
if (!resource_name && record.port_forwardings.length !== 0) {
const ret = record.port_forwardings
.sort((a, b) => a.external_port - b.external_port)
.map(
(i) =>
`${record.floating_ip_address}:${i.external_port} => ${i.internal_ip_address}:${i.internal_port}`
);
return ret.join('\n');
}
return resource_name;
},
isHideable: true, isHideable: true,
sorter: false, sorter: false,
}, },