diff --git a/src/app/components/creator/_dialogs/room-edit/room-edit.component.html b/src/app/components/creator/_dialogs/room-edit/room-edit.component.html index 90db373e237b2f3afb4c3732a1070be8974b89e4..ee3ab788b23f1a1fc80bfbf131b6f2c620763905 100644 --- a/src/app/components/creator/_dialogs/room-edit/room-edit.component.html +++ b/src/app/components/creator/_dialogs/room-edit/room-edit.component.html @@ -1,4 +1,4 @@ -<div *ngIf="editRoom"> +<div mat-dialog-content *ngIf="editRoom"> <h2>{{'room-page.general' | translate }}</h2> <mat-divider></mat-divider> <div fxLayout="column"> diff --git a/src/app/components/creator/room-creator-page/room-creator-page.component.html b/src/app/components/creator/room-creator-page/room-creator-page.component.html index 8283f2948f5971a3ed6a82127f8d8b4f2e7f5612..b7c61024d7d634ed7750f836926843451d4740b3 100644 --- a/src/app/components/creator/room-creator-page/room-creator-page.component.html +++ b/src/app/components/creator/room-creator-page/room-creator-page.component.html @@ -20,7 +20,7 @@ </button> </div> <mat-divider></mat-divider> - <mat-card-content fxLayoutAlign="center"> + <mat-card-content *ngIf="room.description" fxLayoutAlign="center"> <h4> {{ room.description.trim() }} </h4> @@ -64,7 +64,7 @@ <app-content-groups *ngIf="room && room.contentGroups" [contentGroups]="room.contentGroups"></app-content-groups> --> </mat-card> - <div *ngIf="!isLoading && !room">Error: room could not be found!</div> + <div *ngIf="!isLoading && !room">{{ 'room-page.room-not-found' | translate }}</div> </div> </div> diff --git a/src/app/components/participant/room-participant-page/room-participant-page.component.html b/src/app/components/participant/room-participant-page/room-participant-page.component.html index dceb015578142b88ed9db2603c13542296c03d44..29373c1a66ca12b30dc19b8e7aaf932b3d0ac43f 100644 --- a/src/app/components/participant/room-participant-page/room-participant-page.component.html +++ b/src/app/components/participant/room-participant-page/room-participant-page.component.html @@ -11,7 +11,7 @@ </mat-card-subtitle> </mat-card-header> <mat-divider></mat-divider> - <mat-card-content fxLayoutAlign="center"> + <mat-card-content *ngIf="room.description" fxLayoutAlign="center"> <h4>{{room.description.trim()}}</h4> </mat-card-content> <mat-grid-list cols="1" rowHeight="2:1"> diff --git a/src/app/components/shared/_dialogs/present-comment/present-comment.component.ts b/src/app/components/shared/_dialogs/present-comment/present-comment.component.ts index 35bc3e620de7adeb0bcb3b13abadb4db6118227d..341a9423b19442f593b6654644a1cc8aa8463707 100644 --- a/src/app/components/shared/_dialogs/present-comment/present-comment.component.ts +++ b/src/app/components/shared/_dialogs/present-comment/present-comment.component.ts @@ -1,6 +1,7 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, HostListener, Inject } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material'; import { TranslateService } from '@ngx-translate/core'; +import { DOCUMENT } from '@angular/common'; @Component({ selector: 'app-present-comment', @@ -9,8 +10,12 @@ import { TranslateService } from '@ngx-translate/core'; }) export class PresentCommentComponent implements OnInit { public body: string; + // flag for fullscreen + private fs = false; + private ESCAPE_KEYCODE = 27; constructor( + @Inject(DOCUMENT) private document: Document, public dialogRef: MatDialogRef<PresentCommentComponent>, private translateService: TranslateService, public dialog: MatDialog @@ -18,6 +23,21 @@ export class PresentCommentComponent implements OnInit { ngOnInit() { this.translateService.use(localStorage.getItem('currentLang')); + /* if document is in fullscreen and user presses ESC, it doesn't trigger a keyup event */ + this.document.addEventListener('fullscreenchange', () => { + if (this.fs && this.document.exitFullscreen) { + this.onCloseClick(); + } else { + this.fs = true; + } + }); + } + + @HostListener('document:keyup', ['$event']) + onKeyUp(event: KeyboardEvent) { + if (event.keyCode === this.ESCAPE_KEYCODE) { + this.onCloseClick(); + } } onCloseClick(): void { diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 9cd24e35349738a46b3859fec4d8d6d616dc0133..3f542e46de067a6080ce5c0dc0278bb45432ab55 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -23,7 +23,7 @@ import { VoteService } from '../../../services/http/vote.service'; export class CommentListComponent implements OnInit { @Input() user: User; @Input() roomId: string; - comments: Comment[]; + comments: Comment[] = []; room: Room; hideCommentsList = false; filteredComments: Comment[]; diff --git a/src/app/components/shared/header/header.component.html b/src/app/components/shared/header/header.component.html index c592d71b50fb61e87e60afefa1aeded063238fac..1c76c3b8cae451bdaf01247522ff3b5030f33f8d 100644 --- a/src/app/components/shared/header/header.component.html +++ b/src/app/components/shared/header/header.component.html @@ -12,7 +12,7 @@ <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"> - {{'header.id' | translate}}: {{ roomId.slice(0,4) }} {{ roomId.slice(4,8) }} + {{'header.id' | translate}}: {{ shortId.slice(0,4) }} {{ shortId.slice(4,8) }} </h3> <span class="fill-remaining-space"></span> diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts index 3f5f4a04faf0d7f597ddd42206aeadc59c360ca3..50943e98f74f31167463931d8ab86cdde8cf4f77 100644 --- a/src/app/components/shared/header/header.component.ts +++ b/src/app/components/shared/header/header.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { NotificationService } from '../../../services/util/notification.service'; -import { Router } from '@angular/router'; +import { Router, NavigationEnd } from '@angular/router'; import { User } from '../../../models/user'; import { UserRole } from '../../../models/user-roles.enum'; import { Location } from '@angular/common'; @@ -20,7 +20,7 @@ export class HeaderComponent implements OnInit { user: User; themeClass = localStorage.getItem('theme'); cTime: string; - roomId: string; + shortId: string; deviceType = localStorage.getItem('deviceType'); constructor(public location: Location, @@ -44,18 +44,29 @@ 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'); + this.router.events.subscribe(val => { + /* the router will fire multiple events */ + /* we only want to react if it's the final active route */ + if (val instanceof NavigationEnd) { + /* segments gets all parts of the url */ + const segments = this.router.parseUrl(this.router.url).root.children.primary.segments; + const roomIdRegExp = new RegExp('^[0-9]{8}$'); + segments.forEach(element => { + /* searches the url segments for a short id */ + if (roomIdRegExp.test(element.path)) { + this.shortId = element.path; + } + }); + } + }); } getTime(time: Date) { diff --git a/src/assets/i18n/creator/de.json b/src/assets/i18n/creator/de.json index 4c9a7a010bbd694c7c364abf60bff3b5ccfb34eb..b2d00392a5a4d4031664fac954aa1ffb59ee22c3 100644 --- a/src/assets/i18n/creator/de.json +++ b/src/assets/i18n/creator/de.json @@ -28,7 +28,8 @@ "delete-all-comments": "Alle Kommentare löschen", "really-delete-comments": "Wollen Sie wirklich alle Kommentare dieser Session löschen?", "comments-deleted": "Alle Kommentare wurden gelöscht.", - "export-comments": "Kommentare exportieren" + "export-comments": "Kommentare exportieren", + "room-not-found": "Session wurde nicht gefunden :(" }, "content": { "content": "Frage", diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index 2f5c0855f3ae577d32ddc1e223c3b52012efd212..7dd1ec79bd4b0b4111173feb2a546d15529c0bca 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -28,7 +28,8 @@ "delete-all-comments": "Delete all comments", "really-delete-comments": "Do you really want to delete all comments of this session?", "comments-deleted": "All comments have been deleted.", - "export-comments": "Export comments" + "export-comments": "Export comments", + "room-not-found": "Session not found :(" }, "content": { "content": "Content",