node colors!
This commit is contained in:
@@ -5,6 +5,7 @@ use Dancer::Plugin::Ajax;
|
|||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
use Dancer::Plugin::Auth::Extensible;
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
|
use List::Util 'first';
|
||||||
use List::MoreUtils ();
|
use List::MoreUtils ();
|
||||||
use App::Netdisco::Util::Permission 'check_acl_only';
|
use App::Netdisco::Util::Permission 'check_acl_only';
|
||||||
use App::Netdisco::Web::Plugin;
|
use App::Netdisco::Web::Plugin;
|
||||||
@@ -117,20 +118,22 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
|||||||
'+select' => [\'row_number() over()'], '+as' => ['row_number'],
|
'+select' => [\'row_number() over()'], '+as' => ['row_number'],
|
||||||
});
|
});
|
||||||
|
|
||||||
NODE: while (my $device = $devices->next) {
|
# list of groups selected by user and passed in param
|
||||||
|
my $devgrp = (ref [] eq ref param('devgrp') ? param('devgrp') : [param('devgrp')]);
|
||||||
|
# list of groups validated as real host groups and named host groups
|
||||||
|
my @hgrplist = grep { exists setting('host_group_displaynames')->{$_} }
|
||||||
|
grep { exists setting('host_groups')->{$_} }
|
||||||
|
grep { defined } @{ $devgrp };
|
||||||
|
|
||||||
|
DEVICE: while (my $device = $devices->next) {
|
||||||
# if in neighbors or vlan mode then use %ok_dev to filter
|
# if in neighbors or vlan mode then use %ok_dev to filter
|
||||||
next NODE if (($mapshow eq 'neighbors') or $vlan)
|
next DEVICE if (($mapshow eq 'neighbors') or $vlan)
|
||||||
and (not $ok_dev{$device->ip});
|
and (not $ok_dev{$device->ip});
|
||||||
|
|
||||||
# if in only mode then use ACLs to filter
|
# if in only mode then use ACLs to filter
|
||||||
if ($mapshow eq 'only') {
|
my $first_hgrp =
|
||||||
my $devgrp = (ref [] eq ref param('devgrp') ? param('devgrp') : [param('devgrp')]);
|
first { check_acl_only($device, setting('host_groups')->{$_}) } @hgrplist;
|
||||||
next NODE unless scalar grep { check_acl_only($device, $_) }
|
next DEVICE if $mapshow eq 'only' and not $first_hgrp;
|
||||||
grep { defined }
|
|
||||||
map { setting('host_groups')->{$_} }
|
|
||||||
grep { defined }
|
|
||||||
@{ $devgrp };
|
|
||||||
}
|
|
||||||
|
|
||||||
$id_for{$device->ip} = $device->get_column('row_number');
|
$id_for{$device->ip} = $device->get_column('row_number');
|
||||||
(my $name = ($device->dns || lc($device->name) || $device->ip)) =~ s/$domain$//;
|
(my $name = ($device->dns || lc($device->name) || $device->ip)) =~ s/$domain$//;
|
||||||
@@ -138,7 +141,8 @@ ajax '/ajax/data/device/netmap' => require_login sub {
|
|||||||
$v3data{nodes}->{ ($device->get_column('row_number') - 1) } = {
|
$v3data{nodes}->{ ($device->get_column('row_number') - 1) } = {
|
||||||
ID => $device->ip,
|
ID => $device->ip,
|
||||||
SIZEVALUE => 3000,
|
SIZEVALUE => 3000,
|
||||||
(param('colorgroups') ? (COLORVALUE => 10) : ()),
|
(param('colorgroups') ?
|
||||||
|
(COLORVALUE => ($first_hgrp ? setting('host_group_displaynames')->{$first_hgrp} : 'Other')) : ()),
|
||||||
LABEL => $name,
|
LABEL => $name,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]?[% my_query %]', function(m
|
|||||||
.pinMode(true)
|
.pinMode(true)
|
||||||
.nodeEventToStopPinMode('none')
|
.nodeEventToStopPinMode('none')
|
||||||
.showLinkDirection(false)
|
.showLinkDirection(false)
|
||||||
|
.colorScheme('color20')
|
||||||
// .preventLabelOverlappingOnForceEnd(true)
|
// .preventLabelOverlappingOnForceEnd(true)
|
||||||
// .zoomToFitOnForceEnd(true)
|
// .zoomToFitOnForceEnd(true)
|
||||||
.width( parseInt(jQuery('#netmap_pane').parent().css('width')) )
|
.width( parseInt(jQuery('#netmap_pane').parent().css('width')) )
|
||||||
|
|||||||
Reference in New Issue
Block a user