Skip to content

Commit cc10f27

Browse files
committed
Final graph.php removals and overlib() js
1 parent b65ad3c commit cc10f27

9 files changed

Lines changed: 40 additions & 54 deletions

File tree

LibreNMS/Util/Url.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use App\Models\Device;
3131
use App\Models\Port;
3232
use Carbon\Carbon;
33+
use Illuminate\Contracts\Support\Htmlable;
3334
use Illuminate\Support\Facades\Gate;
3435
use Illuminate\Support\Facades\URL as LaravelUrl;
3536
use Illuminate\Support\Str;
@@ -64,10 +65,7 @@ public static function modernDeviceLink(?Device $device, string $text = '', stri
6465
);
6566
}
6667

67-
/**
68-
* Provisional port link generation
69-
*/
70-
public static function modernPortLink(?Port $port, string $text = '', string $extra = ''): string
68+
public static function modernPortLink(?Port $port, Htmlable|string $text = '', string $extra = ''): string
7169
{
7270
if ($port === null) {
7371
return e($text);

includes/html/pages/device/health/processor.inc.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,15 @@
55
$processors = dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', [$device['device_id']]);
66

77
foreach ($processors as $proc) {
8-
$id = 'id';
9-
$val = $proc['processor_id'];
10-
$proc_url = 'graphs/' . $id . '=' . $val . '/type=processor_usage/';
11-
$base_url = 'graph.php?' . $id . '=' . $val . '&type=processor_usage&from=' . \App\Facades\LibrenmsConfig::get('time.day') . '&to=' . \App\Facades\LibrenmsConfig::get('time.now');
8+
$proc_url = 'graphs/id=' . $proc['processor_id'] . '/type=processor_usage/';
9+
$base_url = route('graph', ['type' => 'processor_usage', 'id' => $proc['processor_id'], 'from' => '-1d']);
1210
$mini_url = $base_url . '&width=80&height=20&bg=f4f4f4';
1311

1412
$text_descr = rewrite_entity_descr($proc['processor_descr']);
1513

16-
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . ' - ' . $text_descr;
17-
$proc_popup .= "</div><img src=\'" . $base_url . "&amp;width=400&amp;height=125\'>";
18-
$proc_popup .= "', RIGHT" . \App\Facades\LibrenmsConfig::get('overlib_defaults') . ');" onmouseout="return nd();"';
1914
$percent = round($proc['processor_usage']);
2015

21-
$graph_array[$id] = $val;
16+
$graph_array['id'] = $proc['processor_id'];
2217
$graph_array['type'] = 'processor_usage';
2318

2419
echo "<div class='panel panel-default'>

includes/html/pages/device/health/storage.inc.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424

2525
$fs_url = 'graphs/id=' . $drive['storage_id'] . '/type=storage_usage/';
2626

27-
$fs_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . ' - ' . $storage_descr;
28-
$fs_popup .= "</div><img src=\'graph.php?id=" . $drive['storage_id'] . '&amp;type=' . $graph_type . '&amp;from=' . \App\Facades\LibrenmsConfig::get('time.month') . '&amp;to=' . \App\Facades\LibrenmsConfig::get('time.now') . "&amp;width=400&amp;height=125\'>";
29-
$fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
30-
3127
$graph_array['id'] = $drive['storage_id'];
3228
$graph_array['type'] = $graph_type;
3329

includes/html/pages/device/hrdevice.inc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
if ($hrdevice['hrDeviceType'] == 'hrDeviceProcessor') {
1212
$proc_id = dbFetchCell("SELECT processor_id FROM processors WHERE device_id = '" . $device['device_id'] . "' AND hrDeviceIndex = '" . $hrdevice['hrDeviceIndex'] . "'");
1313
$proc_url = 'device/device=' . $device['device_id'] . '/tab=health/metric=processor/';
14-
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . ' - ' . $hrdevice['hrDeviceDescr'];
15-
$proc_popup .= "</div><img src=\'graph.php?id=" . $proc_id . '&amp;type=processor_usage&amp;from=' . \App\Facades\LibrenmsConfig::get('time.month') . '&amp;to=' . \App\Facades\LibrenmsConfig::get('time.now') . "&amp;width=400&amp;height=125\'>";
16-
$proc_popup .= "', RIGHT" . \App\Facades\LibrenmsConfig::get('overlib_defaults') . ');" onmouseout="return nd();"';
17-
echo "<td><a href='$proc_url' $proc_popup>" . $hrdevice['hrDeviceDescr'] . '</a></td>';
14+
$popup_content = '<div class="list-large">' . e($device['hostname']) . ' - ' . e($hrdevice['hrDeviceDescr']) . '</div>' .
15+
LibreNMS\Util\Url::graphTag(['id' => $proc_id, 'type' => 'processor_usage', 'from' => App\Facades\LibrenmsConfig::get('time.month'), 'to' => App\Facades\LibrenmsConfig::get('time.now'), 'width' => 400, 'height' => 125]);
16+
$proc_link = LibreNMS\Util\Url::overlibLink($proc_url, e($hrdevice['hrDeviceDescr']), $popup_content);
17+
echo "<td>$proc_link</td>";
1818

1919
$graph_array['height'] = '20';
2020
$graph_array['width'] = '100';

includes/html/pages/device/port/macaccounting.inc.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333

3434
$i = 1;
35-
$inf = \LibreNMS\Util\Rewrite::normalizeIfName($ifname);
35+
$inf = LibreNMS\Util\Rewrite::normalizeIfName($ifname);
3636

3737
echo "<div style='clear: both;'>";
3838

@@ -131,7 +131,7 @@
131131
} else {
132132
$row_colour = LibrenmsConfig::get('list_colour.odd');
133133
}
134-
$ipv4 = \App\Models\Ipv4Mac::where('mac_address', $acc['mac'])->value('ipv4_address');
134+
$ipv4 = App\Models\Ipv4Mac::where('mac_address', $acc['mac'])->value('ipv4_address');
135135
$arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', [$ipv4]);
136136
$arp_host = cleanPort($arp_host);
137137
if ($arp_host) {
@@ -165,13 +165,14 @@
165165
$asn = 'No Session';
166166
}
167167

168+
$popup_content = '<div style="font-size: 16px; padding:5px; font-weight: bold; color: #555555;">' . e($name . ' - ' . $ipv4 . ' - ' . $asn) . '</div>' .
169+
'<img src="' . route('graph', ['id' => $acc['ma_id'], 'type' => $graph_type, 'from' => LibrenmsConfig::get('time.twoday'), 'width' => 450, 'height' => 150]) . '">';
170+
$link_text = "<img src='" . e(route('graph', ['id' => $acc['ma_id'], 'type' => $graph_type, 'from' => LibrenmsConfig::get('time.twoday'), 'width' => 213, 'height' => 45])) . "'>";
171+
$overlib_link = Url::overlibLink('#', $link_text, $popup_content);
172+
168173
echo "<div style='display: block; padding: 3px; margin: 3px; min-width: 221px; max-width:221px; min-height:90px; max-height:90px; text-align: center; float: left;'>
169174
" . $ipv4 . ' - ' . $asn . "
170-
<a href='#' onmouseover=\"return overlib('\
171-
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #555555;\'>" . $name . ' - ' . $ipv4 . ' - ' . $asn . "</div>\
172-
<img src=\'" . e(route('graph', ['id' => $acc['ma_id'], 'type' => $graph_type, 'from' => LibrenmsConfig::get('time.twoday'), 'width' => 450, 'height' => 150])) . "\'>\
173-
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >
174-
<img src='" . e(route('graph', ['id' => $acc['ma_id'], 'type' => $graph_type, 'from' => LibrenmsConfig::get('time.twoday'), 'width' => 213, 'height' => 45])) . "'></a>
175+
$overlib_link
175176
176177
<span style='font-size: 10px;'>" . $name . '</span>
177178
</div>';

includes/html/pages/device/port/pagp.inc.php

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
<?php
22

3-
use App\Facades\LibrenmsConfig;
3+
use LibreNMS\Util\Url;
44

55
// FIXME functions!
66
if (! $graph_type) {
77
$graph_type = 'pagp_bits';
88
}
99

10-
$daily_traffic = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.day') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=215&amp;height=100';
11-
$daily_url = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.day') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=500&amp;height=150';
10+
$daily_traffic = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1d', 'width' => 215, 'height' => 100]));
11+
$daily_url = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1d', 'width' => 500, 'height' => 150]));
1212

13-
$weekly_traffic = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.week') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=215&amp;height=100';
14-
$weekly_url = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.week') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=500&amp;height=150';
13+
$weekly_traffic = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1w', 'width' => 215, 'height' => 100]));
14+
$weekly_url = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1w', 'width' => 500, 'height' => 150]));
1515

16-
$monthly_traffic = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.month') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=215&amp;height=100';
17-
$monthly_url = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.month') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=500&amp;height=150';
16+
$monthly_traffic = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1mo', 'width' => 215, 'height' => 100]));
17+
$monthly_url = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1mo', 'width' => 500, 'height' => 150]));
1818

19-
$yearly_traffic = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.year') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=215&amp;height=100';
20-
$yearly_url = 'graph.php?port=' . $port['port_id'] . "&amp;type=$graph_type&amp;from=" . LibrenmsConfig::get('time.year') . '&amp;to=' . LibrenmsConfig::get('time.now') . '&amp;width=500&amp;height=150';
19+
$yearly_traffic = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1y', 'width' => 215, 'height' => 100]));
20+
$yearly_url = e(route('graph', ['port' => $port['port_id'], 'type' => $graph_type, 'from' => '-1y', 'width' => 500, 'height' => 150]));
2121

22-
echo "<a href='#' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT" . LibrenmsConfig::get('overlib_defaults') . ");\" onmouseout=\"return nd();\">
23-
<img src='$daily_traffic' border=0></a> ";
24-
echo "<a href='#' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT" . LibrenmsConfig::get('overlib_defaults') . ");\" onmouseout=\"return nd();\">
25-
<img src='$weekly_traffic' border=0></a> ";
26-
echo "<a href='#' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT" . LibrenmsConfig::get('overlib_defaults') . ", WIDTH, 350);\" onmouseout=\"return nd();\">
27-
<img src='$monthly_traffic' border=0></a> ";
28-
echo "<a href='#' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT" . LibrenmsConfig::get('overlib_defaults') . ", WIDTH, 350);\" onmouseout=\"return nd();\">
29-
<img src='$yearly_traffic' border=0></a>";
22+
echo Url::overlibLink('#', "<img src='$daily_traffic' border=0>", "<img src='$daily_url'>") . ' ';
23+
echo Url::overlibLink('#', "<img src='$weekly_traffic' border=0>", "<img src='$weekly_url'>") . ' ';
24+
echo Url::overlibLink('#', "<img src='$monthly_traffic' border=0>", "<img src='$monthly_url'>") . ' ';
25+
echo Url::overlibLink('#', "<img src='$yearly_traffic' border=0>", "<img src='$yearly_url'>");
3026

3127
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? and `device_id` = ?', [$port['ifIndex'], $device['device_id']]) as $member) {
3228
$member = cleanPort($member);

includes/html/pages/routing/vrf.inc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@
123123
echo "'>" . DeviceCache::get($device['device_id'])->displayName() . '</a> ';
124124

125125
if ($device['vrf_name'] != $vrf['vrf_name']) {
126-
echo "<a href='#' onmouseover=\" return overlib('Expected Name : " . $vrf['vrf_name'] . '<br />Configured : ' . $device['vrf_name'] . "', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i></a>";
126+
$overlib_content = '<div class="list-large">VRF Inconsistency</div>Expected Name : ' . e($vrf['vrf_name']) . '<br />Configured : ' . e($device['vrf_name']);
127+
echo \LibreNMS\Util\Url::overlibLink('#', " <i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i>", $overlib_content);
127128
}
128129

129130
echo '</td><td>';

includes/html/print-vrf.inc.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
$port = cleanPort($port, $device);
1717
if ($vars['view'] == 'graphs') {
1818
$graph_type = 'port_' . $vars['graph'];
19+
$popup_content = '<div style="font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;">' . e($device['hostname'] . ' - ' . $port['ifDescr']) . '</div>' .
20+
e($port['ifAlias']) .
21+
Url::graphTag(['type' => $graph_type, 'id' => $port['port_id'], 'from' => '-2d', 'width' => 450, 'height' => 150]);
22+
$link_text = Url::graphTag(['type' => $graph_type, 'id' => $port['port_id'], 'from' => '-2d', 'width' => 132, 'height' => 40, 'legend' => 'no']);
23+
$overlib_link = Url::overlibLink('device/' . $device['device_id'] . '/port/' . $port['port_id'] . '/', $link_text, $popup_content);
24+
1925
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: #e9e9e9;'>
2026
<div style='font-weight: bold;'>" . Rewrite::shortenIfName($port['ifDescr']) . "</div>
21-
<a href='device/" . $device['device_id'] . '/port/' . $port['port_id'] . "/' onmouseover=\"return overlib('\
22-
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>" . $device['hostname'] . ' - ' . $port['ifDescr'] . '</div>\
23-
' . $port['ifAlias'] .
24-
Url::graphTag(['type' => $graph_type, 'id' => $port['port_id'], 'from' => '-2d', 'width' => 450, 'height' => 150]) .
25-
"', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >" . Url::graphTag(['type' => $graph_type, 'id' => $port['port_id'], 'from' => '-2d', 'width' => 132, 'height' => 40, 'legend' => 'no']) .
26-
"</a>
27+
$overlib_link
2728
<div style='font-size: 9px;'>" . substr((string) short_port_descr($port['ifAlias']), 0, 22) . '</div>
2829
</div>';
2930
} else {

resources/views/device/tabs/vlans.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ class="form-control"
7777
@else
7878
<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: {{ \App\Facades\LibrenmsConfig::get('list_colour.odd_alt2') }}">
7979
<div style="font-weight: bold;">{{ $port->port->ifDescr }}</div>
80-
<a href="{{ route('device', ['device' => $device->device_id, 'tab' => 'port', 'vars' => 'port='.$port->port->port_id]) }}" onmouseover="return overlib('<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>{{ $device->hostname }}-{{ $port->port->ifDescr }}</div>{{ $port->port->ifAlias }}<img src=\'{{ route('graph', ['type' => 'port_' . $vars, 'id' => $port->$port->port_id, 'from' => '-2d', 'width' => 450, 'height' => 150]) }}\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);" onmouseout="return nd();">
81-
<img src="{{ route('graph', ['type' => 'port_' . $vars, 'id' => $port->port->port_id, 'from' => '-2d', 'width' => 132, 'height' => 40, 'legend' => 'no']) }}">
82-
</a>
80+
{!! \LibreNMS\Util\Url::modernPortLink($port->port, new \Illuminate\Support\HtmlString('<img src="' . e(route('graph', ['type' => 'port_' . $vars, 'id' => $port->port->port_id, 'from' => '-2d', 'width' => 132, 'height' => 40, 'legend' => 'no'])) . '">')) !!}
8381
<div style="font-size: 9px;">{{ $port->port->ifAlias }}</div>
8482
</div>
8583
@endif

0 commit comments

Comments
 (0)