From 19be37d4112b9c1ff2568af4c652deccd4c0b3c5 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 17 Apr 2017 13:15:38 +0000
Subject: [PATCH] #0 enh - Configuring dev mode dynamically
---
/dev/null | 3 ---
securis/src/main/webapp/src/app/common/session.ts | 4 +++-
securis/src/main/webapp/src/app/common/default.requests.options.ts | 7 ++-----
securis/src/main/webapp/src/main.ts | 8 +++++---
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/securis/src/main/webapp/src/app/common/default.requests.options.ts b/securis/src/main/webapp/src/app/common/default.requests.options.ts
index fd8865a..e380531 100644
--- a/securis/src/main/webapp/src/app/common/default.requests.options.ts
+++ b/securis/src/main/webapp/src/app/common/default.requests.options.ts
@@ -10,8 +10,7 @@
XHRConnection,
XSRFStrategy
} from '@angular/http';
-declare var window: any;
-
+import { IS_DEV_MODE } from './session';
// TODO: Chnage this to use Covalent Http helper service
// https://www.npmjs.com/package/@covalent/http
@@ -31,12 +30,10 @@
@Injectable()
export class ApiXHRBackend extends XHRBackend {
- localhostEnv : boolean = false;
static DEV_TOMCAT_URL : String = 'http://localhost:8080/securis/';
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: Locker) {
super(_browserXHR, _baseResponseOptions, _xsrfStrategy);
- this.localhostEnv = window.location.href.startsWith("http://localhost");
}
createConnection(request: Request): XHRConnection {
@@ -44,7 +41,7 @@
if (token) {
request.headers.set('X-SECURIS-TOKEN', token);
}
- if (this.localhostEnv && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
+ if (IS_DEV_MODE && !request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
request.url = ApiXHRBackend.DEV_TOMCAT_URL + request.url; // prefix base url
}
return super.createConnection(request);
diff --git a/securis/src/main/webapp/src/app/common/session.ts b/securis/src/main/webapp/src/app/common/session.ts
index 6bbcfca..b47f998 100644
--- a/securis/src/main/webapp/src/app/common/session.ts
+++ b/securis/src/main/webapp/src/app/common/session.ts
@@ -1,6 +1,9 @@
import { Locker } from 'angular-safeguard';
import { Injectable } from '@angular/core';
+declare var window: any;
+
+export const IS_DEV_MODE : Boolean = window.location.href.startsWith("http://localhost");
@Injectable()
export class SeCurisSession {
@@ -8,7 +11,6 @@
sessionData: any = {}
constructor(private store: Locker) {
-
}
public get(key: string): any {
diff --git a/securis/src/main/webapp/src/environments/environment.dev.ts b/securis/src/main/webapp/src/environments/environment.dev.ts
deleted file mode 100644
index ffe8aed..0000000
--- a/securis/src/main/webapp/src/environments/environment.dev.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const environment = {
- production: false
-};
diff --git a/securis/src/main/webapp/src/environments/environment.prod.ts b/securis/src/main/webapp/src/environments/environment.prod.ts
deleted file mode 100644
index 3612073..0000000
--- a/securis/src/main/webapp/src/environments/environment.prod.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const environment = {
- production: true
-};
diff --git a/securis/src/main/webapp/src/environments/environment.ts b/securis/src/main/webapp/src/environments/environment.ts
deleted file mode 100644
index ffe8aed..0000000
--- a/securis/src/main/webapp/src/environments/environment.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export const environment = {
- production: false
-};
diff --git a/securis/src/main/webapp/src/main.ts b/securis/src/main/webapp/src/main.ts
index d635a66..02d996f 100644
--- a/securis/src/main/webapp/src/main.ts
+++ b/securis/src/main/webapp/src/main.ts
@@ -4,10 +4,12 @@
import { AppModule } from './app/app.module';
import { enableProdMode } from '@angular/core';
-import { environment } from './environments/environment';
+import { IS_DEV_MODE } from './app/common/session';
-if (environment.production) {
+if (IS_DEV_MODE) {
+ console.log('Running in dev mode');
+} else {
enableProdMode();
}
-// console.log('This is a test.')
+
platformBrowserDynamic().bootstrapModule(AppModule);
--
Gitblit v1.3.2