From e4b19be5d7728624e356adfcdbbb7620aa033d6c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 24 Dec 2017 13:25:00 +0000 Subject: [PATCH] zoom to device on neighbor show; do not save positions on neighbor show --- share/views/ajax/device/netmap.tt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/share/views/ajax/device/netmap.tt b/share/views/ajax/device/netmap.tt index 554bbe39..31c89220 100644 --- a/share/views/ajax/device/netmap.tt +++ b/share/views/ajax/device/netmap.tt @@ -67,14 +67,13 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]?[% my_query %]', function(m graph.inspect().main.force.on('end.setupfornetdisco', function() { graph.inspect().main.nodes.each(function(n) { n.fixed = true }); - if (mapdata['v3']['newnodes']) { + if (mapdata['v3']['newnodes'] && ('[% params.mapshow %]' != 'neighbors')) { $.post( '[% uri_for('/ajax/data/device/netmappositions') %]' ,$("#nd_vlan-entry, #nd_devgrp-select, input[name='mapshow']").serialize() + '&positions=' + JSON.stringify(graph.positions()) ); } - // else { graph.zoomToFit() } graph.inspect().main.nodes.on('mouseup.dragall', function(n) { graph['nd2']['dragging'] = false; @@ -131,6 +130,13 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]?[% my_query %]', function(m .on("click", function() { requestFullScreen(document.getElementById('netmap_pane')); }); + + if ('[% params.mapshow %]' == 'neighbors') { + setTimeout(function() { + var node = graph.nodeDataById( graph['nd2']['centernode'] ); + graph.zoomSmooth(node.x, node.y, node.radius * 100); + }, 1000); + } }); });