rsanchez
2017-04-17 19be37d4112b9c1ff2568af4c652deccd4c0b3c5
#0 enh - Configuring dev mode dynamically
3 files deleted
3 files modified
changed files
securis/src/main/webapp/src/app/common/default.requests.options.ts patch | view | blame | history
securis/src/main/webapp/src/app/common/session.ts patch | view | blame | history
securis/src/main/webapp/src/environments/environment.dev.ts patch | view | blame | history
securis/src/main/webapp/src/environments/environment.prod.ts patch | view | blame | history
securis/src/main/webapp/src/environments/environment.ts patch | view | blame | history
securis/src/main/webapp/src/main.ts patch | view | blame | history
securis/src/main/webapp/src/app/common/default.requests.options.ts
....@@ -10,8 +10,7 @@
1010 XHRConnection,
1111 XSRFStrategy
1212 } from '@angular/http';
13
-declare var window: any;
14
-
13
+import { IS_DEV_MODE } from './session';
1514
1615 // TODO: Chnage this to use Covalent Http helper service
1716 // https://www.npmjs.com/package/@covalent/http
....@@ -31,12 +30,10 @@
3130 @Injectable()
3231 export class ApiXHRBackend extends XHRBackend {
3332
34
- localhostEnv : boolean = false;
3533 static DEV_TOMCAT_URL : String = 'http://localhost:8080/securis/';
3634
3735 constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: Locker) {
3836 super(_browserXHR, _baseResponseOptions, _xsrfStrategy);
39
- this.localhostEnv = window.location.href.startsWith("http://localhost");
4037 }
4138
4239 createConnection(request: Request): XHRConnection {
....@@ -44,7 +41,7 @@
4441 if (token) {
4542 request.headers.set('X-SECURIS-TOKEN', token);
4643 }
47
- if (this.localhostEnv && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
44
+ if (IS_DEV_MODE && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
4845 request.url = ApiXHRBackend.DEV_TOMCAT_URL + request.url; // prefix base url
4946 }
5047 return super.createConnection(request);
securis/src/main/webapp/src/app/common/session.ts
....@@ -1,6 +1,9 @@
11 import { Locker } from 'angular-safeguard';
22 import { Injectable } from '@angular/core';
33
4
+declare var window: any;
5
+
6
+export const IS_DEV_MODE : Boolean = window.location.href.startsWith("http://localhost");
47
58 @Injectable()
69 export class SeCurisSession {
....@@ -8,7 +11,6 @@
811 sessionData: any = {}
912
1013 constructor(private store: Locker) {
11
-
1214 }
1315
1416 public get(key: string): any {
securis/src/main/webapp/src/environments/environment.dev.ts
deleted file mode 100644
....@@ -1,3 +0,0 @@
1
-export const environment = {
2
- production: false
3
-};
securis/src/main/webapp/src/environments/environment.prod.ts
deleted file mode 100644
....@@ -1,3 +0,0 @@
1
-export const environment = {
2
- production: true
3
-};
securis/src/main/webapp/src/environments/environment.ts
deleted file mode 100644
....@@ -1,3 +0,0 @@
1
-export const environment = {
2
- production: false
3
-};
securis/src/main/webapp/src/main.ts
....@@ -4,10 +4,12 @@
44 import { AppModule } from './app/app.module';
55
66 import { enableProdMode } from '@angular/core';
7
-import { environment } from './environments/environment';
7
+import { IS_DEV_MODE } from './app/common/session';
88
9
-if (environment.production) {
9
+if (IS_DEV_MODE) {
10
+ console.log('Running in dev mode');
11
+} else {
1012 enableProdMode();
1113 }
12
-// console.log('This is a test.')
14
+
1315 platformBrowserDynamic().bootstrapModule(AppModule);