netjsongraph.js icon indicating copy to clipboard operation
netjsongraph.js copied to clipboard

[feature] Update URL with node click of map interactions #238

Open dee077 opened this issue 4 months ago • 4 comments

Checklist

  • [x] I have read the OpenWISP Contributing Guidelines.
  • [x] I have manually tested the changes proposed in this pull request.
  • [ ] I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • [ ] I have updated the documentation.

Reference to Existing Issue

Closes #238 .

Description of Changes

  • Update URL query params on map interactions (zoom, move, bounds change)
  • Add mode in URL to differentiate indoor map and geo-map
  • Open floorplan overlay when in indoor map mode

dee077 avatar Aug 17 '25 13:08 dee077

I also explored about enabling this feature by default. If ID is not provided in the config, we can generate a hash based on the HTML element. This can have side-effects, so let's think before going ahead in this direction

Maybe, this is a bad idea. What if the user updates the HTML element? Then, the old URLs will no longer work.

pandafy avatar Sep 12 '25 19:09 pandafy

Updates

  • ~~Added a new object in the netjsongraph instance this.nodeIndex, which contains the key as node.id or sourceNodeId-targetNodeId in case of a link, so that it can be looked afterwards by this.data.nodes[index] or this.data.links[index].~~
  • Updated the tests with these new changes and added new unit and browser tests for case of links.
  • Did not add browser tests for adding nodes to url on click on the node or link, as we currently don't have resilient logic to trigger the click event of the node or link in selenium tests. Moving the mouse programmatically and triggering a click will cause unexpected failure on different window sizes.
  • Adding the value for nodeIndex as index of the array present this.data.nodes or this.data.nodes was a bad idea, as it cannot be sure the array will be in the same sequence every time. On monitoring found that the index is getting changed on readering a url in a new tab.
  • So in netjsongraph.core.js we are already traversing the nodes and links to set the this.data, so I created a shallow copy of it in this.nodeLinkIndex as key of node id or source~target for further looks without need for a traversal.
  • Used ~ as a separator in case of setting link key in dict as source~target, uuid can have - and give unexpected results

dee077 avatar Oct 12 '25 21:10 dee077

Feel free to update the Readme if you want some additional details to mention or want to remove something.

dee077 avatar Nov 07 '25 21:11 dee077