From 376e0e81a83513827f454bdf42586cd264096f56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Thu, 20 Jun 2019 16:34:03 +0200
Subject: [PATCH] Show room-shortId in header too

---
 .../components/shared/header/header.component.html   |  8 +++++++-
 src/app/components/shared/header/header.component.ts | 12 ++++++++----
 .../shared/room-list/room-list.component.html        |  2 +-
 .../shared/room-list/room-list.component.ts          |  4 ++++
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/app/components/shared/header/header.component.html b/src/app/components/shared/header/header.component.html
index e20a4639c..974f28b7f 100644
--- a/src/app/components/shared/header/header.component.html
+++ b/src/app/components/shared/header/header.component.html
@@ -7,7 +7,13 @@
     <span class="fill-remaining-space"></span>
     <h3 *ngIf="router.url.includes('comments') && user.role === 1" fxLayoutAlign="center center">
       <mat-icon>access_time</mat-icon>
-      {{cTime}}</h3>
+      {{cTime}}
+    </h3>
+    <span class="fill-remaining-space"
+          *ngIf="router.url.includes('comments') && user.role === 1 && deviceType === 'desktop'"></span>
+    <h3 *ngIf="router.url.includes('comments') && user.role === 1 && deviceType === 'desktop'" fxLayoutAlign="center center">
+      ID: {{roomId}}
+    </h3>
     <span class="fill-remaining-space"></span>
 
     <mat-menu class="color-menu" #themeMenu="matMenu" [overlapTrigger]="false">
diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts
index d6869ef1b..3f5f4a04f 100644
--- a/src/app/components/shared/header/header.component.ts
+++ b/src/app/components/shared/header/header.component.ts
@@ -20,6 +20,8 @@ export class HeaderComponent implements OnInit {
   user: User;
   themeClass = localStorage.getItem('theme');
   cTime: string;
+  roomId: string;
+  deviceType = localStorage.getItem('deviceType');
 
   constructor(public location: Location,
               private authenticationService: AuthenticationService,
@@ -42,14 +44,20 @@ export class HeaderComponent implements OnInit {
       this.translationService.setDefaultLang(localStorage.getItem('currentLang'));
     }
     this.authenticationService.watchUser.subscribe(newUser => this.user = newUser);
+    this.getRoomId();
     let time = new Date();
     this.getTime(time);
     setInterval(() => {
       time = new Date();
       this.getTime(time);
+      this.getRoomId();
     }, 1000);
   }
 
+  public getRoomId() {
+    this.roomId = localStorage.getItem('shortId');
+  }
+
   getTime(time: Date) {
     const hh = ('0' + time.getHours()).substr(-2);
     const mm = ('0' + time.getMinutes()).substr(-2);
@@ -68,10 +76,6 @@ export class HeaderComponent implements OnInit {
     this.location.back();
   }
 
-  goToHomepage() {
-    this.router.navigate(['/home']);
-  }
-
   useLanguage(language: string) {
     this.translationService.use(language);
     localStorage.setItem('currentLang', language);
diff --git a/src/app/components/shared/room-list/room-list.component.html b/src/app/components/shared/room-list/room-list.component.html
index af77f8f0b..5321c8178 100644
--- a/src/app/components/shared/room-list/room-list.component.html
+++ b/src/app/components/shared/room-list/room-list.component.html
@@ -13,7 +13,7 @@
   </mat-expansion-panel>
   <mat-expansion-panel *ngFor="let room of rooms" class="matPanel">
     <mat-expansion-panel-header class="matPanelListHeader">
-      <button mat-button routerLink="/{{ baseUrl }}/room/{{ room.shortId }}">
+      <button mat-button routerLink="/{{ baseUrl }}/room/{{ room.shortId }}" (click)="setCurrentRoom(room.shortId)">
         <mat-icon>input</mat-icon>
       </button>
       <mat-panel-title class="panelTitle">
diff --git a/src/app/components/shared/room-list/room-list.component.ts b/src/app/components/shared/room-list/room-list.component.ts
index 4dbaa2838..e55aaaf4b 100644
--- a/src/app/components/shared/room-list/room-list.component.ts
+++ b/src/app/components/shared/room-list/room-list.component.ts
@@ -51,4 +51,8 @@ export class RoomListComponent implements OnInit {
     this.closedRooms = this.rooms.filter(room => room.closed);
     this.isLoading = false;
   }
+
+  setCurrentRoom(shortId: string) {
+    localStorage.setItem('shortId', shortId);
+  }
 }
-- 
GitLab