Skip to content
Snippets Groups Projects
Commit 46c5280d authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Fix create-comment button position

parent 528b197a
Branches
Tags
4 merge requests!171SWTP Comment Project,!170Fix linter in pipe,!169WebSocket Connector,!168Filter comment list
...@@ -3,9 +3,9 @@ import { Comment } from '../../../../models/comment'; ...@@ -3,9 +3,9 @@ import { Comment } from '../../../../models/comment';
import { NotificationService } from '../../../../services/util/notification.service'; import { NotificationService } from '../../../../services/util/notification.service';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CommentPageComponent } from '../../comment-page/comment-page.component';
import { FormControl, Validators } from '@angular/forms'; import { FormControl, Validators } from '@angular/forms';
import { User } from '../../../../models/user'; import { User } from '../../../../models/user';
import { CommentListComponent } from '../../comment-list/comment-list.component';
@Component({ @Component({
...@@ -20,17 +20,15 @@ export class SubmitCommentComponent implements OnInit { ...@@ -20,17 +20,15 @@ export class SubmitCommentComponent implements OnInit {
user: User; user: User;
roomId: string; roomId: string;
subjectForm = new FormControl('', [Validators.required]);
bodyForm = new FormControl('', [Validators.required]); bodyForm = new FormControl('', [Validators.required]);
private date = new Date(Date.now());
constructor( constructor(
private notification: NotificationService, private notification: NotificationService,
public dialogRef: MatDialogRef<CommentPageComponent>, public dialogRef: MatDialogRef<CommentListComponent>,
private translateService: TranslateService, private translateService: TranslateService,
public dialog: MatDialog, public dialog: MatDialog,
private translationService: TranslateService, private translationService: TranslateService,
@Inject(MAT_DIALOG_DATA) public data: any) { @Inject(MAT_DIALOG_DATA) public data: any) {
} }
ngOnInit() { ngOnInit() {
......
...@@ -14,3 +14,6 @@ ...@@ -14,3 +14,6 @@
<mat-card class="outer-card" *ngIf="!hideCommentsList"> <mat-card class="outer-card" *ngIf="!hideCommentsList">
<app-comment *ngFor="let current of comments" [comment]="current"> </app-comment> <app-comment *ngFor="let current of comments" [comment]="current"> </app-comment>
</mat-card> </mat-card>
<button mat-icon-button class="add-button" color="accent" (click)="openSubmitDialog()">
<mat-icon class="add-icon">add_circle</mat-icon>
</button>
...@@ -21,7 +21,7 @@ input { ...@@ -21,7 +21,7 @@ input {
} }
button{ button{
min-height: 100% !important; //min-height: 100% !important;
min-width: 100px; min-width: 100px;
} }
...@@ -34,3 +34,20 @@ mat-icon { ...@@ -34,3 +34,20 @@ mat-icon {
background-color: #80cbc4; background-color: #80cbc4;
margin-bottom: 10px; margin-bottom: 10px;
} }
.add-button {
width: 60px;
height: 60px;
position: fixed;
top: 80%;
right: 35%;
}
.add-icon {
font-size: 60px;
height: 60px;
width: 60px;
line-height: 100%!important;
}
import { Component, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Comment } from '../../../models/comment'; import { Comment } from '../../../models/comment';
import { CommentService } from '../../../services/http/comment.service'; import { CommentService } from '../../../services/http/comment.service';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { LanguageService } from '../../../services/util/language.service'; import { LanguageService } from '../../../services/util/language.service';
import { RxStompService } from '@stomp/ng2-stompjs'; import { RxStompService } from '@stomp/ng2-stompjs';
import { Message } from '@stomp/stompjs'; import { Message } from '@stomp/stompjs';
import { SubmitCommentComponent } from '../_dialogs/submit-comment/submit-comment.component';
import { MatDialog } from '@angular/material';
import { WsCommentServiceService } from '../../../services/websockets/ws-comment-service.service';
import { User } from '../../../models/user';
@Component({ @Component({
selector: 'app-comment-list', selector: 'app-comment-list',
...@@ -12,16 +16,19 @@ import { Message } from '@stomp/stompjs'; ...@@ -12,16 +16,19 @@ import { Message } from '@stomp/stompjs';
styleUrls: ['./comment-list.component.scss'] styleUrls: ['./comment-list.component.scss']
}) })
export class CommentListComponent implements OnInit { export class CommentListComponent implements OnInit {
@Input() user: User;
@Input() roomId: string;
comments: Comment[]; comments: Comment[];
isLoading = true; isLoading = true;
roomId: string;
hideCommentsList: boolean; hideCommentsList: boolean;
filteredComments: Comment[]; filteredComments: Comment[];
constructor(private commentService: CommentService, constructor(private commentService: CommentService,
private translateService: TranslateService, private translateService: TranslateService,
public dialog: MatDialog,
protected langService: LanguageService, protected langService: LanguageService,
private rxStompService: RxStompService) { private rxStompService: RxStompService,
private wsCommentService: WsCommentServiceService) {
langService.langEmitter.subscribe(lang => translateService.use(lang)); langService.langEmitter.subscribe(lang => translateService.use(lang));
} }
...@@ -88,5 +95,25 @@ export class CommentListComponent implements OnInit { ...@@ -88,5 +95,25 @@ export class CommentListComponent implements OnInit {
} }
} }
} }
openSubmitDialog(): void {
const dialogRef = this.dialog.open(SubmitCommentComponent, {
width: '400px'
});
dialogRef.componentInstance.user = this.user;
dialogRef.componentInstance.roomId = this.roomId;
dialogRef.afterClosed()
.subscribe(result => {
if (result) {
this.send(result);
} else {
return;
}
});
}
send(comment: Comment): void {
this.wsCommentService.add(comment);
}
} }
<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="20px"> <div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="20px">
<div fxLayout="row" fxLayoutAlign="center"> <div fxLayout="row" fxLayoutAlign="center">
<mat-toolbar>List of Questions <app-comment-list [user]="user" [roomId]="roomId"></app-comment-list>
<span class="fill-remaining-space"></span>
<button mat-icon-button color="primary" (click)="openSubmitDialog()">
<mat-icon>add_circle</mat-icon>
</button></mat-toolbar>
</div>
<div fxLayout="row" fxLayoutAlign="center">
<app-comment-list></app-comment-list>
</div> </div>
</div> </div>
...@@ -2,23 +2,3 @@ app-comment-list { ...@@ -2,23 +2,3 @@ app-comment-list {
width: 100%; width: 100%;
max-width: 800px; max-width: 800px;
} }
.mat-icon-button {
width: 50px;
height: 50px;
margin-bottom: 20px;
margin-top: 20px;
}
mat-icon {
font-size: 50px;
height: 50px;
width: 50px;
line-height: 100%!important;
}
mat-toolbar {
border-radius: 10px;
background-color: #bbdefb;
max-width: 800px;
}
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Comment } from '../../../models/comment';
import { User } from '../../../models/user'; import { User } from '../../../models/user';
import { NotificationService } from '../../../services/util/notification.service'; import { NotificationService } from '../../../services/util/notification.service';
import { AuthenticationService } from '../../../services/http/authentication.service'; import { AuthenticationService } from '../../../services/http/authentication.service';
import { MatDialog } from '@angular/material';
import { SubmitCommentComponent } from '../_dialogs/submit-comment/submit-comment.component';
import { WsCommentServiceService } from '../../../services/websockets/ws-comment-service.service';
@Component({ @Component({
selector: 'app-comment-page', selector: 'app-comment-page',
...@@ -19,32 +15,10 @@ export class CommentPageComponent implements OnInit { ...@@ -19,32 +15,10 @@ export class CommentPageComponent implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private notification: NotificationService, private notification: NotificationService,
public dialog: MatDialog, private authenticationService: AuthenticationService) { }
private authenticationService: AuthenticationService,
private wsCommentService: WsCommentServiceService) { }
ngOnInit(): void { ngOnInit(): void {
this.roomId = localStorage.getItem('roomId'); this.roomId = localStorage.getItem('roomId');
this.user = this.authenticationService.getUser(); this.user = this.authenticationService.getUser();
} }
openSubmitDialog(): void {
const dialogRef = this.dialog.open(SubmitCommentComponent, {
width: '400px'
});
dialogRef.componentInstance.user = this.user;
dialogRef.componentInstance.roomId = this.roomId;
dialogRef.afterClosed()
.subscribe(result => {
if (result) {
this.send(result);
} else {
return;
}
});
}
send(comment: Comment): void {
this.wsCommentService.add(comment);
}
} }
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