[CORD-772] Onboarding GUI Extensions and persisting them in xos-core

Change-Id: I09411f974cac7678197873d9e76f4a4dd7f0ef18
diff --git a/src/app/extender/services/onboard.service.ts b/src/app/extender/services/onboard.service.ts
index 2f85028..b6a9abc 100644
--- a/src/app/extender/services/onboard.service.ts
+++ b/src/app/extender/services/onboard.service.ts
@@ -1,4 +1,4 @@
-import {IWSEventService, IWSEvent} from '../../datasources/websocket/global';
+import {IWSEventService} from '../../datasources/websocket/global';
 import {IXosModelStoreService} from '../../datasources/stores/model.store';
 import * as _ from 'lodash';
 import {Observable} from 'rxjs';
@@ -20,56 +20,19 @@
   ) {
     this.$log.info('[XosOnboarder] Setup');
 
-    // Listen for new app (we need a pause to allow the container to boot)
-    this.webSocket.list()
-      .filter((e: IWSEvent) => {
-        if (e.model === 'XOSComponent' && e.msg.object.extra) {
-          e.msg.object.extra = JSON.parse(e.msg.object.extra);
-          return true;
-        }
-        return false;
-      })
-      .subscribe(
-        (event) => {
-          this.$timeout(() => {
-            this.$log.info(`[XosOnboarder] Loading files for app: ${event.msg.object.name}`);
-            // NOTE we need the timeout because the event is triggered when the model is created,
-            // XOS take around 15s to boot it
-            this.loadFile(event.msg.object.extra)
-              .then((res) => {
-                this.$log.info(`[XosOnboarder] All files loaded for app: ${event.msg.object.name}`);
-              });
-          }, 20 * 1000);
-        }
-      );
+    // Load onboarded app
+    const ComponentObservable: Observable<any> = this.XosModelStore.query('XOSGuiExtension');
 
-    // Load previously onboarded app (containers are already running, so we don't need to wait)
-    let componentsLoaded = false;
-    const ComponentObservable: Observable<any> = this.XosModelStore.query('XOSComponent');
     ComponentObservable.subscribe(
         (component) => {
-          if (componentsLoaded) {
-            // if we have already loaded the component present when we loaded the page
-            // do nothing, we are intercepting WS to give the container time to boot
-            return;
-          }
-
           _.forEach(component, (c) => {
-            if (c.extra) {
-              this.$log.info(`[XosOnboarder] Loading files for app: ${c.name}`);
-              let extra;
-              try {
-                extra = JSON.parse(c.extra);
-              } catch (e) {
-                extra = c.extra;
-              }
-              this.loadFile(extra)
-                .then((res) => {
-                  this.$log.info(`[XosOnboarder] All files loaded for app: ${c.name}`);
-                });
-            }
+            this.$log.info(`[XosOnboarder] Loading files for app: ${c.name}`);
+            const files = c.files.split(',').map(s => s.trim());
+            this.loadFile(files)
+              .then((res) => {
+                this.$log.info(`[XosOnboarder] All files loaded for app: ${c.name}`);
+              });
           });
-          componentsLoaded = true;
         }
       );
   }