From 27a75ab237b8b9be1fcf6101e1d2e5d4cf4a1379 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Tue, 19 Feb 2019 13:00:54 +0100
Subject: [PATCH] Add new function to landing-page which decides if you have to
 loding or can create session

---
 .../home/new-landing/new-landing.component.html  |  2 +-
 .../home/new-landing/new-landing.component.ts    | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/app/components/home/new-landing/new-landing.component.html b/src/app/components/home/new-landing/new-landing.component.html
index b01150a8a..cee66710b 100644
--- a/src/app/components/home/new-landing/new-landing.component.html
+++ b/src/app/components/home/new-landing/new-landing.component.html
@@ -1,6 +1,6 @@
 <div fxLayout="column" fxLayoutAlign="center center" fxlayoutgap="50px" fxFill>
     <app-room-join></app-room-join>
-    <button mat-fab class="fab-extended" color="accent" (click)="openLoginDialog()">
+    <button mat-fab class="fab-extended" color="accent" (click)="createSession()">
       <mat-icon class="add">add</mat-icon>
       Create Session
     </button>
diff --git a/src/app/components/home/new-landing/new-landing.component.ts b/src/app/components/home/new-landing/new-landing.component.ts
index ff4cd5f8a..ce9495c6e 100644
--- a/src/app/components/home/new-landing/new-landing.component.ts
+++ b/src/app/components/home/new-landing/new-landing.component.ts
@@ -5,6 +5,8 @@ import { Router } from '@angular/router';
 import { TranslateService } from '@ngx-translate/core';
 import { LanguageService } from '../../../services/util/language.service';
 import { LoginPageComponent } from '../login-page/login-page.component';
+import { AuthenticationService } from '../../../services/http/authentication.service';
+import { User } from '../../../models/user';
 
 @Component({
   selector: 'app-new-landing',
@@ -13,15 +15,27 @@ import { LoginPageComponent } from '../login-page/login-page.component';
 })
 export class NewLandingComponent implements OnInit {
 
+  user: User;
+
   constructor(private router: Router,
               public dialog: MatDialog,
               private translateService: TranslateService,
-              protected langService: LanguageService) {
+              protected langService: LanguageService,
+              public authenticationService: AuthenticationService) {
     langService.langEmitter.subscribe(lang => translateService.use(lang));
   }
 
   ngOnInit() {
     this.translateService.use(localStorage.getItem('currentLang'));
+    this.authenticationService.watchUser.subscribe(newUser => this.user = newUser);
+  }
+
+  createSession() {
+    if (this.user) {
+      this.openCreateRoomDialog();
+    } else {
+      this.openLoginDialog();
+    }
   }
 
   openCreateRoomDialog(): void {
-- 
GitLab