auto save map positions
This commit is contained in:
@@ -151,24 +151,6 @@ $.getJSON('[% uri_for('/ajax/data/device/netmap') %]?[% my_query %]', function(m
|
||||
graph.inspect().main.force.on('start.draggednode', null);
|
||||
});
|
||||
|
||||
// ********************************************************
|
||||
// ********* save new node positions back to DB ***********
|
||||
// ********************************************************
|
||||
|
||||
graph.inspect().main.force.on('end.savepositions', function() {
|
||||
graph.inspect().main.nodes.each(function(n) { n.fixed = true });
|
||||
|
||||
if (mapdata['newnodes'] && ('[% params.mapshow %]' != 'neighbors')) {
|
||||
$.post(
|
||||
'[% uri_for('/ajax/data/device/netmappositions') %]'
|
||||
,$("#nd_vlan-entry, #nd_hgroup-select, input[name='mapshow']").serialize()
|
||||
+ '&positions=' + JSON.stringify(graph.positions())
|
||||
);
|
||||
}
|
||||
|
||||
graph.inspect().main.force.on('end.savepositions', null);
|
||||
});
|
||||
|
||||
// *****************************
|
||||
// ********* DO IT!! ***********
|
||||
// *****************************
|
||||
@@ -213,6 +195,7 @@ function spin(selection, duration) {
|
||||
duration = duration || 1500;
|
||||
if (! graph.inspect().status.forceRunning) {
|
||||
d3.select('#nd2_netmap-spinner').style('fill', '#CCFFCC').attr('d', circle);
|
||||
saveMapPositions();
|
||||
return;
|
||||
}
|
||||
d3.select('#nd2_netmap-spinner').style('fill', '#FFE4B5').attr('d', arc);
|
||||
@@ -225,6 +208,20 @@ function spin(selection, duration) {
|
||||
setTimeout(function() { spin(selection, duration); }, duration);
|
||||
}
|
||||
|
||||
// ********************************************************
|
||||
// ********* save new node positions back to DB ***********
|
||||
// ********************************************************
|
||||
|
||||
function saveMapPositions() {
|
||||
graph.inspect().main.nodes.each(function(n) { n.fixed = true });
|
||||
$.post(
|
||||
'[% uri_for('/ajax/data/device/netmappositions') %]'
|
||||
,$("#nd_vlan-entry, #nd_hgroup-select, #nd_lgroup-select, input[name='mapshow']").serialize()
|
||||
+ '&positions=' + JSON.stringify(graph.positions())
|
||||
);
|
||||
toastr.success('Saved map positions.');
|
||||
}
|
||||
|
||||
// ***********************************************
|
||||
// ************ full screen handling *************
|
||||
// ***********************************************
|
||||
|
||||
Reference in New Issue
Block a user