Skip to content
Snippets Groups Projects
Commit 82ae11a5 authored by Tom Käsler's avatar Tom Käsler
Browse files

Add a 'delete from room history' button for users

parent a7cce491
Branches
Tags
No related merge requests found
......@@ -73,13 +73,18 @@
</th>
<td mat-cell *matCellDef="let room" style="text-align: end"
attr.aria-labelledby="empty">
<button mat-flat-button type="button"
attr.aria-labelledby="{{ 'joinButtonLabel' + room.shortId | translate }}"
name="{{ 'room-list.panel-join-button' | translate }}"
routerLink="/{{ roleToString((room.role)) }}/room/{{ room.shortId }}"
(click)="setCurrentRoom(room.shortId)">
<mat-icon>input</mat-icon>
</button>
<button *ngIf="room.role < 3" mat-flat-button type="button"
name="{{ 'room-list.panel-remove-button' | translate }}"
(click)="removeFromHistory(room.id)">
<mat-icon>delete_forever</mat-icon>
</button>
<button mat-flat-button type="button"
attr.aria-labelledby="{{ 'joinButtonLabel' + room.shortId | translate }}"
name="{{ 'room-list.panel-join-button' | translate }}"
routerLink="/{{ roleToString((room.role)) }}/room/{{ room.shortId }}"
(click)="setCurrentRoom(room.shortId)">
<mat-icon>input</mat-icon>
</button>
<div class="visually-hidden">
<div id="{{ 'joinButtonLabel' + room.shortId | translate }}">
{{ 'room-list.join-message-template' | translate:{
......
......@@ -11,6 +11,8 @@ import { ModeratorService } from '../../../services/http/moderator.service';
import { MatTableDataSource } from '@angular/material';
import { Subscription } from 'rxjs';
import { CommentService } from '../../../services/http/comment.service';
import { NotificationService } from '../../../services/util/notification.service';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-room-list',
......@@ -38,7 +40,9 @@ export class RoomListComponent implements OnInit, OnDestroy {
public eventService: EventService,
protected authenticationService: AuthenticationService,
private moderatorService: ModeratorService,
private commentService: CommentService
private commentService: CommentService,
public notificationService: NotificationService,
private translateService: TranslateService
) {
}
......@@ -100,6 +104,18 @@ export class RoomListComponent implements OnInit, OnDestroy {
}
}
removeFromHistory(roomId: string) {
this.roomService.removeFromHistory(roomId).subscribe( x => {
this.rooms = this.rooms.filter(r => r.id !== roomId);
this.closedRooms = this.closedRooms.filter(r => r.id !== roomId);
this.roomsWithRole = this.roomsWithRole.filter(r => r.id !== roomId);
this.updateTable();
this.translateService.get('room-list.room-successfully-removed').subscribe(message => {
this.notificationService.show(message);
});
});
}
roleToString(role: UserRole): string {
switch (role) {
case UserRole.CREATOR:
......
......@@ -99,6 +99,14 @@ export class RoomService extends BaseHttpService {
this.http.post(connectionUrl, { roomId: roomId, lastVisit: this.joinDate.getTime() }, httpOptions).subscribe(() => {});
}
removeFromHistory(roomId: string): Observable<Room> {
const connectionUrl = `${ this.apiUrl.base + this.apiUrl.user }/${ this.authService.getUser().id }/roomHistory/${roomId}`;
return this.http.delete<Room>(connectionUrl, httpOptions).pipe(
tap(() => ''),
catchError(this.handleError<Room>('deleteRoom'))
);
}
updateRoom(updatedRoom: Room): Observable<Room> {
const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/~${ updatedRoom.shortId }`;
return this.http.put(connectionUrl, updatedRoom , httpOptions).pipe(
......
......@@ -206,10 +206,12 @@
"moderator-role": "Moderator",
"no-room-history": "Du hast bisher an keiner Sitzung teilgenommen.",
"panel-join-button": "",
"panel-remove-button": "Sitzung aus dem Verlauf löschen.",
"panel-session-id": "Code",
"panel-session-name": "Sitzung",
"panel-user-role": "Rolle",
"participant-role": "Teilnehmer",
"room-successfully-removed": "Die Sitzung wurde erfolgreich aus dem Verlauf gelöscht.",
"session-history": "Dein Sitzungsverlauf enthält {{count}} Sitzungen.",
"session-history-1": "Dein Sitzungsverlauf enthält genau eine Sitzung.",
"session-history-label": "Nachfolgend findest du eine Liste deiner Sitzungen."
......
......@@ -207,10 +207,12 @@
"moderator-role": "Moderator",
"no-room-history": "You haven't joined any sessions yet.",
"panel-join-button": "",
"panel-remove-button": "Delete the session from your room history.",
"panel-session-id": "Key",
"panel-session-name": "Session",
"panel-user-role": "Role",
"participant-role": "Participant",
"room-successfully-removed": "The session was successfully removed from the history.",
"session-history": "Your session history contains {count}} sessions.",
"session-history-1": "Your session history contains one session.",
"session-history-label": "Below you will find a list of your attended sessions."
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment