Skip to content
Snippets Groups Projects
Commit 809601d4 authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Merge branch '83-see-read-comments' into 'master'

Resolve "See read comments"

Closes #83

See merge request swtp-block-ws17/arsnova-angular-frontend!72
parents 53fb7ae6 9c27c78c
1 merge request!72Resolve "See read comments"
Pipeline #13308 passed with stage
in 34 seconds
<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10"> <div fxLayout="row" fxLayoutAlign="center">
<div *ngFor="let comment of comments"> <div fxLayout="column" fxLayoutGap="20px">
<mat-card> <div *ngFor="let comment of comments">
<mat-card-content> <mat-card>
<div class="comment-body"> <mat-card-content>
<h3>{{comment.subject}}</h3><br> <h3>{{comment.subject}}</h3>
{{comment.body}} {{comment.body}}
<div class="trash-icon"> <div class="body-buttons" fxLayout="Column" fxLayoutGap="5px" fxLayoutAlign="end">
<i class="material-icons" (click)="delete(comment)">delete</i> <button *ngIf="!comment.read" mat-fab color="warn" matTooltip="Is not read" (click)="setRead(comment)">
</div> <mat-icon>clear</mat-icon>
</div> </button>
</mat-card-content> <button *ngIf="comment.read" mat-fab color="primary" matTooltip="Is read" (click)="setRead(comment)">
<mat-card-footer> <mat-icon>check</mat-icon>
<div class="date"> </button>
<i> Submitted on {{comment.creationTimestamp | date:'dd-MM-yyyy HH:mm:ss' : format}} </i> <button class="trash-icon" mat-fab color="primary" matTooltip="Delete" (click)="delete(comment)">
</div> <mat-icon>delete</mat-icon>
</mat-card-footer> </button>
</mat-card><br> </div>
</mat-card-content>
<mat-card-footer>
<div class="date">
<i> Submitted on {{comment.creationTimestamp | date:'dd-MM-yyyy HH:mm:ss' : format}} </i>
</div>
</mat-card-footer>
</mat-card><br>
</div>
<button class="back-button" mat-raised-button color="primary" (click)="goBack()">Back</button>
</div> </div>
</div> </div>
<button mat-raised-button color="primary" (click)="goBack()">Back</button>
.trash-icon { mat-card {
min-width: 800px;
justify-content: center;
}
mat-card-content {
min-height: 100px;
}
mat-card:hover {
box-shadow: 0 6px 6px 6px rgba(0,0,0,.2), 0 6px 6px 0 rgba(0,0,0,.14), 0 6px 6px 0 rgba(0,0,0,.12) !important;
transition: background .4s cubic-bezier(.25,.8,.25,1),box-shadow 300ms cubic-bezier(.3,0,.2,1);
}
.trash-icon:hover {
background: #F44336;
}
.back-button {
min-width: 800px;
}
.body-buttons {
position: absolute; position: absolute;
top: 50%; top: 10%;
left: 98%; left: 92%;
} }
.date { .date {
text-align: right; text-align: right;
font-size: 80%; font-size: 80%;
margin-right: 10px; margin-right: 10px;
margin-bottom: 3px;
} }
import { Component, Input, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { Comment } from '../comment'; import { Comment } from '../comment';
import { CommentService} from '../comment.service'; import { CommentService } from '../comment.service';
import { RoomService } from '../room.service'; import { RoomService } from '../room.service';
import { NotificationService } from '../notification.service'; import { NotificationService } from '../notification.service';
...@@ -30,15 +30,20 @@ export class CommentListComponent implements OnInit { ...@@ -30,15 +30,20 @@ export class CommentListComponent implements OnInit {
getRoom(id: string): void { getRoom(id: string): void {
this.roomService.getRoom(id).subscribe( this.roomService.getRoom(id).subscribe(
params => { params => {
this.getComments(params['id'], params['name']); this.getComments(params['id']);
}); });
} }
getComments(roomId: string, roomName: string): void { getComments(roomId: string): void {
this.commentService.getComments(roomId) this.commentService.getComments(roomId)
.subscribe(comments => this.comments = comments); .subscribe(comments => this.comments = comments);
} }
setRead(comment: Comment): void {
this.comments.find( c => c.id === comment.id).read = !comment.read;
this.commentService.updateComment(comment).subscribe();
}
delete(comment: Comment): void { delete(comment: Comment): void {
this.comments = this.comments.filter(c => c !== comment); this.comments = this.comments.filter(c => c !== comment);
this.commentService.deleteComment(comment).subscribe(room => { this.commentService.deleteComment(comment).subscribe(room => {
......
...@@ -39,4 +39,11 @@ export class CommentService extends ErrorHandlingService { ...@@ -39,4 +39,11 @@ export class CommentService extends ErrorHandlingService {
catchError(this.handleError<Comment[]>('getComments', [])) catchError(this.handleError<Comment[]>('getComments', []))
); );
} }
updateComment(comment: Comment): Observable<any> {
return this.http.put(this.commentsUrl, comment, httpOptions).pipe(
tap(_ => ''),
catchError(this.handleError<any>('updateComment'))
);
}
} }
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