Merge "[CORD-1001] Solved race condition in autogeneration of models and tweaks for slow connections"
diff --git a/Dockerfile b/Dockerfile
index 3fef3f0..46ee933 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# To build use: docker build -t xosproject/xos-gui .
-# To run use: docker run -p 80:80 -d xosproject/xos-gui
+# To run use: docker run -p 4000:4000 --volumes-from gui-extensions-store -d xosproject/xos-gui
FROM nginx
diff --git a/Dockerfile.xos-gui-extension-builder b/Dockerfile.xos-gui-extension-builder
new file mode 100644
index 0000000..4bf1e02
--- /dev/null
+++ b/Dockerfile.xos-gui-extension-builder
@@ -0,0 +1,16 @@
+# To build use: docker build -t xosproject/xos-gui-extension-builder .
+
+FROM node:argon
+
+# Set environment vars
+ENV CODE_SOURCE .
+ENV CODE_DEST /var/www
+
+# Add the app deps
+COPY ${CODE_SOURCE}/package.json ${CODE_DEST}/package.json
+COPY ${CODE_SOURCE}/typings.json ${CODE_DEST}/typings.json
+
+# Install Deps
+WORKDIR ${CODE_DEST}
+RUN npm install
+RUN npm run typings
diff --git a/src/app/extender/services/onboard.service.spec.ts b/src/app/extender/services/onboard.service.spec.ts
index 17a7543..d53f3af 100644
--- a/src/app/extender/services/onboard.service.spec.ts
+++ b/src/app/extender/services/onboard.service.spec.ts
@@ -34,11 +34,7 @@
const MockModelStore = {
query: () => {
- return {
- subscribe: () => {
- return;
- }
- };
+ return subject.asObservable();
}
};
@@ -69,17 +65,12 @@
describe('when receive an event', () => {
it('should use $ocLazyLoad to add modules to the app', () => {
- subject.next({
- model: 'XOSComponent',
- msg: {
- app: 'sample',
- object: {
- extra: '["vendor.js", "app.js"]',
- name: 'sample app'
- }
+ subject.next([
+ {
+ files: 'vendor.js,app.js',
+ name: 'sample app'
}
- });
- $timeout.flush();
+ ]);
expect($ocLazyLoad.load).toHaveBeenCalledWith('vendor.js');
expect($ocLazyLoad.load).toHaveBeenCalledWith('app.js');
});
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;
}
);
}
diff --git a/src/extensions/.gitignore b/src/extensions/.gitignore
new file mode 100644
index 0000000..c96a04f
--- /dev/null
+++ b/src/extensions/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file