mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Speedup vlans list in device VLANS tab (#11805)
* init * spaces and commas fix
This commit is contained in:
@@ -75,14 +75,8 @@ print_optionbar_end();
|
|||||||
|
|
||||||
echo '<table border="0" cellspacing="0" cellpadding="5" width="100%">';
|
echo '<table border="0" cellspacing="0" cellpadding="5" width="100%">';
|
||||||
|
|
||||||
$i = '1';
|
|
||||||
|
|
||||||
foreach (dbFetchRows("SELECT * FROM `vlans` WHERE `device_id` = ? ORDER BY 'vlan_vlan'", array($device['device_id'])) as $vlan) {
|
|
||||||
include 'includes/html/print-vlan.inc.php';
|
include 'includes/html/print-vlan.inc.php';
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
$pagetitle[] = 'VLANs';
|
$pagetitle[] = 'VLANs';
|
||||||
|
@@ -1,37 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!is_integer($i / 2)) {
|
|
||||||
$bg_colour = \LibreNMS\Config::get('list_colour.even');
|
|
||||||
} else {
|
|
||||||
$bg_colour = \LibreNMS\Config::get('list_colour.odd');
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "<tr bgcolor='$bg_colour'>";
|
|
||||||
|
|
||||||
echo '<td width=100 class=list-large> Vlan '.$vlan['vlan_vlan'].'</td>';
|
|
||||||
echo '<td width=200 class=box-desc>'.$vlan['vlan_name'].'</td>';
|
|
||||||
echo '<td class=list-bold>';
|
|
||||||
|
|
||||||
$vlan_ports = array();
|
$vlan_ports = array();
|
||||||
$traverse_ifvlan = true;
|
$vlans_data = array();
|
||||||
$otherports = dbFetchRows('SELECT * FROM `ports_vlans` AS V, `ports` as P WHERE V.`device_id` = ? AND V.`vlan` = ? AND P.port_id = V.port_id', array($device['device_id'], $vlan['vlan_vlan']));
|
|
||||||
foreach ($otherports as $otherport) {
|
foreach (dbFetchRows('SELECT * FROM `vlans` WHERE `device_id` = ? GROUP BY `vlan_vlan` ORDER BY `vlan_vlan`', array($device['device_id'])) as $vlan) {
|
||||||
if ($otherport['untagged']) {
|
foreach ($vlan as $k => $v) {
|
||||||
$traverse_ifvlan = false;
|
if ($k != "vlan_vlan") {
|
||||||
|
$vlans_data[$vlan['vlan_vlan']][$k]=$v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$vlan_ports[$otherport['ifIndex']] = $otherport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($traverse_ifvlan) {
|
$otherports = dbFetchRows('SELECT * FROM `ports_vlans` AS V, `ports` AS P WHERE V.`device_id` = ? AND P.port_id = V.port_id', array($device['device_id']));
|
||||||
$otherports = dbFetchRows('SELECT * FROM ports WHERE `device_id` = ? AND `ifVlan` = ?', array($device['device_id'], $vlan['vlan_vlan']));
|
foreach ($otherports as $n => $otherport) {
|
||||||
foreach ($otherports as $otherport) {
|
if (!$otherport['untagged']) {
|
||||||
$vlan_ports[$otherport['ifIndex']] = array_merge($otherport, array('untagged' => '1'));
|
if ($otherport['ifvlan'] == $otherport['vlan']) {
|
||||||
|
$otherport['untagged'] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$vlan_ports[$otherport['vlan']][$otherport['ifIndex']] = $otherport;
|
||||||
|
}
|
||||||
|
|
||||||
ksort($vlan_ports);
|
ksort($vlan_ports);
|
||||||
|
|
||||||
foreach ($vlan_ports as $port) {
|
$i=0;
|
||||||
|
foreach ($vlan_ports as $vlan => $ports) {
|
||||||
|
$bg_colour = \LibreNMS\Config::get('list_colour.odd');
|
||||||
|
if (!is_integer($i / 2)) {
|
||||||
|
$bg_colour = \LibreNMS\Config::get('list_colour.even');
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<tr bgcolor='$bg_colour'>";
|
||||||
|
echo '<td width=100 class=list-large> Vlan '.$vlan.'</td>';
|
||||||
|
echo '<td width=200 class=box-desc>'.$vlans_data[$vlan]['vlan_name'].'</td>';
|
||||||
|
echo '<td class=list-bold>';
|
||||||
|
|
||||||
|
foreach ($ports as $port_id => $port) {
|
||||||
$port = cleanPort($port, $device);
|
$port = cleanPort($port, $device);
|
||||||
if ($vars['view'] == 'graphs') {
|
if ($vars['view'] == 'graphs') {
|
||||||
echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: " . \LibreNMS\Config::get('list_colour.odd_alt2') . ";'>
|
echo "<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: " . \LibreNMS\Config::get('list_colour.odd_alt2') . ";'>
|
||||||
@@ -45,12 +49,13 @@ foreach ($vlan_ports as $port) {
|
|||||||
<div style='font-size: 9px;'>".substr(short_port_descr($port['ifAlias']), 0, 22).'</div>
|
<div style='font-size: 9px;'>".substr(short_port_descr($port['ifAlias']), 0, 22).'</div>
|
||||||
</div>';
|
</div>';
|
||||||
} else {
|
} else {
|
||||||
echo $vlan['port_sep'].generate_port_link($port, makeshortif($port['label']));
|
echo $vlans_data[$vlan]['port_sep'].generate_port_link($port, makeshortif($port['label']));
|
||||||
$vlan['port_sep'] = ', ';
|
$vlans_data[$vlan]['port_sep'] = ', ';
|
||||||
if ($port['untagged']) {
|
if ($port['untagged']) {
|
||||||
echo '(U)';
|
echo '(U)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end foreach
|
}
|
||||||
|
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user