From b746b541d9efe0c4950364371b0527281b399580 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Fri, 9 Mar 2018 11:34:25 +0100
Subject: [PATCH] Add room logic so that the participant-room view displays the
 current-room information instead of test data

---
 .../participant-room.component.html             |  6 +++---
 .../participant-room.component.ts               | 17 +++++++++++++++--
 src/app/room.service.ts                         |  5 ++---
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/app/participant-room/participant-room.component.html b/src/app/participant-room/participant-room.component.html
index 7f6f4ae50..c5cfec539 100644
--- a/src/app/participant-room/participant-room.component.html
+++ b/src/app/participant-room/participant-room.component.html
@@ -2,13 +2,13 @@
   <div fxLayout="row" fxLayoutAlign="center">
     <mat-card>
       <mat-card-header>
-        <mat-card-title><h3 class="subheading-2">{{ roomName }}</h3></mat-card-title>
-        <mat-card-subtitle>{{ roomId }}</mat-card-subtitle>
+        <mat-card-title><h3 class="subheading-2">{{ room.name }}</h3></mat-card-title>
+        <mat-card-subtitle>{{ room.shortId }}</mat-card-subtitle>
       </mat-card-header>
       <mat-divider></mat-divider>
       <mat-card-content>
         <p>
-          {{ roomDescription }}
+          {{ room.description }}
         </p>
       </mat-card-content>
       <mat-divider></mat-divider>
diff --git a/src/app/participant-room/participant-room.component.ts b/src/app/participant-room/participant-room.component.ts
index 53c52e01a..8c99c196c 100644
--- a/src/app/participant-room/participant-room.component.ts
+++ b/src/app/participant-room/participant-room.component.ts
@@ -1,6 +1,8 @@
 import { Component, OnInit } from '@angular/core';
 import { Room } from '../room';
 import { Location } from '@angular/common';
+import { RoomService } from '../room.service';
+import { ActivatedRoute } from '@angular/router';
 
 @Component({
   selector: 'app-participant-room',
@@ -19,13 +21,24 @@ export class ParticipantRoomComponent implements OnInit {
     'tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea ' +
     'rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.';
 
-  constructor(private location: Location) {
+  constructor(private location: Location,
+              private roomService: RoomService,
+              private route: ActivatedRoute) {
   }
 
   ngOnInit() {
+    this.route.params.subscribe(params => {
+      this.getRoom(params['roomId']);
+    });
   }
 
-  goBack() {
+  getRoom(id: string): void {
+    this.roomService.getRoom(id)
+      .subscribe(room => this.room = room);
+  }
+
+
+  goBack(): void {
     this.location.back();
   }
 }
diff --git a/src/app/room.service.ts b/src/app/room.service.ts
index 77b492462..5f4fc2796 100644
--- a/src/app/room.service.ts
+++ b/src/app/room.service.ts
@@ -34,8 +34,7 @@ export class RoomService extends ErrorHandlingService {
   getRoom(id: string): Observable<Room> {
     const url = `${this.roomsUrl}/${id}`;
     return this.http.get<Room>(url).pipe(
-      tap(_ => ''),
-      catchError(this.handleError<Room>(`getRoom id=${id}`))
-    );
+    catchError(this.handleError<Room>(`getRoom id=${id}`))
+  );
   }
 }
-- 
GitLab