Merge branch 'DEVELOP' of ssh://git.eclipse.org:29418/openk-usermodules/org.eclipse.openk-usermodules.contactBaseData.frontend into KON-103-Q-Umgebung-in-CI-aufnehmen

# Conflicts:
#	package.json
diff --git a/config/production.json b/config/production.json
index 8179dd7..0ef2a1f 100644
--- a/config/production.json
+++ b/config/production.json
@@ -1,6 +1,6 @@
 {
   "api": {
-    "baseUrl": "/api"
+    "baseUrl": "/contactdatabase/api"
   },
 
   "paths": {
diff --git a/hooks/pre-build.js b/hooks/pre-build.js
index 3caed32..8cd3264 100644
--- a/hooks/pre-build.js
+++ b/hooks/pre-build.js
@@ -42,7 +42,7 @@
 }
 
 // Set environment variable to "production"
-setEnvironment('./src/config/env.json', 'production');
+setEnvironment('./config/env.json', 'production');
 
 // Merge all localization files into one
-mergeAndSaveJsonFiles(localizationSourceFilesDE, "./src/i18n/de.json");
+mergeAndSaveJsonFiles(localizationSourceFilesDE, "./i18n/de.json");
diff --git a/package.json b/package.json
index 4410a4f..ab103bc 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
     "sy-pre-build": "node hooks/pre-build.js",
     "sy-post-build": "node hooks/post-build.js",
     "sw": "sw-precache --root=./dist --config=sw-precache-config.js",
-    "sy-build": "npm run sy-pre-build && ng build --prod --aot && npm run sy-post-build && npm run sw",
+    "sy-build": "npm run sy-pre-build && ng build --base-href ../contactdatabase/ --prod --aot && npm run sy-post-build && npm run sw",
     "start-in-docker": "npm run sy-pre-start && ng serve --optimization=false --vendor-chunk --common-chunk --host=0.0.0.0 --disableHostCheck=true --proxy-config proxy-docker.conf.json"
   },
   "private": true,
diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts
index 75b6da4..b2f133d 100644
--- a/src/app/app-config.service.ts
+++ b/src/app/app-config.service.ts
@@ -10,22 +10,24 @@
  *
  * SPDX-License-Identifier: EPL-2.0
  ********************************************************************************/
-import { Injectable } from '@angular/core';
+import { Injectable, Inject } from '@angular/core';
 import { Observable } from 'rxjs';
 import { Http, Headers, RequestOptions } from '@angular/http';
+import { APP_BASE_HREF } from '@angular/common'; 
 
 @Injectable()
 export class ConfigService {
   private config: Object;
-  private env: Object;
+  private env: Object;  
 
-  constructor(private http: Http) {}
+  constructor(private http: Http, 
+    @Inject(APP_BASE_HREF) private baseHref: string) {}
 
   /**
    * Loads the environment config file first. Reads the environment variable from the file
    * and based on that loads the appropriate configuration file - development or production
    */
-  load() {
+  load() {    
     return new Promise((resolve, reject) => {
       const headers = new Headers({
         Accept: 'application/json',
@@ -34,13 +36,13 @@
       });
 
       this.http
-        .get('/config/env.json')
+        .get(this.baseHref + 'config/env.json')
         .map(res => res.json())
         .subscribe(env_data => {
           this.env = env_data;
 
           this.http
-            .get('/config/' + env_data.env + '.json')
+            .get(this.baseHref + 'config/' + env_data.env + '.json')
             .map(res => res.json())
             .catch((error: any) => {
               return Observable.throw(error.json().error || 'Server error');
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 73cb65f..dfca123 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -18,7 +18,7 @@
 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
 import { NgModule, APP_INITIALIZER } from '@angular/core';
 import { FormsModule } from '@angular/forms';
-import { CommonModule } from '@angular/common';
+import { CommonModule, APP_BASE_HREF, PlatformLocation } from '@angular/common';
 
 // Routes
 import { AppRoutingModule } from '@app/app-routing.module';
@@ -55,6 +55,15 @@
 import { ContainersModule } from '@shared/containers';
 import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
 
+/**
+ * Get the BaseHref which is defined in the index.html ( <base href="/"> ). 
+ * The "base href" in the index.html can be set via ng nuild for different enviroments.
+ * Example: ng build --prod --base-href ../contactdatabase/
+ */
+
+export function getBaseHref(platformLocation: PlatformLocation): string {
+  return platformLocation.getBaseHrefFromDOM();
+}
 
 /**
  * Calling functions or calling new is not supported in metadata when using AoT.
@@ -115,6 +124,11 @@
       deps: [ConfigService],
       multi: true,
     },
+    {
+    provide: APP_BASE_HREF, 
+    useFactory: getBaseHref,
+    deps: [PlatformLocation]
+    }
   ],
   bootstrap: [AppComponent],
 })
diff --git a/src/index.html b/src/index.html
index d267e5a..d23b001 100644
--- a/src/index.html
+++ b/src/index.html
@@ -22,15 +22,5 @@
 </head>
 <body>
   <div class="loading"></div>
-
-  <script>
-    if ('serviceWorker' in navigator) {
-      navigator.serviceWorker.register('/service-worker.js').then(function(registration) {
-        console.log('Service Worker registered');
-      }).catch(function(err) {
-        console.log('Service Worker registration failed: ', err);
-      });
-    }
-  </script>
 </body>
 </html>