[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.html b/src/app/service-graph/components/graph/graph.component.html
index ad3d0da..1db00fc 100644
--- a/src/app/service-graph/components/graph/graph.component.html
+++ b/src/app/service-graph/components/graph/graph.component.html
@@ -22,7 +22,7 @@
   </div>
   <a ng-click="vm.closeFullscreen()" class="close-btn"><i class="fa fa-times"></i></a>
   <svg></svg>
-  <div class="row">
+  <div class="row" ng-if="!vm.loader">
     <div class="col-md-3">
       <a ng-click="vm.toggleModel('services')" ng-class="{active: vm.currentState >= 0}" class="btn btn-block btn-accent">
         <span>Services</span>
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)