[CORD-2719] Consider previous position of existing nodes in the graph

Change-Id: I1c814604391be3653d0515dfa3daf88cd780ed4a
diff --git a/src/app/service-graph/components/graph/graph.component.ts b/src/app/service-graph/components/graph/graph.component.ts
index b0cabb9..ae5c2f1 100644
--- a/src/app/service-graph/components/graph/graph.component.ts
+++ b/src/app/service-graph/components/graph/graph.component.ts
@@ -18,6 +18,7 @@
 
 import * as d3 from 'd3';
 import * as $ from 'jquery';
+import * as _ from 'lodash';
 
 import {IXosGraphStore} from '../../services/graph.store';
 import {Subscription} from 'rxjs/Subscription';
@@ -189,6 +190,24 @@
       .then((nodes: IXosSgNode[]) => {
         this.loader = false;
 
+        // NOTE keep the position for the nodes that already in the graph
+        nodes = _.map(nodes, (n: IXosSgNode) => {
+
+          if (n.id === 'undefined') {
+            // FIXME why the fabric ONOS app is not displayed and the VTN ONOS app is???
+            console.warn(n);
+          }
+
+          const previousVal = _.find(this.forceLayout.nodes(), {id: n.id});
+
+          if (previousVal) {
+            n.x = previousVal.x;
+            n.y = previousVal.y;
+            n.fixed = previousVal.fixed;
+          }
+          return n;
+        });
+
         this.forceLayout
           .nodes(nodes)
           .links(links)