Cleanup Port hover minigraph description when using "Interface Description Parsing" (#13143)

* Cleanup Port hover minigraph description.
Use port_descr_descr if exists or ifDescr.
Use the same generate_port_link() in:
- Devices - Ports
- Ports - All/Errored/Ignored
- Ports - "Types"

* Port-Customers, using Ajax Controller,  Util/Url

* make https://styleci.io/ check happy
This commit is contained in:
fbourqui
2021-08-18 13:02:01 +02:00
committed by GitHub
parent e9c89b3778
commit f1dc4435e3
4 changed files with 9 additions and 16 deletions

View File

@@ -135,7 +135,9 @@ class Url
}
$content = '<div class=list-large>' . addslashes(htmlentities($port->device->displayName() . ' - ' . $label)) . '</div>';
if ($port->ifAlias) {
if ($port['port_descr_descr']) {
$content .= addslashes(\LibreNMS\Util\Clean::html($port['port_descr_descr'], [])) . '<br />';
} elseif ($port['ifAlias']) {
$content .= addslashes(htmlentities($port->ifAlias)) . '<br />';
}

View File

@@ -347,7 +347,9 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
}
$content = '<div class=list-large>' . $port['hostname'] . ' - ' . Rewrite::normalizeIfName(addslashes(\LibreNMS\Util\Clean::html($port['label'], []))) . '</div>';
if ($port['ifAlias']) {
if ($port['port_descr_descr']) {
$content .= addslashes(\LibreNMS\Util\Clean::html($port['port_descr_descr'], [])) . '<br />';
} elseif ($port['ifAlias']) {
$content .= addslashes(\LibreNMS\Util\Clean::html($port['ifAlias'], [])) . '<br />';
}

View File

@@ -101,19 +101,9 @@ if ($vars['view'] == 'minigraphs') {
echo "<div style='display: block; clear: both; margin: auto; min-height: 500px;'>";
unset($seperator);
// FIXME - FIX THIS. UGLY.
foreach (dbFetchRows('select * from ports WHERE device_id = ? AND `disabled` = 0 ORDER BY ifIndex', [$device['device_id']]) as $port) {
$port = cleanPort($port, $device);
echo "<div class='minigraph-div'><div style='font-weight: bold;'>" . makeshortif($port['ifDescr']) . '</div>
<a href="' . generate_port_url($port) . "\" onmouseover=\"return overlib('<div class=\'overlib-content\'>\
<div class=\'overlib-text\'>" . $device['hostname'] . ' - ' . $port['ifDescr'] . "</div>\
<span class=\'overlib-title\'>" . $port['ifAlias'] . "</span>\
<img src=\'graph.php?type=" . $graph_type . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . \LibreNMS\Config::get('time.now') . "&amp;width=450&amp;height=150\'>\
</div>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >" . "<img src='graph.php?type=" . $graph_type . '&amp;id=' . $port['port_id'] . '&amp;from=' . $from . '&amp;to=' . \LibreNMS\Config::get('time.now') . "&amp;width=180&amp;height=45&amp;legend=no'>
</a>
<div style='font-size: 9px;'>" . substr(short_port_descr($port['ifAlias']), 0, 32) . '</div>
</div>';
echo "<div class='minigraph-div'><div style='font-weight: bold;'>" . generate_port_link($port) . '</div>';
}
echo '</div>';

View File

@@ -52,9 +52,8 @@ if ($if_list) {
}
echo "<tr class='iftype'>
<td><span class=list-large>" . generate_port_link($port, $port['port_descr_descr']) . "</span><br />
<span class=interface-desc style='float: left;'>" . generate_device_link($port) . ' ' . generate_port_link($port) . ' </span></td>
<td>' . generate_port_link($port, makeshortif($port['ifDescr'])) . '</td>
<td><span class=list-large>" . generate_port_link($port) . "</span><br />
<span class=interface-desc style='float: left;'>" . generate_device_link($port) . ' - ' . generate_port_link($port) . ' </span></td>
<td>' . $port['port_descr_speed'] . '</td>
<td>' . $port['port_descr_circuit'] . '</td>
<td>' . $port['port_descr_notes'] . "</td>