link infostrings!
This commit is contained in:
@@ -15,24 +15,28 @@ __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
__PACKAGE__->table('device_links');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT dp.ip AS left_ip, array_agg(dp.port) AS left_port, array_agg(dp.name) AS left_descr,
|
||||
SELECT dp.ip AS left_ip, ld.dns AS left_dns, ld.name AS left_name,
|
||||
array_agg(dp.port) AS left_port, array_agg(dp.name) AS left_descr,
|
||||
sum(btrim(dp.speed, ' MGTbps')::float
|
||||
* (CASE btrim(dp.speed, ' 0123456789.')
|
||||
WHEN 'Gbps' THEN 1000
|
||||
WHEN 'Tbps' THEN 1000000
|
||||
ELSE 1 END)) AS aggspeed,
|
||||
count(*) AS aggports,
|
||||
dp2.ip AS right_ip, array_agg(dp2.port) AS right_port, array_agg(dp2.name) AS right_descr
|
||||
dp2.ip AS right_ip, rd.dns AS right_dns, rd.name AS right_name,
|
||||
array_agg(dp2.port) AS right_port, array_agg(dp2.name) AS right_descr
|
||||
|
||||
FROM device_port dp
|
||||
INNER JOIN device ld ON dp.ip = ld.ip
|
||||
INNER JOIN device_ip di ON dp.remote_ip = di.alias
|
||||
INNER JOIN device rd ON di.ip = rd.ip
|
||||
INNER JOIN device_port dp2 ON (di.ip = dp2.ip AND dp.remote_port = dp2.port)
|
||||
|
||||
WHERE dp.remote_port IS NOT NULL
|
||||
AND dp.type = 'ethernetCsmacd'
|
||||
AND dp.speed LIKE '%bps'
|
||||
AND dp.ip <= dp2.ip
|
||||
GROUP BY left_ip, right_ip
|
||||
GROUP BY left_ip, left_dns, left_name, right_ip, right_dns, right_name
|
||||
ORDER BY dp.ip
|
||||
ENDSQL
|
||||
);
|
||||
@@ -41,6 +45,12 @@ __PACKAGE__->add_columns(
|
||||
'left_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'left_dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'left_name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'left_port' => {
|
||||
data_type => '[text]',
|
||||
},
|
||||
@@ -56,6 +66,12 @@ __PACKAGE__->add_columns(
|
||||
'right_ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'right_dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'right_name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'right_port' => {
|
||||
data_type => '[text]',
|
||||
},
|
||||
|
||||
@@ -72,6 +72,25 @@ sub to_speed {
|
||||
return $speed;
|
||||
}
|
||||
|
||||
sub make_link_infostring {
|
||||
my $link = shift or return '';
|
||||
|
||||
my $domain = quotemeta( setting('domain_suffix') || '' );
|
||||
(my $left_name = lc($link->{left_dns} || $link->{left_name} || $link->{left_ip})) =~ s/$domain$//;
|
||||
(my $right_name = lc($link->{right_dns} || $link->{right_name} || $link->{right_ip})) =~ s/$domain$//;
|
||||
|
||||
if ($link->{aggports} == 1) {
|
||||
return sprintf '<strong>%s:%s</strong> (%s)<br><strong>%s:%s</strong> (%s)',
|
||||
$left_name, $link->{left_port}->[0], $link->{left_descr}->[0],
|
||||
$right_name, $link->{right_port}->[0], $link->{right_descr}->[0];
|
||||
}
|
||||
else {
|
||||
return sprintf '<strong>%s:(%s)</strong><br><strong>%s:(%s)</strong>',
|
||||
$left_name, join(',', @{$link->{left_port}}),
|
||||
$right_name, join(',', @{$link->{right_port}});
|
||||
}
|
||||
}
|
||||
|
||||
ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
my $q = param('q');
|
||||
my $qdev = schema('netdisco')->resultset('Device')
|
||||
@@ -122,6 +141,7 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
push @{$data{'links'}}, {
|
||||
FROMID => $link->{left_ip},
|
||||
TOID => $link->{right_ip},
|
||||
INFOSTRING => make_link_infostring($link),
|
||||
SPEED => to_speed($link->{aggspeed}),
|
||||
};
|
||||
|
||||
|
||||
@@ -478,6 +478,11 @@ td > form.nd_inline-form {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* netmap tooltip box */
|
||||
#netmap_pane_tooltip {
|
||||
width: unset;
|
||||
}
|
||||
|
||||
/* fixup for prepended checkbox in sidebar */
|
||||
.nd_searchcheckbox {
|
||||
width: 121px;
|
||||
|
||||
@@ -598,7 +598,8 @@ function netGobrechtsD3Force(domContainerId, options, apexPluginId, apexPageItem
|
||||
.attr("id", v.dom.containerId);
|
||||
} else {
|
||||
v.dom.container = d3.select("#" + v.dom.containerId);
|
||||
d3.selectAll("#" + v.dom.containerId + "_tooltip, #" + v.dom.containerId + "_customizing").remove();
|
||||
d3.selectAll("#" + v.dom.containerId + "_customizing").remove();
|
||||
// d3.selectAll("#" + v.dom.containerId + "_tooltip").remove();
|
||||
}
|
||||
|
||||
// create SVG element, if not existing (if we have an APEX context, it is already created from the APEX plugin )
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<div id="netmap_pane_tooltip" class="net_gobrechts_d3_force_tooltip" style="top: 0px; left: 0px;"></div>
|
||||
<script>
|
||||
|
||||
// ***********************************************
|
||||
|
||||
Reference in New Issue
Block a user