working folters and colors for host group and location
This commit is contained in:
@@ -14,8 +14,9 @@ __PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
sum( COALESCE(dpp.raw_speed,1) ) as total
|
||||
FROM device_port
|
||||
LEFT OUTER JOIN device_port_properties dpp USING (ip, port)
|
||||
WHERE type = 'ethernetCsmacd'
|
||||
AND speed LIKE '%bps'
|
||||
WHERE type !~* '^(53|ieee8023adLag|propVirtual|l2vlan|l3ipvlan|135|136|137)\$'
|
||||
AND port !~* 'vlan'
|
||||
AND name !~* 'vlan'
|
||||
GROUP BY ip
|
||||
ORDER BY total DESC
|
||||
ENDSQL
|
||||
|
||||
@@ -41,7 +41,7 @@ hook 'before_template' => sub {
|
||||
}
|
||||
|
||||
# used in the device search sidebar template to set selected items
|
||||
foreach my $opt (qw/hgroup location/) {
|
||||
foreach my $opt (qw/hgroup lgroup/) {
|
||||
my $p = (ref [] eq ref param($opt) ? param($opt)
|
||||
: (param($opt) ? [param($opt)] : []));
|
||||
$tokens->{"${opt}_lkp"} = { map { $_ => 1 } @$p };
|
||||
@@ -82,7 +82,7 @@ get '/device' => require_login sub {
|
||||
params->{'tab'} ||= 'details';
|
||||
template 'device', {
|
||||
display_name => ($others ? $first->ip : ($first->dns || $first->ip)),
|
||||
location_list => [ schema('netdisco')->resultset('Device')->get_distinct_col('location') ],
|
||||
lgroup_list => [ schema('netdisco')->resultset('Device')->get_distinct_col('location') ],
|
||||
hgroup_list => setting('host_group_displaynames'),
|
||||
device => params->{'tab'},
|
||||
};
|
||||
|
||||
@@ -109,8 +109,9 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
my $vlan = param('vlan');
|
||||
undef $vlan if (defined $vlan and $vlan !~ m/^\d+$/);
|
||||
|
||||
my $colorby = (param('colorby') || 'speed');
|
||||
my $mapshow = (param('mapshow') || 'neighbors');
|
||||
$mapshow = 'neighbors' if $mapshow !~ m/^(?:all|neighbors|location|hgroup)$/;
|
||||
$mapshow = 'neighbors' if $mapshow !~ m/^(?:all|neighbors)$/;
|
||||
$mapshow = 'all' unless $qdev->in_storage;
|
||||
|
||||
# list of groups selected by user and passed in param
|
||||
@@ -181,27 +182,30 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
next DEVICE if (($mapshow eq 'neighbors') or $vlan)
|
||||
and (not $ok_dev{$device->ip});
|
||||
|
||||
# if in locations mode then filter
|
||||
next DEVICE if $mapshow eq 'location' and ((!defined $device->location)
|
||||
or (0 == scalar grep {$_ eq $device->location} @lgrplist));
|
||||
# if location picked then filter
|
||||
next DEVICE if ((scalar @lgrplist) and ((!defined $device->location)
|
||||
or (0 == scalar grep {$_ eq $device->location} @lgrplist)));
|
||||
|
||||
# if in host group mode then use ACLs to filter
|
||||
# if host groups piked then use ACLs to filter
|
||||
my $first_hgrp =
|
||||
first { check_acl_only($device, setting('host_groups')->{$_}) } @hgrplist;
|
||||
next DEVICE if $mapshow eq 'hgroup' and not $first_hgrp;
|
||||
next DEVICE if ((scalar @hgrplist) and (not $first_hgrp));
|
||||
|
||||
++$logvals{ $device->get_column('log') || 1 };
|
||||
(my $name = lc($device->dns || $device->name || $device->ip)) =~ s/$domain$//;
|
||||
|
||||
my %color_lkp = (
|
||||
speed => (($device->get_column('log') || 1) * 1000),
|
||||
hgroup => ($first_hgrp ?
|
||||
setting('host_group_displaynames')->{$first_hgrp} : 'Other'),
|
||||
lgroup => ($device->location || 'Other'),
|
||||
);
|
||||
|
||||
my $node = {
|
||||
ID => $device->ip,
|
||||
SIZEVALUE => (param('dynamicsize') ?
|
||||
(($device->get_column('log') || 1) * 1000) : 3000),
|
||||
(param('colorgroups') ?
|
||||
(COLORVALUE => ($first_hgrp ? setting('host_group_displaynames')->{$first_hgrp}
|
||||
: 'Other')) : ()),
|
||||
LABEL => (param('showips')
|
||||
? (($name eq $device->ip) ? $name : ($name .' '. $device->ip)) : $name),
|
||||
SIZEVALUE => (param('dynamicsize') ? $color_lkp{speed} : 3000),
|
||||
((exists $color_lkp{$colorby}) ? (COLORVALUE => $color_lkp{$colorby}) : ()),
|
||||
LABEL => $name,
|
||||
ORIG_LABEL => $name,
|
||||
INFOSTRING => make_node_infostring($device),
|
||||
LINK => uri_for('/device', {
|
||||
@@ -211,7 +215,7 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
||||
})->path_query,
|
||||
};
|
||||
|
||||
if ($mapshow ne 'neighbors' and exists $pos_for->{$device->ip}) {
|
||||
if (exists $pos_for->{$device->ip}) {
|
||||
$node->{'fixed'} = 1;
|
||||
$node->{'x'} = $pos_for->{$device->ip}->{'x'};
|
||||
$node->{'y'} = $pos_for->{$device->ip}->{'y'};
|
||||
|
||||
@@ -139,8 +139,7 @@ sidebar_defaults:
|
||||
showips: { default: null }
|
||||
showspeed: { default: null }
|
||||
mapshow: { default: neighbors }
|
||||
colorby: { default: location }
|
||||
colorgroups: { default: checked }
|
||||
colorby: { default: speed }
|
||||
dynamicsize: { default: checked }
|
||||
report_moduleinventory:
|
||||
fruonly: { default: checked }
|
||||
|
||||
@@ -18,7 +18,7 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]?[% my_query %]', function(m
|
||||
.dragMode(true)
|
||||
.zoomMode(true)
|
||||
.pinMode(true)
|
||||
[% '.showLegend(false)' IF NOT params.colorgroups %]
|
||||
[% '.showLegend(false)' UNLESS (params.colorby == 'hgroup' OR params.colorby == 'lgroup') %]
|
||||
.showLinkDirection(false)
|
||||
.colorScheme('color10')
|
||||
//.preventLabelOverlappingOnForceEnd(
|
||||
|
||||
@@ -86,12 +86,12 @@
|
||||
[% END %]
|
||||
</select>
|
||||
[% END %]
|
||||
[% IF location_list.size %]
|
||||
<select class="nd_side-select" size="[% location_list.size > 4 ? 4 : location_list.size %]"
|
||||
[% IF lgroup_list.size %]
|
||||
<select class="nd_side-select" size="[% lgroup_list.size > 4 ? 4 : lgroup_list.size %]"
|
||||
multiple="on" name="lgroup" id="nd_lgroup-select"
|
||||
rel="tooltip" data-placement="left" data-offset="5" data-title="Device Locations"/>
|
||||
[% FOREACH loc IN location_list %]
|
||||
<option[% ' selected="selected"' IF location_lkp.exists(loc) %]
|
||||
[% FOREACH loc IN lgroup_list %]
|
||||
<option[% ' selected="selected"' IF lgroup_lkp.exists(loc) %]
|
||||
value="[% loc %]">[% loc | html_entity %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
@@ -99,16 +99,21 @@
|
||||
|
||||
<div class="clearfix nd_netmap-sidebar">
|
||||
|
||||
[% IF hgroup_list.size OR location_list.size %]
|
||||
[% IF hgroup_list.size OR lgroup_list.size %]
|
||||
<div class="clearfix input-prepend">
|
||||
<label><span id="nd_colorby-label-text">Color by: </span>
|
||||
<select id="nd_colorby" name="colorby">
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'off' %]>Off</option>
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'off' %]
|
||||
value="off">Off</option>
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'speed' %]
|
||||
value="speed">Throughput</option>
|
||||
[% IF hgroup_list.size %]
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'hgroup' %]>Group</option>
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'hgroup' %]
|
||||
value="hgroup">Host Group</option>
|
||||
[% END %]
|
||||
[% IF location_list.size %]
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'location' %]>Location</option>
|
||||
[% IF lgroup_list.size %]
|
||||
<option[% ' selected="selected"' IF vars.sidebar_defaults.device_netmap.colorby == 'lgroup' %]
|
||||
value="lgroup">Location</option>
|
||||
[% END %]
|
||||
</select>
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user