Config and login
Change-Id: I81ffb9b8097620cb7870beaf1b1b315945eebec0
diff --git a/.gitignore b/.gitignore
index fa28be8..cebc32a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
 coverage/
 dist/
 node_modules/
+npm-debug.log
\ No newline at end of file
diff --git a/README.md b/README.md
index c53e867..a96eafb 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,15 @@
-#XOS GUI
+# XOS GUI
+
+# Development
+
+This application can be executed on your system as long as you have `NodeJs` version 4 or higher.
+
+To start de development environment use: `npm start`
+
+## Configuration
+
+There are two configuration file available in the application, and they depend on the environment. You can find the various possibilities in `conf/app`, and they regard application constants, such as `apiEndpoint`, or branding elements, such as `projectName`.
+
+To load a different configration file you can use two environment variables:
+- `NODE_ENV`: to configure the app constants (eg: `dev`, `production`)
+- `BRAND`: to configure style constants (eg: `cord`, `opencloud`)
\ No newline at end of file
diff --git a/conf/app/app.config.dev.ts b/conf/app/app.config.dev.ts
new file mode 100644
index 0000000..749ccc5
--- /dev/null
+++ b/conf/app/app.config.dev.ts
@@ -0,0 +1,11 @@
+/// <reference path="../../../typings/index.d.ts"/>
+
+export interface IAppConfig {
+    apiEndpoint: string;
+    websocketClient: string;
+}
+
+export const AppConfig: IAppConfig = {
+    apiEndpoint: 'http://xos.dev:3000/api',
+    websocketClient: 'http://xos.dev:3000/socket.io/socket.io.js'
+};
diff --git a/conf/app/app.config.production.ts b/conf/app/app.config.production.ts
new file mode 100644
index 0000000..6ae83a4
--- /dev/null
+++ b/conf/app/app.config.production.ts
@@ -0,0 +1,11 @@
+/// <reference path="../../../typings/index.d.ts"/>
+
+export interface IAppConfig {
+    apiEndpoint: string;
+    websocketClient: string;
+}
+
+export const AppConfig: IAppConfig = {
+    apiEndpoint: 'http://xos-rest-gw:3000/api',
+    websocketClient: 'http://xos-rest-gw:3000/socket.io/socket.io.js'
+};
diff --git a/conf/app/app.config.test.ts b/conf/app/app.config.test.ts
new file mode 100644
index 0000000..0b10e64
--- /dev/null
+++ b/conf/app/app.config.test.ts
@@ -0,0 +1,11 @@
+/// <reference path="../../../typings/index.d.ts"/>
+
+export interface IAppConfig {
+    apiEndpoint: string;
+    websocketClient: string;
+}
+
+export const AppConfig: IAppConfig = {
+    apiEndpoint: 'http://xos-test:3000/api',
+    websocketClient: 'http://xos-test:3000/socket.io/socket.io.js'
+};
diff --git a/conf/app/style.config.cord.ts b/conf/app/style.config.cord.ts
new file mode 100644
index 0000000..120725f
--- /dev/null
+++ b/conf/app/style.config.cord.ts
@@ -0,0 +1,11 @@
+/// <reference path="../../../typings/index.d.ts"/>
+
+export interface IStyleConfig {
+    projectName: string;
+    favicon: string;
+}
+
+export const StyleConfig: IStyleConfig = {
+    projectName: 'CORD',
+    favicon: 'cord-favicon.png'
+};
diff --git a/conf/app/style.config.opencloud.ts b/conf/app/style.config.opencloud.ts
new file mode 100644
index 0000000..9423866
--- /dev/null
+++ b/conf/app/style.config.opencloud.ts
@@ -0,0 +1,11 @@
+/// <reference path="../../../typings/index.d.ts"/>
+
+export interface IStyleConfig {
+    projectName: string;
+    favicon: string;
+}
+
+export const StyleConfig: IStyleConfig = {
+    projectName: 'OpenCloud',
+    favicon: 'opencloud-favicon.png'
+};
diff --git a/conf/gulp.conf.js b/conf/gulp.conf.js
index 12e482e..ab46d42 100644
--- a/conf/gulp.conf.js
+++ b/conf/gulp.conf.js
@@ -17,6 +17,7 @@
 exports.paths = {
   src: 'src',
   dist: 'dist',
+  appConfig: 'conf/app',
   tmp: '.tmp',
   e2e: 'e2e',
   tasks: 'gulp_tasks'
diff --git a/gulp_tasks/karma.js b/gulp_tasks/karma.js
index 98aaf1d..5b90572 100644
--- a/gulp_tasks/karma.js
+++ b/gulp_tasks/karma.js
@@ -1,5 +1,3 @@
-process.env.NODE_ENV = 'test';
-
 const path = require('path');
 
 const gulp = require('gulp');
@@ -15,12 +13,14 @@
 }
 
 function karmaSingleRun(done) {
+  process.env.NODE_ENV = 'test';
   const configFile = path.join(process.cwd(), 'conf', 'karma.conf.js');
   const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
   karmaServer.start();
 }
 
 function karmaAutoRun(done) {
+  process.env.NODE_ENV = 'test';
   const configFile = path.join(process.cwd(), 'conf', 'karma-auto.conf.js');
   const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
   karmaServer.start();
diff --git a/gulp_tasks/misc.js b/gulp_tasks/misc.js
index 6cc14bc..efd2cca 100644
--- a/gulp_tasks/misc.js
+++ b/gulp_tasks/misc.js
@@ -3,16 +3,39 @@
 const gulp = require('gulp');
 const del = require('del');
 const filter = require('gulp-filter');
+const rename = require("gulp-rename");
 
 const conf = require('../conf/gulp.conf');
+const cfgFolder = path.join(conf.paths.src, 'app/config');
 
 gulp.task('clean', clean);
 gulp.task('other', other);
+gulp.task('brand', styleConfig);
+gulp.task('appConfig', appConfig);
+gulp.task('config', gulp.series('brand', 'appConfig'));
 
 function clean() {
   return del([conf.paths.dist, conf.paths.tmp]);
 }
 
+function appConfig() {
+  const env = process.env.NODE_ENV || 'production';
+  return gulp.src([
+    path.join(conf.paths.appConfig, `app.config.${env}.ts`)
+  ])
+  .pipe(rename('app.config.ts'))
+  .pipe(gulp.dest(cfgFolder));
+}
+
+function styleConfig() {
+  const env = process.env.BRAND || 'cord';
+  return gulp.src([
+    path.join(conf.paths.appConfig, `style.config.${env}.ts`)
+  ])
+  .pipe(rename('style.config.ts'))
+  .pipe(gulp.dest(cfgFolder));
+}
+
 function other() {
   const fileFilter = filter(file => file.stat.isFile());
 
diff --git a/gulpfile.js b/gulpfile.js
index 541d6e4..479273b 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -10,11 +10,11 @@
 // Tell gulp to use the tasks just loaded
 gulp.registry(hub);
 
-gulp.task('build', gulp.series(gulp.parallel('other', 'webpack:dist')));
-gulp.task('test', gulp.series('karma:single-run'));
+gulp.task('build', gulp.series('config', gulp.parallel('other', 'webpack:dist')));
+gulp.task('test', gulp.series('config', 'karma:single-run'));
 gulp.task('test:auto', gulp.series('karma:auto-run'));
-gulp.task('serve', gulp.series('webpack:watch', 'watch', 'browsersync'));
-gulp.task('serve:dist', gulp.series('default', 'browsersync:dist'));
+gulp.task('serve', gulp.series('config', 'webpack:watch', 'watch', 'browsersync'));
+gulp.task('serve:dist', gulp.series('config', 'default', 'browsersync:dist'));
 gulp.task('default', gulp.series('clean', 'build'));
 gulp.task('watch', watch);
 
diff --git a/package.json b/package.json
index dc798f8..19b1e22 100644
--- a/package.json
+++ b/package.json
@@ -1,59 +1,60 @@
 {
   "dependencies": {
-    "@angular/core": "^2.0.0",
-    "@angular/compiler": "^2.0.0",
     "@angular/common": "^2.0.0",
+    "@angular/compiler": "^2.0.0",
+    "@angular/core": "^2.0.0",
+    "@angular/forms": "^2.2.4",
+    "@angular/http": "^2.0.0",
     "@angular/platform-browser": "^2.0.0",
     "@angular/platform-browser-dynamic": "^2.0.0",
-    "@angular/http": "^2.0.0",
-    "rxjs": "5.0.0-beta.12",
-    "zone.js": "^0.6.23",
+    "@angular/router": "^3.0.0",
+    "angular2-cookie": "^1.2.5",
     "core-js": "^2.4.1",
-    "@angular/router": "^3.0.0"
+    "rxjs": "5.0.0-beta.12",
+    "zone.js": "^0.6.21"
   },
   "devDependencies": {
-    "del": "^2.0.2",
-    "gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb",
-    "gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4",
-    "gulp-filter": "^4.0.0",
-    "gulp-util": "^3.0.7",
-    "gulp-sass": "^2.1.1",
+    "autoprefixer": "^6.2.2",
+    "babel-eslint": "^6.0.2",
+    "babel-loader": "^6.2.0",
+    "babel-plugin-istanbul": "^2.0.1",
     "browser-sync": "^2.9.11",
     "browser-sync-spa": "^1.0.3",
-    "karma": "^1.3.0",
-    "karma-coverage": "^1.1.1",
-    "karma-jasmine": "^1.0.2",
-    "karma-junit-reporter": "^1.1.0",
-    "jasmine": "^2.4.1",
-    "es6-shim": "^0.35.0",
-    "karma-chrome-launcher": "^0.2.3",
-    "karma-phantomjs-launcher": "^0.2.1",
-    "babel-plugin-istanbul": "^2.0.1",
-    "karma-webpack": "^1.7.0",
-    "webpack": "2.1.0-beta.20",
-    "html-webpack-plugin": "^2.9.0",
-    "style-loader": "^0.13.0",
+    "codelyzer": "^0.0.25",
     "css-loader": "^0.23.1",
-    "postcss-loader": "^0.8.0",
-    "autoprefixer": "^6.2.2",
-    "json-loader": "^0.5.4",
-    "extract-text-webpack-plugin": "^2.0.0-beta.3",
-    "html-loader": "^0.4.3",
-    "ts-loader": "^0.8.2",
-    "sass-loader": "^3.1.2",
-    "node-sass": "^3.4.2",
+    "del": "^2.0.2",
+    "es6-shim": "^0.35.0",
     "eslint": "^3.2.2",
     "eslint-config-xo-space": "^0.12.0",
     "eslint-loader": "^1.3.0",
-    "babel-loader": "^6.2.0",
-    "babel-eslint": "^6.0.2",
     "eslint-plugin-babel": "^3.1.0",
+    "extract-text-webpack-plugin": "^2.0.0-beta.3",
+    "gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb",
+    "gulp-filter": "^4.0.0",
+    "gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4",
+    "gulp-rename": "^1.2.2",
+    "gulp-sass": "^2.1.1",
+    "gulp-util": "^3.0.7",
+    "html-loader": "^0.4.3",
+    "html-webpack-plugin": "^2.9.0",
+    "jasmine": "^2.4.1",
+    "json-loader": "^0.5.4",
+    "karma": "^1.3.0",
+    "karma-chrome-launcher": "^0.2.3",
+    "karma-coverage": "^1.1.1",
+    "karma-jasmine": "^1.0.2",
+    "karma-junit-reporter": "^1.1.0",
+    "karma-webpack": "^1.7.0",
+    "node-sass": "^3.4.2",
+    "postcss-loader": "^0.8.0",
+    "sass-loader": "^3.1.2",
+    "style-loader": "^0.13.0",
+    "ts-loader": "^0.8.2",
     "tslint": "^3.2.1",
+    "tslint-loader": "^2.1.0",
     "typescript": "^2.0.2",
     "typings": "^1.0.4",
-    "tslint-loader": "^2.1.0",
-    "codelyzer": "^0.0.25",
-    "phantomjs": "^2.1.3"
+    "webpack": "2.1.0-beta.20"
   },
   "scripts": {
     "start": "gulp serve",
@@ -61,7 +62,8 @@
     "serve": "gulp serve",
     "serve:dist": "gulp serve:dist",
     "test": "gulp test",
-    "test:auto": "gulp test:auto"
+    "test:auto": "gulp test:auto",
+    "config": "gulp config"
   },
   "eslintConfig": {
     "root": true,
diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts
new file mode 100644
index 0000000..413290c
--- /dev/null
+++ b/src/app/components/login/login.component.ts
@@ -0,0 +1,38 @@
+/// <reference path="../../../../typings/index.d.ts"/>
+import {Component} from '@angular/core';
+import {Router} from '@angular/router';
+import {IAuthRequest, IAuthResponse} from '../../interfaces/auth.interface';
+import {StyleConfig} from '../../config/style.config';
+import {AuthService} from '../../services/rest/auth.service';
+
+export class Auth {
+  constructor(
+    public username,
+    public password
+  ){
+  }
+}
+
+@Component({
+  selector: 'xos-login',
+  template: require('./login.html'),
+  providers: [AuthService],
+})
+export class LoginComponent {
+  public auth:IAuthRequest;
+  public brandName;
+  constructor(private AuthService: AuthService, private router:Router) {
+    this.auth = new Auth('', '');
+    this.brandName = StyleConfig.projectName;
+  }
+
+  onSubmit(auth:IAuthRequest){
+    this.AuthService.login(auth)
+      .subscribe(
+        (user:IAuthResponse) => {
+          this.router.navigate(['/']);
+        }
+      )
+  }
+}
+
diff --git a/src/app/components/login/login.html b/src/app/components/login/login.html
new file mode 100644
index 0000000..0f8362c
--- /dev/null
+++ b/src/app/components/login/login.html
@@ -0,0 +1,10 @@
+<div class="login-container">
+  <div class="login-form">
+    <h2>Login to {{brandName}}</h2>
+    <form (ngSubmit)="onSubmit(loginForm.value)" #loginForm="ngForm">
+      <input type="email" [(ngModel)]="auth.username" name="username" required/>
+      <input type="password" [(ngModel)]="auth.password" name="password" required/>
+      <button type="submit" [disabled]="!loginForm.form.valid">Login</button>
+    </form>
+  </div>
+</div>
diff --git a/src/app/config/.gitignore b/src/app/config/.gitignore
new file mode 100644
index 0000000..c96a04f
--- /dev/null
+++ b/src/app/config/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
\ No newline at end of file
diff --git a/src/app/directives/protected.directive.ts b/src/app/directives/protected.directive.ts
new file mode 100644
index 0000000..9ebe89e
--- /dev/null
+++ b/src/app/directives/protected.directive.ts
@@ -0,0 +1,34 @@
+/**
+ * Created by teone on 12/5/16.
+ */
+import {Directive, OnDestroy} from '@angular/core';
+import {AuthService} from '../services/rest/auth.service';
+import {Router} from '@angular/router';
+
+@Directive({
+  selector: '[xos-protected]',
+  providers: [AuthService]
+})
+export class ProtectedDirective implements OnDestroy {
+  private sub:any = null;
+
+  constructor(private authService:AuthService, private router:Router) {
+    console.log('protected directive');
+    if (!authService.isAuthenticated()) {
+      console.log('redirect');
+      this.router.navigate(['/login']);
+    }
+
+    // this.sub = this.authService.subscribe((val) => {
+    //   if (!val.authenticated) {
+    //     this.router.navigate(['LoggedoutPage']); // tells them they've been logged out (somehow)
+    //   }
+    // });
+  }
+
+  ngOnDestroy() {
+    // if (this.sub != null) {
+    //   this.sub.unsubscribe();
+    // }
+  }
+}
diff --git a/src/app/hello.html b/src/app/hello.html
index 2ec8382..089199c 100644
--- a/src/app/hello.html
+++ b/src/app/hello.html
@@ -1 +1,5 @@
-<h1>{{ hello }}</h1>
\ No newline at end of file
+<div xos-protected></div>
+
+<h1>{{ hello }}</h1>
+
+<pre>{{ endpoints | json }}</pre>
diff --git a/src/app/hello.spec.ts b/src/app/hello.spec.ts
index 7e3b2cc..91b3f1a 100644
--- a/src/app/hello.spec.ts
+++ b/src/app/hello.spec.ts
@@ -2,12 +2,26 @@
 
 import {HelloComponent} from './hello';
 import {TestBed, async} from '@angular/core/testing';
+import {StyleConfig} from './config/style.config';
+import { Http, BaseRequestOptions } from '@angular/http';
+import { MockBackend } from '@angular/http/testing';
 
 describe('hello component', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [
         HelloComponent
+      ],
+      providers: [
+        {
+          provide: Http,
+          useFactory: (mockBackend, options) => {
+            return new Http(mockBackend, options);
+          },
+          deps: [MockBackend, BaseRequestOptions]
+        },
+        MockBackend,
+        BaseRequestOptions
       ]
     });
     TestBed.compileComponents();
@@ -17,6 +31,6 @@
     const fixture = TestBed.createComponent(HelloComponent);
     fixture.detectChanges();
     const hello = fixture.nativeElement;
-    expect(hello.querySelector('h1').textContent).toBe('Hello World!');
+    expect(hello.querySelector('h1').textContent).toBe(`Hello ${StyleConfig.projectName}!`);
   });
 });
diff --git a/src/app/hello.ts b/src/app/hello.ts
index 9f42916..b67e7f6 100644
--- a/src/app/hello.ts
+++ b/src/app/hello.ts
@@ -1,13 +1,33 @@
-import {Component} from '@angular/core';
+/// <reference path="../../typings/index.d.ts"/>
+import {Component, OnInit} from '@angular/core';
+import {NgFor} from '@angular/common';
+import {StyleConfig} from './config/style.config';
+import {CoreService} from './services/rest/core.service';
 
 @Component({
-  selector: 'fountain-app',
-  template: require('./hello.html')
+  selector: 'xos-app',
+  template: require('./hello.html'),
+  providers: [CoreService],
 })
 export class HelloComponent {
-  public hello: string;
 
-  constructor() {
-    this.hello = 'Hello World!';
+  // declare class properties
+  public hello: string;
+  public endpoints: any[];
+
+  constructor(private coreService: CoreService) {
+    this.hello = `Hello ${StyleConfig.projectName}!`;
+    this.endpoints = [];
+  }
+
+  ngOnInit() {
+    console.log('on init');
+    this.coreService.getCoreEndpoints()
+      .subscribe(
+        endpoints => {
+          this.endpoints = endpoints
+        },
+        err => console.log
+      )
   }
 }
diff --git a/src/app/index.ts b/src/app/index.ts
index 5f02fe6..4e93275 100644
--- a/src/app/index.ts
+++ b/src/app/index.ts
@@ -1,18 +1,29 @@
 import {NgModule} from '@angular/core';
 import {BrowserModule} from '@angular/platform-browser';
+import {HttpModule}    from '@angular/http';
+import {FormsModule}   from '@angular/forms';
+import {CookieService} from 'angular2-cookie/services/cookies.service';
+
 import {routing, RootComponent} from './routes';
 
 import {HelloComponent} from './hello';
+import {LoginComponent} from './components/login/login.component';
+import {ProtectedDirective} from './directives/protected.directive';
 
 @NgModule({
   imports: [
     BrowserModule,
-    routing
+    FormsModule,
+    routing,
+    HttpModule
   ],
   declarations: [
     RootComponent,
-    HelloComponent
+    HelloComponent,
+    LoginComponent,
+    ProtectedDirective
   ],
+  providers: [CookieService],
   bootstrap: [RootComponent]
 })
 export class AppModule {}
diff --git a/src/app/interfaces/auth.interface.ts b/src/app/interfaces/auth.interface.ts
new file mode 100644
index 0000000..1742fb7
--- /dev/null
+++ b/src/app/interfaces/auth.interface.ts
@@ -0,0 +1,10 @@
+export interface IAuthRequest {
+  username: string;
+  password: string;
+}
+
+export interface IAuthResponse {
+  xossessionid: string;
+  xoscsrftoken: string;
+  user: string;
+}
diff --git a/src/app/routes.ts b/src/app/routes.ts
index 9a197e7..4c27ed1 100644
--- a/src/app/routes.ts
+++ b/src/app/routes.ts
@@ -3,10 +3,13 @@
 import {Component} from '@angular/core';
 import {RouterModule, Routes} from '@angular/router';
 import {HelloComponent} from './hello';
+import {LoginComponent} from "./components/login/login.component";
 
 @Component({
-  selector: 'fountain-root',
-  template: '<router-outlet></router-outlet>'
+  selector: 'xos-root',
+  template: `
+    <router-outlet></router-outlet>
+  `
 })
 export class RootComponent {}
 
@@ -14,6 +17,10 @@
   {
     path: '',
     component: HelloComponent
+  },
+  {
+    path: 'login',
+    component: LoginComponent
   }
 ];
 
diff --git a/src/app/services/rest/auth.service.ts b/src/app/services/rest/auth.service.ts
new file mode 100644
index 0000000..7c73c28
--- /dev/null
+++ b/src/app/services/rest/auth.service.ts
@@ -0,0 +1,48 @@
+/// <reference path="../../../../typings/index.d.ts"/>
+
+// Imports
+import {AppConfig} from '../../config/app.config';
+import {Injectable}     from '@angular/core';
+import {Http, Response} from '@angular/http';
+import {Observable} from 'rxjs/Rx';
+import {IAuthRequest, IAuthResponse} from '../../interfaces/auth.interface';
+import {CookieService} from 'angular2-cookie/core';
+
+// Import RxJs required methods
+import 'rxjs/add/operator/map';
+import 'rxjs/add/operator/catch';
+
+@Injectable()
+export class AuthService {
+  private xosToken:string;
+  private xosSessionId:string;
+  // Resolve HTTP using the constructor
+  constructor (private http: Http, private cookieService:CookieService) {
+  }
+
+  // check if the user is authenticated
+  isAuthenticated(){
+    this.xosToken = this.cookieService.get('xoscsrftoken');
+    this.xosSessionId = this.cookieService.get('xossessionid');
+    return this.xosToken;
+  }
+
+  // save cookies
+  storeAuth(auth:IAuthResponse){
+    this.cookieService.put('xoscsrftoken', auth.xoscsrftoken);
+    this.cookieService.put('xossessionid', auth.xossessionid);
+  }
+
+  // Log the user in
+  login(auth: IAuthRequest) : Observable<IAuthResponse> {
+    return this.http.post(`${AppConfig.apiEndpoint}/utility/login/`, auth)
+      .map((res:Response) => res.json())
+      .map((auth:IAuthResponse) => {
+        this.storeAuth(auth);
+        auth.user = JSON.parse(auth.user);
+        return auth;
+      })
+      .catch((error:any) => Observable.throw(error.json().error || 'Server error'));
+  }
+}
+
diff --git a/src/app/services/rest/core.service.ts b/src/app/services/rest/core.service.ts
new file mode 100644
index 0000000..04097a6
--- /dev/null
+++ b/src/app/services/rest/core.service.ts
@@ -0,0 +1,31 @@
+/// <reference path="../../../../typings/index.d.ts"/>
+
+// Imports
+import {AppConfig} from '../../config/app.config';
+import { Injectable }     from '@angular/core';
+import { Http, Response, Headers, RequestOptions } from '@angular/http';
+import {Observable} from 'rxjs/Rx';
+
+// Import RxJs required methods
+import 'rxjs/add/operator/map';
+import 'rxjs/add/operator/catch';
+
+@Injectable()
+export class CoreService {
+  // Resolve HTTP using the constructor
+  constructor (private http: Http) {}
+  // private instance variable to hold base url
+  private baseUrl = AppConfig.apiEndpoint;
+
+  // Fetch all existing comments
+  getCoreEndpoints() : Observable<any[]> {
+
+    // ...using get request
+    return this.http.get(`${this.baseUrl}/core/`)
+    // ...and calling .json() on the response to return data
+      .map((res:Response) => res.json())
+      //...errors if any
+      .catch((error:any) => Observable.throw(error.json().error || 'Server error'));
+
+  }
+}
diff --git a/src/images/cord-favicon.png b/src/images/cord-favicon.png
new file mode 100644
index 0000000..758902e
--- /dev/null
+++ b/src/images/cord-favicon.png
Binary files differ
diff --git a/src/images/opencloud-favicon.png b/src/images/opencloud-favicon.png
new file mode 100644
index 0000000..d49afe0
--- /dev/null
+++ b/src/images/opencloud-favicon.png
Binary files differ
diff --git a/src/index.html b/src/index.html
index 2d0e805..6d6e8c1 100644
--- a/src/index.html
+++ b/src/index.html
@@ -3,13 +3,13 @@
   <head>
     <base href="/">
     <meta charset="utf-8">
-    <title>FountainJS</title>
+    <title>XOS</title>
     <meta name="description" content="">
     <meta name="viewport" content="width=device-width">
-    <link rel="icon" type="image/png" href="http://fountainjs.io/assets/imgs/fountain.png" />
+    <link rel="icon" type="image/png" href="images/cord-favicon.png" />
   </head>
 
   <body>
-    <fountain-root>Loading...</fountain-root>
+    <xos-root>Loading XOS...</xos-root>
   </body>
 </html>
diff --git a/src/index.ts b/src/index.ts
index f7b360a..4cf1437 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -13,6 +13,7 @@
 import {AppModule} from './app';
 
 declare var process: any;
+console.log(process.env.NODE_ENV);
 if (process.env.NODE_ENV === 'production') {
   enableProdMode();
 } else {
diff --git a/tsconfig.json b/tsconfig.json
index 60aa28a..b0eaa45 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -3,14 +3,18 @@
     "sourceMap": true,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
+    "moduleResolution": "node",
     "removeComments": false,
     "noImplicitAny": false
   },
   "compileOnSave": false,
-  "filesGlob": [
+  "include": [
     "src/**/*.ts",
-    "src/**/*.tsx",
-    "!typings/**",
-    "!node_modules/**"
+    "src/**/*.tsx"
+  ],
+  "exclude": [
+    "typings/**",
+    "conf/app/**",
+    "node_modules/**"
   ]
 }
diff --git a/tslint.json b/tslint.json
index 373c573..d8902fa 100644
--- a/tslint.json
+++ b/tslint.json
@@ -7,8 +7,8 @@
     "component-selector-name": [true, "kebab-case"],
     "directive-selector-type": [true, "attribute"],
     "component-selector-type": [true, "element"],
-    "directive-selector-prefix": [true, "fountain"],
-    "component-selector-prefix": [true, "fountain"],
+    "directive-selector-prefix": [true, "xos"],
+    "component-selector-prefix": [true, "xos"],
     "use-input-property-decorator": true,
     "use-output-property-decorator": true,
     "use-host-property-decorator": true,
@@ -18,7 +18,7 @@
     "no-forward-ref" :true,
     "use-life-cycle-interface": true,
     "use-pipe-transform-interface": true,
-    "pipe-naming": [true, "camelCase", "fountain"],
+    "pipe-naming": [true, "camelCase", "xos"],
     "component-class-suffix": true,
     "directive-class-suffix": true,
     "ban": [true,