Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topology - Ability to save a layout for later use #272

Closed
andrew-ronaldson opened this issue Feb 4, 2025 · 4 comments
Closed

Topology - Ability to save a layout for later use #272

andrew-ronaldson opened this issue Feb 4, 2025 · 4 comments

Comments

@andrew-ronaldson
Copy link
Collaborator

Description

The Ansible team has the draggable prop enabled so users can reposition nodes on the canvas. Customers have noted that each time the leave this page and return the custom layout does not persist and the graph they just organized has become messy again. Previously they were using the pipeline visualization but that view does not offer draggable support.

Goal

Can we add a mechanism to save or cache the users layout so that it will not be reset each time the page loads.

@jeff-phillips-18
Copy link
Member

@andrew-ronaldson This is already available via the visualization.ToModel() function.

To save current positions:

  • Add listeners for NODE_POSITIONED_EVENT and GRAPH_POSITION_CHANGE_EVENT (debounce the listener as it can can called a lot on a relayout)
  • When either event occurs use the visualization.toModel() call to get the current model state
  • From the model data, create a store to save the locations of the nodes along with the id of the node (or whatever fields you need to re-identify the node)
  • Add the graph values for x, y, scale, and scaleExtent to the store
  • Save that store to local storage (for example)

To restore positions when initially loading the graph, before calling visualization.fromModel:

  • Create the model data
  • Fetch the stored data from local storage
  • Find the nodes based on the stored data's node id and set the location of the model data to the stored x, y locations
  • Set the graph model to the stored graph values

@andrew-ronaldson
Copy link
Collaborator Author

Great to know! Thanks Jeff. I will pass this on to Ansible and see if they have any feedback. If not I will close this issue.

@jeff-phillips-18
Copy link
Member

@andrew-ronaldson OK to close this?

@andrew-ronaldson
Copy link
Collaborator Author

I can close for now and if we need to revisit I'll open a new issue

@github-project-automation github-project-automation bot moved this from Needs triage to Done in PatternFly Issues Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants