Fixing bug in creation
Change-Id: Ie4059b197fecfd605c2ad8bda334a9d1d18285de
diff --git a/conf/app/app.config.production.js b/conf/app/app.config.production.js
index 8f5bd5a..cf92947 100644
--- a/conf/app/app.config.production.js
+++ b/conf/app/app.config.production.js
@@ -1,5 +1,5 @@
angular.module('app')
.constant('AppConfig', {
- apiEndpoint: '/spa/api',
+ apiEndpoint: '/xosapi/v1',
websocketClient: '/'
});
diff --git a/conf/browsersync-dist.conf.js b/conf/browsersync-dist.conf.js
index cbefe1d..d80f1ef 100644
--- a/conf/browsersync-dist.conf.js
+++ b/conf/browsersync-dist.conf.js
@@ -1,4 +1,5 @@
const conf = require('./gulp.conf');
+const proxy = require('./proxy');
module.exports = function () {
return {
@@ -6,10 +7,18 @@
baseDir: [
conf.paths.dist
],
+ middleware: function(req, res, next){
+ if (req.url.indexOf('xosapi') !== -1) {
+ proxy.web(req, res);
+ }
+ else{
+ next();
+ }
+ },
routes: {
"/spa": "./dist"
}
},
- open: false
+ open: true
};
};
diff --git a/conf/browsersync.conf.js b/conf/browsersync.conf.js
index e8c38fa..dd7acd5 100644
--- a/conf/browsersync.conf.js
+++ b/conf/browsersync.conf.js
@@ -1,18 +1,5 @@
const conf = require('./gulp.conf');
-const httpProxy = require('http-proxy');
-
-// TODO move the proxy config in a separate file and share with browsersync.dist.js
-
-const proxy = httpProxy.createProxyServer({
- target: 'http://xos.dev:9101'
-});
-
-proxy.on('error', function(error, req, res) {
- res.writeHead(500, {
- 'Content-Type': 'text/plain'
- });
- console.error('[Proxy]', error);
-});
+const proxy = require('./proxy');
module.exports = function () {
return {
diff --git a/conf/proxy.js b/conf/proxy.js
new file mode 100644
index 0000000..daec1a8
--- /dev/null
+++ b/conf/proxy.js
@@ -0,0 +1,14 @@
+const httpProxy = require('http-proxy');
+
+const proxy = httpProxy.createProxyServer({
+ target: 'http://xos.dev:9101'
+});
+
+proxy.on('error', function(error, req, res) {
+ res.writeHead(500, {
+ 'Content-Type': 'text/plain'
+ });
+ console.error('[Proxy]', error);
+});
+
+module.exports = proxy;
\ No newline at end of file
diff --git a/src/app/core/nav/nav.ts b/src/app/core/nav/nav.ts
index f537e5e..2082efb 100644
--- a/src/app/core/nav/nav.ts
+++ b/src/app/core/nav/nav.ts
@@ -21,10 +21,6 @@
private XosSidePanel: IXosSidePanelService,
private XosComponentInjector: IXosComponentInjectorService
) {
- // NOTE we'll need to have:
- // - Base routes (defined from configuration based on BRAND)
- // - Autogenerated routes (nested somewhere)
- // - Service Routes (dynamically added)
this.routes = [];
this.$scope.$watch(() => this.navigationService.query(), (routes) => {
this.routes = routes;
diff --git a/src/app/datasources/helpers/model-discoverer.service.ts b/src/app/datasources/helpers/model-discoverer.service.ts
index deaed33..da6f265 100644
--- a/src/app/datasources/helpers/model-discoverer.service.ts
+++ b/src/app/datasources/helpers/model-discoverer.service.ts
@@ -62,6 +62,7 @@
const pArray = [];
_.forEach(modelsDef, (model: IXosModeldef) => {
+ this.$log.debug(`[XosModelDiscovererService] Loading: ${model.name}`);
let p = this.cacheModelEntries(model)
.then(model => {
return this.addState(model);
@@ -167,15 +168,20 @@
},
component: 'xosCrud',
};
- this.XosRuntimeStates.addState(
- this.stateNameFromModel(model),
- state
- );
- // extend model
- model.clientUrl = `${this.serviceNameFromAppName(model.app)}${clientUrl}`;
+ try {
+ this.XosRuntimeStates.addState(
+ this.stateNameFromModel(model),
+ state
+ );
- d.resolve(model);
+ // extend model
+ model.clientUrl = `${this.serviceNameFromAppName(model.app)}${clientUrl}`;
+
+ d.resolve(model);
+ } catch (e) {
+ d.reject(e);
+ }
return d.promise;
}
@@ -186,13 +192,17 @@
const parentState: string = this.getParentStateFromModel(model);
- this.XosNavigationService.add({
- label: this.ConfigHelpers.pluralize(model.name),
- state: stateName,
- parent: parentState
- });
+ try {
+ this.XosNavigationService.add({
+ label: this.ConfigHelpers.pluralize(model.name),
+ state: stateName,
+ parent: parentState
+ });
+ d.resolve(model);
+ } catch (e) {
+ d.reject(e);
+ }
- d.resolve(model);
return d.promise;
}