correct physics

This commit is contained in:
dreng
2023-05-09 10:19:29 +02:00
parent bef5e8479f
commit 25380c0618
3 changed files with 19 additions and 14 deletions
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(
topologyData.edges.map((node) => ({
...node,
@@ -76,6 +79,7 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
Promise.allSettled(
Object.entries(graph.getPositions(params.nodes)).map(
async ([nodeId, nodePosition]) => {
window.nodes.update({id: parseInt(nodeId), physics: false, x: nodePosition.x, y: nodePosition.y});
const res = await fetch(
'/api/plugins/netbox_topology_views/save-coords/save_coords/',
{
+13 -12
View File
@@ -147,15 +147,6 @@ def create_node(
if 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":
group_id = Coordinate.get_or_create_default_group(group_id)
if not group_id:
@@ -182,8 +173,18 @@ def create_node(
node["physics"] = False
elif save_coords:
node["physics"] = False
elif save_coords:
node["physics"] = False
else:
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
@@ -329,7 +330,7 @@ def get_topology_data(
ports = chain(interfaces, frontports, rearports)
for port in ports:
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)
if show_logical_connections: