Moved config to ngConstant to mount that from outside the container

Change-Id: I23169cdeeae9034ea97e94089dcdbca3179bbb23
diff --git a/src/app/datasources/rest/auth.rest.spec.ts b/src/app/datasources/rest/auth.rest.spec.ts
index 16c0f8d..483bcfc 100644
--- a/src/app/datasources/rest/auth.rest.spec.ts
+++ b/src/app/datasources/rest/auth.rest.spec.ts
@@ -3,7 +3,6 @@
 import 'angular-resource';
 import 'angular-cookies';
 import {xosDataSources} from '../index';
-import {AppConfig} from '../../config/app.config';
 import {IXosAuthService} from './auth.rest';
 
 let service: IXosAuthService;
@@ -11,11 +10,20 @@
 let $scope;
 let $cookies;
 
+const MockAppCfg = {
+  apiEndpoint: 'http://xos-test:3000/api',
+  websocketClient: 'http://xos-test:3000'
+};
+
 describe('The AuthService service', () => {
 
   beforeEach(angular.mock.module(xosDataSources));
 
   beforeEach(() => {
+
+    angular.module(xosDataSources)
+      .constant('AppConfig', MockAppCfg);
+
     angular.mock.module(xosDataSources);
   });
 
@@ -34,7 +42,7 @@
 
   describe('when logging in', () => {
     beforeEach(() => {
-      httpBackend.expectPOST(`${AppConfig.apiEndpoint}/utility/login/`)
+      httpBackend.expectPOST(`${MockAppCfg.apiEndpoint}/utility/login/`)
         .respond({
           user: JSON.stringify({usernane: 'test@xos.org'}),
           xoscsrftoken: 'token',
@@ -59,7 +67,7 @@
 
   describe('when logging out', () => {
     beforeEach(() => {
-      httpBackend.expectPOST(`${AppConfig.apiEndpoint}/utility/logout/`)
+      httpBackend.expectPOST(`${MockAppCfg.apiEndpoint}/utility/logout/`)
         .respond({
           user: JSON.stringify({usernane: 'test@xos.org'}),
           xoscsrftoken: 'token',
diff --git a/src/app/datasources/rest/auth.rest.ts b/src/app/datasources/rest/auth.rest.ts
index edf7705..2979bf1 100644
--- a/src/app/datasources/rest/auth.rest.ts
+++ b/src/app/datasources/rest/auth.rest.ts
@@ -1,5 +1,5 @@
-import {AppConfig} from '../../config/app.config';
 import IHttpPromiseCallbackArg = angular.IHttpPromiseCallbackArg;
+import {IXosAppConfig} from '../../../index';
 export interface IAuthRequestData {
   username: string;
   password: string;
@@ -30,17 +30,18 @@
   constructor(
     private $http: angular.IHttpService,
     private $q: angular.IQService,
-    private $cookies: angular.cookies.ICookiesService
+    private $cookies: angular.cookies.ICookiesService,
+    private AppConfig: IXosAppConfig
   ) {
   }
 
   public login(data: IAuthRequestData): Promise<any> {
     const d = this.$q.defer();
-    this.$http.post(`${AppConfig.apiEndpoint}/utility/login/`, data)
+    this.$http.post(`${this.AppConfig.apiEndpoint}/utility/login/`, data)
       .then((res: IAuthResponseData) => {
-        this.$cookies.put('xoscsrftoken', res.data.xoscsrftoken);
-        this.$cookies.put('xossessionid', res.data.xossessionid);
-        this.$cookies.put('xosuser', res.data.user);
+        this.$cookies.put('xoscsrftoken', res.data.xoscsrftoken, {path: '/'});
+        this.$cookies.put('xossessionid', res.data.xossessionid, {path: '/'});
+        this.$cookies.put('xosuser', res.data.user, {path: '/'});
         res.data.user = JSON.parse(res.data.user);
         d.resolve(res.data);
       })
@@ -52,7 +53,7 @@
 
   public logout(): Promise<any> {
     const d = this.$q.defer();
-    this.$http.post(`${AppConfig.apiEndpoint}/utility/logout/`, {
+    this.$http.post(`${this.AppConfig.apiEndpoint}/utility/logout/`, {
       xoscsrftoken: this.$cookies.get('xoscsrftoken'),
       xossessionid: this.$cookies.get('xossessionid')
     })
@@ -67,9 +68,9 @@
   }
 
   public clearUser(): void {
-    this.$cookies.remove('xoscsrftoken');
-    this.$cookies.remove('xossessionid');
-    this.$cookies.remove('xosuser');
+    this.$cookies.remove('xoscsrftoken', {path: '/'});
+    this.$cookies.remove('xossessionid', {path: '/'});
+    this.$cookies.remove('xosuser', {path: '/'});
   }
 
   public getUser(): IXosUser {
diff --git a/src/app/datasources/rest/model.rest.spec.ts b/src/app/datasources/rest/model.rest.spec.ts
index f57c0c8..9d5b4f3 100644
--- a/src/app/datasources/rest/model.rest.spec.ts
+++ b/src/app/datasources/rest/model.rest.spec.ts
@@ -4,7 +4,6 @@
 import 'angular-cookies';
 import {IXosResourceService} from './model.rest';
 import {xosDataSources} from '../index';
-import {AppConfig} from '../../config/app.config';
 
 let service: IXosResourceService;
 let resource: ng.resource.IResourceClass<any>;
@@ -12,11 +11,20 @@
 let $resource;
 let $scope;
 
+const MockAppCfg = {
+  apiEndpoint: 'http://xos-test:3000/api',
+  websocketClient: 'http://xos-test:3000'
+};
+
 describe('The ModelRest service', () => {
 
   beforeEach(angular.mock.module(xosDataSources));
 
   beforeEach(() => {
+
+    angular.module(xosDataSources)
+      .constant('AppConfig', MockAppCfg);
+
     angular.mock.module(xosDataSources);
   });
 
@@ -39,7 +47,7 @@
   });
 
   it('should have a query method', (done) => {
-    httpBackend.expectGET(`${AppConfig.apiEndpoint}/core/test`)
+    httpBackend.expectGET(`${MockAppCfg.apiEndpoint}/core/test`)
       .respond([
         {status: 'ok'}
       ]);
@@ -57,7 +65,7 @@
   });
 
   it('should have a get method', (done) => {
-    httpBackend.expectGET(`${AppConfig.apiEndpoint}/core/test/1`)
+    httpBackend.expectGET(`${MockAppCfg.apiEndpoint}/core/test/1`)
       .respond([
         {status: 'ok'}
       ]);
diff --git a/src/app/datasources/rest/model.rest.ts b/src/app/datasources/rest/model.rest.ts
index 8bd2c1f..12590af 100644
--- a/src/app/datasources/rest/model.rest.ts
+++ b/src/app/datasources/rest/model.rest.ts
@@ -1,21 +1,21 @@
-import {AppConfig} from '../../config/app.config';
-
+import {IXosAppConfig} from '../../../index';
 export interface IXosResourceService {
   getResource(url: string): ng.resource.IResourceClass<any>;
 }
 
 export class ModelRest implements IXosResourceService {
-  static $inject = ['$resource'];
+  static $inject = ['$resource', 'AppConfig'];
 
   /** @ngInject */
   constructor(
-    private $resource: ng.resource.IResourceService
+    private $resource: ng.resource.IResourceService,
+    private AppConfig: IXosAppConfig
   ) {
 
   }
 
   public getResource(url: string): ng.resource.IResourceClass<ng.resource.IResource<any>> {
-    const resource: angular.resource.IResourceClass<any> = this.$resource(`${AppConfig.apiEndpoint}${url}/:id/`, {id: '@id'}, {
+    const resource: angular.resource.IResourceClass<any> = this.$resource(`${this.AppConfig.apiEndpoint}${url}/:id/`, {id: '@id'}, {
       update: { method: 'PUT' }
     });
 
diff --git a/src/app/datasources/rest/modeldefs.rest.spec.ts b/src/app/datasources/rest/modeldefs.rest.spec.ts
index 6469cca..9dc4025 100644
--- a/src/app/datasources/rest/modeldefs.rest.spec.ts
+++ b/src/app/datasources/rest/modeldefs.rest.spec.ts
@@ -3,18 +3,26 @@
 import 'angular-resource';
 import 'angular-cookies';
 import {xosDataSources} from '../index';
-import {AppConfig} from '../../config/app.config';
 import {IModeldefsService} from './modeldefs.rest';
 
 let service: IModeldefsService;
 let httpBackend: ng.IHttpBackendService;
 let $scope;
 
+const MockAppCfg = {
+  apiEndpoint: 'http://xos-test:3000/api',
+  websocketClient: 'http://xos-test:3000'
+};
+
 describe('The ModelDefs service', () => {
 
   beforeEach(angular.mock.module(xosDataSources));
 
   beforeEach(() => {
+
+    angular.module(xosDataSources)
+      .constant('AppConfig', MockAppCfg);
+
     angular.mock.module(xosDataSources);
   });
 
@@ -31,7 +39,7 @@
   }));
 
   it('should have a get method', (done) => {
-    httpBackend.expectGET(`${AppConfig.apiEndpoint}/utility/modeldefs/`)
+    httpBackend.expectGET(`${MockAppCfg.apiEndpoint}/utility/modeldefs/`)
       .respond([
         {name: 'ok'}
       ]);
diff --git a/src/app/datasources/rest/modeldefs.rest.ts b/src/app/datasources/rest/modeldefs.rest.ts
index d5a5541..d927f8c 100644
--- a/src/app/datasources/rest/modeldefs.rest.ts
+++ b/src/app/datasources/rest/modeldefs.rest.ts
@@ -1,5 +1,5 @@
-import {AppConfig} from '../../config/app.config';
 import {IXosModelDefsField} from '../../core/services/helpers/config.helpers';
+import {IXosAppConfig} from '../../../index';
 
 export interface IModeldef {
   fields: IXosModelDefsField[];
@@ -12,15 +12,19 @@
 }
 
 export class ModeldefsService {
+
+  static $inject = ['$http', '$q', 'AppConfig'];
+
   constructor(
     private $http: angular.IHttpService,
     private $q: angular.IQService,
+    private AppConfig: IXosAppConfig
   ) {
   }
 
   public get(): Promise<any> {
     const d = this.$q.defer();
-    this.$http.get(`${AppConfig.apiEndpoint}/utility/modeldefs/`)
+    this.$http.get(`${this.AppConfig.apiEndpoint}/utility/modeldefs/`)
       .then((res) => {
         d.resolve(res.data);
       })