tweak mapshow

This commit is contained in:
Oliver Gorwits
2017-12-23 17:44:41 +00:00
parent 9f9971ff4e
commit f9e5ec02ab
3 changed files with 16 additions and 8 deletions

View File

@@ -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,
};

View File

@@ -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;

View File

@@ -50,7 +50,8 @@
<hr class="nd_sidebar-hr"/>
<div class="radio radio-success">
<input type="radio" name="mapshow" id="nd_mapshow-all" value="all">
<input type="radio" name="mapshow" id="nd_mapshow-all"
[% 'checked' IF params.mapshow == 'all' %] value="all">
<label for="nd_mapshow-all">All Devices</label>
</div>
<div class="radio radio-success">