From f9e5ec02ab8fcba35ccd610ebc8a2e7a6a4b9610 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 23 Dec 2017 17:44:41 +0000 Subject: [PATCH] tweak mapshow --- lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm | 15 +++++++++------ share/views/ajax/device/netmap.tt | 6 +++++- share/views/sidebar/device/netmap.tt | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm index 60fbc57f..29425774 100644 --- a/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm +++ b/lib/App/Netdisco/Web/Plugin/Device/Neighbors.pm @@ -49,6 +49,11 @@ ajax '/ajax/data/device/netmappositions' => require_login sub { } }; +# mapshow=all,neighbors,only +# devgrp[] +# colorgroups +# dynamicsize + ajax '/ajax/data/device/netmap' => require_login sub { my $q = param('q'); my $qdev = schema('netdisco')->resultset('Device') @@ -57,11 +62,9 @@ ajax '/ajax/data/device/netmap' => require_login sub { my $vlan = param('vlan'); undef $vlan if (defined $vlan and $vlan !~ m/^\d+$/); - my $mapshow = (param('mapshow') || 'groups'); - if (not $qdev or not $qdev->in_storage - or (defined $mapshow and $mapshow !~ m/^(?:neighbors|groups)$/)) { - $mapshow = 'groups'; - } + my $mapshow = (param('mapshow') || 'neighbors'); + $mapshow = 'neighbors' if $mapshow !~ m/^(?:all|neighbors|only)$/; + $mapshow = 'all' unless $qdev->in_storage; my %id_for = (); my %ok_dev = (); @@ -123,7 +126,7 @@ ajax '/ajax/data/device/netmap' => require_login sub { $v3data{nodes}->{ ($device->{row_number} - 1) } = { ID => $device->{ip}, SIZEVALUE => 3000, - COLORVALUE => 10, + (param('colorgroups') ? (COLORVALUE => 10) : ()), LABEL => $name, }; diff --git a/share/views/ajax/device/netmap.tt b/share/views/ajax/device/netmap.tt index 9a9c0e88..6bc55a7f 100644 --- a/share/views/ajax/device/netmap.tt +++ b/share/views/ajax/device/netmap.tt @@ -37,7 +37,8 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]',{ jQuery(document).ready(function() { window.graph = netGobrechtsD3Force('netmap_pane') - // .debug(true) + .debug(true) + [% '.showLegend(false)' IF NOT params.colorgroups %] .lassoMode(true) .dragMode(true) .nodeEventToOpenLink('click') @@ -75,6 +76,9 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]',{ ,'vlan=[% params.vlan %]&positions=' + JSON.stringify(graph.positions()) ); } + // else { + // graph.zoomToFit(); + // } graph.inspect().main.nodes.on('mouseup.dragall', function(n) { graph['nd2']['dragging'] = false; diff --git a/share/views/sidebar/device/netmap.tt b/share/views/sidebar/device/netmap.tt index 081369a0..2a76dcd1 100644 --- a/share/views/sidebar/device/netmap.tt +++ b/share/views/sidebar/device/netmap.tt @@ -50,7 +50,8 @@
- +