correct physics
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -60,6 +60,9 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// make nodes object available globally in order to update their physics and positions later
|
||||||
|
window.nodes = nodes;
|
||||||
|
|
||||||
const edges = new DataSet(
|
const edges = new DataSet(
|
||||||
topologyData.edges.map((node) => ({
|
topologyData.edges.map((node) => ({
|
||||||
...node,
|
...node,
|
||||||
@@ -76,6 +79,7 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
Promise.allSettled(
|
Promise.allSettled(
|
||||||
Object.entries(graph.getPositions(params.nodes)).map(
|
Object.entries(graph.getPositions(params.nodes)).map(
|
||||||
async ([nodeId, nodePosition]) => {
|
async ([nodeId, nodePosition]) => {
|
||||||
|
window.nodes.update({id: parseInt(nodeId), physics: false, x: nodePosition.x, y: nodePosition.y});
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
'/api/plugins/netbox_topology_views/save-coords/save_coords/',
|
'/api/plugins/netbox_topology_views/save-coords/save_coords/',
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -147,15 +147,6 @@ def create_node(
|
|||||||
if device.device_role.color != "":
|
if device.device_role.color != "":
|
||||||
node["color.border"] = "#" + device.device_role.color
|
node["color.border"] = "#" + device.device_role.color
|
||||||
|
|
||||||
dev_title = "<table><tbody> %s</tbody></table>" % (node_content)
|
|
||||||
|
|
||||||
node["title"] = dev_title
|
|
||||||
node["name"] = dev_name
|
|
||||||
node["label"] = dev_name
|
|
||||||
node["shape"] = "image"
|
|
||||||
node["href"] = device.get_absolute_url()
|
|
||||||
node["image"] = get_image_for_entity(device)
|
|
||||||
|
|
||||||
if group_id is None or group_id == "default":
|
if group_id is None or group_id == "default":
|
||||||
group_id = Coordinate.get_or_create_default_group(group_id)
|
group_id = Coordinate.get_or_create_default_group(group_id)
|
||||||
if not group_id:
|
if not group_id:
|
||||||
@@ -182,8 +173,18 @@ def create_node(
|
|||||||
node["physics"] = False
|
node["physics"] = False
|
||||||
elif save_coords:
|
elif save_coords:
|
||||||
node["physics"] = False
|
node["physics"] = False
|
||||||
elif save_coords:
|
else:
|
||||||
node["physics"] = False
|
node["physics"] = True
|
||||||
|
node["x"] = 0
|
||||||
|
node["y"] = 0
|
||||||
|
|
||||||
|
dev_title = "<table><tbody> %s</tbody></table>" % (node_content)
|
||||||
|
node["title"] = dev_title
|
||||||
|
node["name"] = dev_name
|
||||||
|
node["label"] = dev_name
|
||||||
|
node["shape"] = "image"
|
||||||
|
node["href"] = device.get_absolute_url()
|
||||||
|
node["image"] = get_image_for_entity(device)
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
@@ -329,7 +330,7 @@ def get_topology_data(
|
|||||||
ports = chain(interfaces, frontports, rearports)
|
ports = chain(interfaces, frontports, rearports)
|
||||||
for port in ports:
|
for port in ports:
|
||||||
for link_peer in port.link_peers:
|
for link_peer in port.link_peers:
|
||||||
if link_peer.device.id not in device_ids:
|
if hasattr(link_peer, 'device') and link_peer.device.id not in device_ids:
|
||||||
device_ids.append(link_peer.device.id)
|
device_ids.append(link_peer.device.id)
|
||||||
|
|
||||||
if show_logical_connections:
|
if show_logical_connections:
|
||||||
|
|||||||
Reference in New Issue
Block a user