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 882578590f14c62a223c166acf30eb90d1ee7cd9..506856101a42c3d51e5055316f9205878c3f9dec 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -75,7 +75,7 @@ export class CommentListComponent implements OnInit { c.roomId = this.roomId; c.body = payload.body; c.id = payload.id; - c.creationTimestamp = payload.timestamp; + c.timestamp = new Date(); this.comments = this.comments.concat(c); break; case 'CommentPatched': diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 23494d799cf0c4fb89fe18ae5f70c12a25d9c609..0b6491b5a35ac089cd40b0778f214f7094370324 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -2,14 +2,22 @@ <div fxLayout="column"> <div fxLayout="row"> <span class="fill-remaining-space"></span> - <button mat-icon-button *ngIf="comment.correct || !isStudent" [disabled]="isStudent" (click)="setCorrect(comment)" [matTooltip]="comment.correct ? 'Unmark as correct' : 'Mark as correct'"> - <mat-icon [ngClass]="{true : 'correct-icon', false: 'incorrect-icon'}[comment.correct]">check_circle</mat-icon> - </button> - <button mat-icon-button *ngIf="comment.favorite || !isStudent" [disabled]="isStudent" (click)="setFavorite(comment)" [matTooltip]="comment.favorite ? 'Mark as not favorite' : 'Mark as favorite'"> - <mat-icon [ngClass]="{true: 'favorite-icon', false: 'not-favorite-icon'}[comment.favorite]">star</mat-icon> + <div id="date"> + <div *ngIf="language === 'de'; else englishDate"> + {{comment.timestamp | date: ' HH:mm:ss '}}Uhr,{{comment.timestamp | date: ' M.d.yy'}} + </div> + <ng-template #englishDate> + {{comment.timestamp | date: 'h:mm:ss a, M/d/yy'}} + </ng-template> + </div> + <button mat-icon-button *ngIf="comment.correct || !isStudent" [disabled]="isStudent" (click)="setCorrect(comment)" [matTooltip]="comment.correct ? 'Unmark as correct' : 'Mark as correct'"> + <mat-icon [ngClass]="{true : 'correct-icon', false: 'incorrect-icon'}[comment.correct]">check_circle</mat-icon> + </button> + <button mat-icon-button *ngIf="comment.favorite || !isStudent" [disabled]="isStudent" (click)="setFavorite(comment)" [matTooltip]="comment.favorite ? 'Mark as not favorite' : 'Mark as favorite'"> + <mat-icon [ngClass]="{true: 'favorite-icon', false: 'not-favorite-icon'}[comment.favorite]">favorite_border</mat-icon> </button> <button mat-icon-button [disabled]="isStudent" (click)="setRead(comment)" [matTooltip]="comment.read ? 'Mark as unread' : 'Mark as read'"> - <mat-icon [ngClass]="{true: 'read-icon', false: 'unread-icon'}[comment.read]">visibility</mat-icon> + <mat-icon class="icon" [ngClass]="{true: 'read-icon', false: 'unread-icon'}[comment.read]">visibility</mat-icon> </button> </div> <div fxLayout="row"> @@ -26,5 +34,5 @@ </div> </div> </div> - </mat-card> - \ No newline at end of file + </mat-card> + diff --git a/src/app/components/shared/comment/comment.component.scss b/src/app/components/shared/comment/comment.component.scss index 4adef858b4fb0eda22e013fefb1e2ba48c94cf71..8084452349db7c8769e683d3adf51b6bc7523886 100644 --- a/src/app/components/shared/comment/comment.component.scss +++ b/src/app/components/shared/comment/comment.component.scss @@ -71,7 +71,20 @@ h2 { min-width: 200px; min-height: 100px; text-align: start; - font-size: large; + font-size: 140%; max-height: 120px; overflow: auto; + padding-left: 2%; + padding-right: 2%; +} + +.mat-icon { + transform: scale(1.2); +} + +#date { + padding-top: 10px; + margin-left: 2%; + opacity: 0.4; + position: absolute; } diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 2af7a5a05e93c80750089c3634b744726693a29f..fae83d243f619ddf089006796738f394f23125bd 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -42,6 +42,7 @@ export class CommentComponent implements OnInit { isStudent = false; isLoading = true; hasVoted = 0; + language: string; animationState: string; constructor(protected authenticationService: AuthenticationService, @@ -53,14 +54,18 @@ export class CommentComponent implements OnInit { public dialog: MatDialog, protected langService: LanguageService, private wsCommentService: WsCommentServiceService) { - langService.langEmitter.subscribe(lang => translateService.use(lang)); + langService.langEmitter.subscribe(lang => { + translateService.use(lang); + this.language = lang; + } ); } ngOnInit() { if (this.authenticationService.getRole() === 0) { this.isStudent = true; } - this.translateService.use(localStorage.getItem('currentLang')); + this.language = localStorage.getItem('currentLang'); + this.translateService.use(this.language); } startAnimation(state_: any): void { diff --git a/src/app/models/comment.ts b/src/app/models/comment.ts index 2fb2ad760db8e8cb2c39c6b389fb34f52f1fe474..df7165a4bd6c24397b611f3b3871e6fd3296e656 100644 --- a/src/app/models/comment.ts +++ b/src/app/models/comment.ts @@ -7,7 +7,7 @@ export class Comment { read: boolean; correct: boolean; favorite: boolean; - creationTimestamp: Date; + timestamp: Date; score: number; createdFromLecturer: boolean; @@ -28,7 +28,7 @@ export class Comment { this.read = read; this.correct = correct; this.favorite = favorite; - this.creationTimestamp = creationTimestamp; + this.timestamp = creationTimestamp; this.score = score; this.createdFromLecturer = createdFromLecturer; } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index 5eafa91d041fd8fde700abb89288139c47eaf292..f658bc23e6d4759567efb2ea2f37d6c89ffc0094 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -34,9 +34,8 @@ export class CommentService extends BaseHttpService { addComment(comment: Comment): Observable<Comment> { const connectionUrl = this.apiUrl.base + this.apiUrl.comment + '/'; return this.http.post<Comment>(connectionUrl, - { - roomId: comment.roomId, body: comment.body, - read: comment.read, creationTimestamp: comment.creationTimestamp + { roomId: comment.roomId, body: comment.body, + read: comment.read, creationTimestamp: comment.timestamp }, httpOptions).pipe( tap(_ => ''), catchError(this.handleError<Comment>('addComment'))