Hello,

The position of nodes were different after each reload. The attached patch changes it. The nodes are set as fixed after initial animation. Even if someone releases the node by double-clicking then after animation the node is set as fixed. And the same behavior for new added nodes to the graph (i.e. new client) - after initial animation, which allows node to find proper position, the node is set as fixed, too.


The patch also fixes one minor bug which is, I guess, related to this bug. In a situation where the node is set as fixed (no matter how - manually or automatically) then the page is reloaded or refreshed, then the initial animation runs. If after all these steps someone tries to release the node by double-clicking the state of the node is set to not fixed, but a layout animation is not run. This is the reason why there is layout.resume() in dblclick listener. If you think that there should be another ticket for this minor bug, let me know.

--
Pavel^3 Vomacka
>From 78133bbe1655025c37e8388ee52bec2f4146230b Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Thu, 11 Feb 2016 10:55:48 +0100
Subject: [PATCH] Nodes stay fixed after initial animation.

There is an animation of nodes layout after first load of graph or adding new node.
Then all nodes of the graph are set to the fixed state. The node is set to fixed even after
manual turn off of fixed state.

https://fedorahosted.org/freeipa/ticket/5649
---
 install/ui/src/freeipa/topology_graph.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/install/ui/src/freeipa/topology_graph.js b/install/ui/src/freeipa/topology_graph.js
index 0243ecbd2d0e1b95e629038c63b0a978041f5e3c..2539c39492a1cce84dd03d5e2df4d72fbcd8ea20 100644
--- a/install/ui/src/freeipa/topology_graph.js
+++ b/install/ui/src/freeipa/topology_graph.js
@@ -170,6 +170,21 @@ topology_graph.TopoGraph = declare([Evented], {
         l.linkDistance(150);
         l.charge(-1000);
         l.on('tick', lang.hitch(this, this._tick));
+
+        var that = this;
+
+        l.on('end', function () {
+            var nodes = l.nodes();
+
+            for (var i = 0; i < nodes.length; i++) {
+                var curr_node = nodes[i];
+
+                if (!curr_node.fixed) {
+                    curr_node.fixed = 1;
+                    that._save_node_info(curr_node);
+                }
+            }
+        });
     },
 
     _get_local_storage_attr: function(id, attr) {
@@ -450,6 +465,7 @@ topology_graph.TopoGraph = declare([Evented], {
                 d3.event.stopPropagation();
                 //xor operation switch value of fixed from 1 to 0 and vice versa
                 d.fixed = d.fixed ^ 1;
+                self._layout.resume();
             })
             .call(drag);
 
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to