system: adjust address display in interfaces widget #7707

This commit is contained in:
Franco Fichtner 2024-08-02 11:08:37 +02:00
parent ec7d2f9ac1
commit 6f10caef26
2 changed files with 9 additions and 10 deletions

View File

@ -111,9 +111,10 @@ class OverviewController extends ApiControllerBase
$cfg = Config::getInstance()->object();
$result = [];
/* quick information */
/* abbreviated information */
$ifinfo = json_decode($backend->configdpRun('interface list ifconfig', [$interface]), true);
$routes = json_decode($backend->configdRun('interface routes list -n json'), true);
$ifaddr = json_decode($backend->configdRun('interface address'), true);
/* detailed information */
if ($detailed) {
@ -180,6 +181,11 @@ class OverviewController extends ApiControllerBase
$tmp['description'] = !empty($config['descr']) ? $config['descr'] : strtoupper($config['identifier']);
$tmp['enabled'] = !empty($config['enable']);
$tmp['link_type'] = !empty($config['ipaddr']) ? $config['ipaddr'] : 'none';
foreach ([4, 6] as $primary) {
$addr = $ifaddr[$config['identifier']][$primary != 4] ?? [];
$tmp['addr' . $primary] = !empty($addr['address']) ?
"{$addr['address']}/{$addr['bits']}" : '';
}
if (Util::isIpAddress($tmp['link_type'])) {
$tmp['link_type'] = 'static';
} elseif (empty($config['ipaddr']) && !empty(!empty($config['ipaddrv6']))) {

View File

@ -85,15 +85,8 @@ export default class Interfaces extends BaseTableWidget {
</div>
`).prop('outerHTML'));
let ipv4 = '';
let ipv6 = '';
if ('ipv4' in intf_data && intf_data.ipv4.length > 0) {
ipv4 = intf_data.ipv4[0].ipaddr;
}
if ('ipv6' in intf_data && intf_data.ipv6.length > 0) {
ipv6 = intf_data.ipv6[0].ipaddr;
}
let ipv4 = intf_data.addr4;
let ipv6 = intf_data.addr6;
row.push($(`
<div class="interface-info">