Skip to content

Commit

Permalink
Merge pull request #2582 from irontec/PROVIDER-1744-proxy-trunk-adver…
Browse files Browse the repository at this point in the history
…tised-address-issues

Proxy trunk advertised address issues
  • Loading branch information
mmadariaga authored Mar 22, 2024
2 parents 745032e + 2d6f7f5 commit e080e79
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
8 changes: 7 additions & 1 deletion web/portal/brand/src/entities/ProxyTrunk/ProxyTrunk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ const ProxyTrunk: EntityInterface = {
iden: 'ProxyTrunk',
title: _('Proxy Trunks', { count: 2 }),
path: '/proxy_trunks',
toStr: (row: ProxyTrunkPropertyList<EntityValues>) => `${row.ip}`,
toStr: (row: ProxyTrunkPropertyList<EntityValues>) => {
const ip = row.advertisedIp ? row.advertisedIp : row.ip;

const label = `${row.name} (${ip})`;

return label;
},
properties,
acl: {
...defaultEntityBehavior.acl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
export type ProxyTrunkPropertyList<T> = {
name?: T;
ip?: T;
advertisedIp?: T;
id?: T;
};

Expand Down
8 changes: 5 additions & 3 deletions web/portal/brand/src/entities/ProxyTrunk/SelectOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import defaultEntityBehavior from '@irontec/ivoz-ui/entities/DefaultEntityBehavi
import { SelectOptionsType } from '@irontec/ivoz-ui/entities/EntityInterface';
import store from 'store';

import { ProxyTrunkPropertiesList } from './ProxyTrunkProperties';

const ProxyTrunkSelectOptions: SelectOptionsType = ({
callback,
cancelToken,
Expand All @@ -12,11 +14,11 @@ const ProxyTrunkSelectOptions: SelectOptionsType = ({

return defaultEntityBehavior.fetchFks(
`${ProxyTrunk.path}?_order[ip]=ASC`,
['id', 'ip'],
(data) => {
['id', 'name', 'ip', 'advertisedIp'],
(data: ProxyTrunkPropertiesList) => {
const options: DropdownChoices = [];
for (const item of data) {
options.push({ id: item.id, label: item.ip });
options.push({ id: item.id as number, label: ProxyTrunk.toStr(item) });
}

callback(options);
Expand Down
9 changes: 7 additions & 2 deletions web/portal/platform/src/entities/ProxyTrunk/ProxyTrunk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ const ProxyTrunk: EntityInterface = {
iden: 'ProxyTrunk',
title: _('Proxy Trunk', { count: 2 }),
path: '/proxy_trunks',
toStr: (row: ProxyTrunkPropertyList<EntityValue>) =>
`${row.name} (${row.ip})`,
toStr: (row: ProxyTrunkPropertyList<EntityValue>) => {
const ip = row.advertisedIp ? row.advertisedIp : row.ip;

const label = `${row.name} (${ip})`;

return label;
},
columns: ['name', 'ip', 'advertisedIp'],
properties,
ChildDecorator,
Expand Down
7 changes: 2 additions & 5 deletions web/portal/platform/src/entities/ProxyTrunk/SelectOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ const ProxyTrunkSelectOptions: SelectOptionsType = ({

return defaultEntityBehavior.fetchFks(
`${ProxyTrunk.path}?_order[name]=ASC`,
['id', 'ip', 'name'],
['id', 'ip', 'name', 'advertisedIp'],
(data: ProxyTrunkPropertiesList) => {
const options: DropdownChoices = [];
for (const item of data) {
options.push({
id: item.id as number,
label: `${item.name} (${item.ip})`,
});
options.push({ id: item.id as number, label: ProxyTrunk.toStr(item) });
}

callback(options);
Expand Down

0 comments on commit e080e79

Please sign in to comment.