publish event to all models involved

Change-Id: I869692fbababaa881ce2a0fc8f2ef6add5c7c243
diff --git a/conf/browsersync.conf.js b/conf/browsersync.conf.js
index dd7acd5..d820bb6 100644
--- a/conf/browsersync.conf.js
+++ b/conf/browsersync.conf.js
@@ -1,5 +1,6 @@
 const conf = require('./gulp.conf');
-const proxy = require('./proxy');
+const proxy = require('./proxy').proxy;
+const extensionsProxy = require('./proxy').extensionsProxy;
 
 module.exports = function () {
   return {
@@ -12,6 +13,9 @@
         if (req.url.indexOf('xosapi') !== -1) {
           proxy.web(req, res);
         }
+        // else if (req.url.indexOf('extensions') !== -1) {
+        //   extensionsProxy.web(req, res);
+        // }
         else{
           next();
         }
diff --git a/conf/proxy.js b/conf/proxy.js
index 6a7e8b0..fedbf72 100644
--- a/conf/proxy.js
+++ b/conf/proxy.js
@@ -4,6 +4,10 @@
   target: 'http://192.168.46.100:9101'
 });
 
+const extensionsProxy = httpProxy.createProxyServer({
+  target: 'http://192.168.46.100/spa/'
+});
+
 proxy.on('error', function(error, req, res) {
   res.writeHead(500, {
     'Content-Type': 'text/plain'
@@ -11,4 +15,7 @@
   console.error('[Proxy]', error);
 });
 
-module.exports = proxy;
\ No newline at end of file
+module.exports = {
+  proxy,
+  extensionsProxy
+};
\ No newline at end of file
diff --git a/src/app/datasources/websocket/global.ts b/src/app/datasources/websocket/global.ts
index a5852c8..a820269 100644
--- a/src/app/datasources/websocket/global.ts
+++ b/src/app/datasources/websocket/global.ts
@@ -1,4 +1,5 @@
 import * as io from 'socket.io-client';
+import * as _ from 'lodash';
 import {Subject, Observable} from 'rxjs/Rx';
 import {IXosAppConfig} from '../../../index';
 
@@ -17,16 +18,31 @@
 
 export class WebSocketEvent {
 
-  static $inject = ['AppConfig'];
+  static $inject = [
+    'AppConfig',
+    '$log'
+  ];
 
   private _events: Subject<IWSEvent> = new Subject<IWSEvent>();
     private socket;
     constructor(
-      private AppConfig: IXosAppConfig
+      private AppConfig: IXosAppConfig,
+      private $log: ng.ILogService
     ) {
       this.socket = io(this.AppConfig.websocketClient);
       this.socket.on('event', (data: IWSEvent): void => {
+          this.$log.debug(`[WebSocket] Received Event for: ${data.model} [${data.msg.pk}]`);
           this._events.next(data);
+
+          // NOTE update observers of parent classes
+          if (data.msg.object.class_names && angular.isString(data.msg.object.class_names)) {
+            const models = data.msg.object.class_names.split(',');
+            _.forEach(models, (m: string) => {
+              data.model = m;
+              this._events.next(data);
+            });
+          }
+
         });
     }
     list() {
diff --git a/src/app/service-graph/components/coarse/coarse.component.ts b/src/app/service-graph/components/coarse/coarse.component.ts
index 4e681d7..fb04e2d 100644
--- a/src/app/service-graph/components/coarse/coarse.component.ts
+++ b/src/app/service-graph/components/coarse/coarse.component.ts
@@ -43,12 +43,12 @@
     this.CoarseGraphSubscription = this.XosServiceGraphStore.getCoarse()
       .subscribe(
         (res: IXosServiceGraph) => {
+          this.$log.debug(`[XosCoarseTenancyGraph] Coarse Event and render`, res);
 
           // id there are no data, do nothing
           if (!res.nodes || res.nodes.length === 0 || !res.links || res.links.length === 0) {
             return;
           }
-          this.$log.debug(`[XosCoarseTenancyGraph] Coarse Event and render`, res);
           this.graph = res;
           this.renderGraph();
         },
@@ -138,6 +138,9 @@
   }
 
   private addNodeLinksToForceLayout(data: IXosServiceGraph) {
+    if (!data.nodes || !data.links) {
+      return;
+    }
     this.forceLayout
       .nodes(data.nodes)
       .links(data.links)
diff --git a/src/app/service-graph/components/fine-grained/fine-grained.component.ts b/src/app/service-graph/components/fine-grained/fine-grained.component.ts
index c7efd1c..5647c75 100644
--- a/src/app/service-graph/components/fine-grained/fine-grained.component.ts
+++ b/src/app/service-graph/components/fine-grained/fine-grained.component.ts
@@ -53,12 +53,12 @@
     this.GraphSubscription = this.XosServiceGraphStore.get()
       .subscribe(
         (graph) => {
+          this.$log.debug(`[XosFineGrainedTenancyGraphCtrl] Fine-Grained Event and render`, graph);
 
           if (!graph.nodes || graph.nodes.length === 0 || !graph.links || graph.links.length === 0) {
             return;
           }
 
-          this.$log.debug(`[XosFineGrainedTenancyGraphCtrl] Coarse Event and render`, graph);
           this.graph = graph;
           this.renderGraph();
         },
diff --git a/src/app/service-graph/services/graph.store.ts b/src/app/service-graph/services/graph.store.ts
index 54bc083..9ab1a5d 100644
--- a/src/app/service-graph/services/graph.store.ts
+++ b/src/app/service-graph/services/graph.store.ts
@@ -106,6 +106,7 @@
     this.graphData
       .subscribe(
         (res: IXosFineGrainedGraphData) => {
+          this.$log.debug(`[XosServiceGraphStore] New graph data received`, res);
           this.graphDataToCoarseGraph(res);
           this.graphDataToFineGrainedGraph(res);
         },