From c01d351f3fc0b91253b985a3d900c79af51bad54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Wed, 14 Mar 2018 22:16:00 +0100
Subject: [PATCH] Add demo room

---
 src/app/join-room/join-room.component.html |  1 +
 src/app/join-room/join-room.component.ts   | 27 ++++++++++++++--------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/app/join-room/join-room.component.html b/src/app/join-room/join-room.component.html
index 63ee40874..d491d9e40 100644
--- a/src/app/join-room/join-room.component.html
+++ b/src/app/join-room/join-room.component.html
@@ -10,4 +10,5 @@
         <mat-icon>send</mat-icon>
       </button>
     </div>
+    <button mat-button color="primary" (click)="joinDemo()">Join demo room <mat-icon>lightbulb_outline</mat-icon></button>
 </form>
diff --git a/src/app/join-room/join-room.component.ts b/src/app/join-room/join-room.component.ts
index 8f2aa11d1..edb949a76 100644
--- a/src/app/join-room/join-room.component.ts
+++ b/src/app/join-room/join-room.component.ts
@@ -22,6 +22,7 @@ export class JoinErrorStateMatcher implements ErrorStateMatcher {
 export class JoinRoomComponent implements OnInit {
 
   room: Room;
+  demoId = '17703069';
 
   roomFormControl = new FormControl('', [Validators.required]);
 
@@ -36,18 +37,26 @@ export class JoinRoomComponent implements OnInit {
   ngOnInit() {
   }
 
+  getRoom(id: string): void {
+    this.roomService.getRoom(id)
+      .subscribe(room => {
+        this.room = room;
+        if (!room) {
+          this.notificationService.show(`No room was found with id: ${id}`);
+        } else {
+          this.router.navigate([`/participant/room/${this.room.shortId}`]);
+        }
+      });
+  }
+
   joinRoom(id: string): void {
     if (!this.roomFormControl.hasError('required')) {
-      this.roomService.getRoom(id)
-        .subscribe(room => {
-          this.room = room;
-          if (!room) {
-            this.notificationService.show(`No room was found with id: ${id}`);
-          } else {
-            this.router.navigate([`/participant/room/${this.room.shortId}`]);
-          }
-        });
+      this.getRoom(id);
     }
   }
 
+  joinDemo(): void {
+    this.getRoom(this.demoId);
+  }
+
 }
-- 
GitLab