diff --git a/src/app/components/shared/comment-list/comment-list.component.html b/src/app/components/shared/comment-list/comment-list.component.html index 67389651dd653103118019fbaf8963f31a365c7e..886f34baf99903c51dea2c4c29dfa201a309b555 100644 --- a/src/app/components/shared/comment-list/comment-list.component.html +++ b/src/app/components/shared/comment-list/comment-list.component.html @@ -49,6 +49,9 @@ <button mat-icon-button (focus)="hideCommentsList=false" (click)="sortTimeStamp()"> <mat-icon color="primary">remove</mat-icon> </button> + <button mat-icon-button *ngIf="userRole === 1" (focus)="hideCommentsList=false" (click)="deleteComments()"> + <mat-icon color="primary">delete</mat-icon> + </button> </div> </mat-menu> </div> 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 96ba333323c06c461709a1805f051810eada05e7..edbaadb4c33ddc5b337102d50f599e28ac3cfea3 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -200,4 +200,8 @@ export class CommentListComponent implements OnInit { return +dateB - +dateA; }); } + + deleteComments(): void { + this.commentService.deleteCommentsByRoomId(this.roomId).subscribe(); + } } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index c3179ad69aad8f1c8811b5bdd8254d3294e47f31..df643a7db61f9f15b3497c94ff7bcc1ee4820c68 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -66,4 +66,12 @@ export class CommentService extends BaseHttpService { catchError(this.handleError<any>('updateComment')) ); } + + deleteCommentsByRoomId(roomId: string): Observable<Comment> { + const connectionUrl = `${this.apiUrl.base + this.apiUrl.comment}/byRoom?roomId=${roomId}`; + return this.http.delete<Comment>(connectionUrl, httpOptions).pipe( + tap(_ => ''), + catchError(this.handleError<Comment>('deleteComment')) + ); + } }