diff --git a/src/app/components/creator/comment-creator-page/comment-creator-page.component.html b/src/app/components/creator/comment-creator-page/comment-creator-page.component.html new file mode 100644 index 0000000000000000000000000000000000000000..cb304da36e93923b448b9828927e96afbd907ab6 --- /dev/null +++ b/src/app/components/creator/comment-creator-page/comment-creator-page.component.html @@ -0,0 +1,3 @@ +<div fxLayout="row" fxLayoutAlign="center"> + <app-comment-list></app-comment-list> +</div> diff --git a/src/app/components/creator/comment-creator-page/comment-creator-page.component.scss b/src/app/components/creator/comment-creator-page/comment-creator-page.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..501394eb496b8c96db882589073de268cfcb434a --- /dev/null +++ b/src/app/components/creator/comment-creator-page/comment-creator-page.component.scss @@ -0,0 +1,4 @@ +app-comment-list { + width: 100%; + max-width: 800px; +} diff --git a/src/app/components/creator/comment-creator-page/comment-creator-page.component.spec.ts b/src/app/components/creator/comment-creator-page/comment-creator-page.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..de0a3aef6dc4dfda982d534c827258d562a082c9 --- /dev/null +++ b/src/app/components/creator/comment-creator-page/comment-creator-page.component.spec.ts @@ -0,0 +1,26 @@ +/* import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CommentCreatorPageComponent } from './comment-creator-page.component'; + +describe('CommentCreatorPageComponent', () => { + let component: CommentCreatorPageComponent; + let fixture: ComponentFixture<CommentCreatorPageComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CommentCreatorPageComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CommentCreatorPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); +*/ diff --git a/src/app/components/creator/comment-creator-page/comment-creator-page.component.ts b/src/app/components/creator/comment-creator-page/comment-creator-page.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..eedc6d5e88e697a81659a3d3fd51b809158c445a --- /dev/null +++ b/src/app/components/creator/comment-creator-page/comment-creator-page.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-comment-creator-page', + templateUrl: './comment-creator-page.component.html', + styleUrls: ['./comment-creator-page.component.scss'] +}) +export class CommentCreatorPageComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/src/app/components/creator/creator-routing.module.ts b/src/app/components/creator/creator-routing.module.ts index 8f5d6276a24767d2f2014ce5da03d676aea7db51..37cc87063de37571aba54ebc76be84f41371afa9 100644 --- a/src/app/components/creator/creator-routing.module.ts +++ b/src/app/components/creator/creator-routing.module.ts @@ -6,11 +6,11 @@ import { UserRole } from '../../models/user-roles.enum'; import { RoomCreatorPageComponent } from './room-creator-page/room-creator-page.component'; import { ContentCreatePageComponent } from './content-create-page/content-create-page.component'; import { StatisticsPageComponent } from '../shared/statistics-page/statistics-page.component'; -import { CommentListComponent } from '../shared/comment-list/comment-list.component'; import { FeedbackBarometerPageComponent } from '../shared/feedback-barometer-page/feedback-barometer-page.component'; import { ContentListComponent } from './content-list/content-list.component'; import { StatisticComponent } from '../shared/statistic/statistic.component'; import { ContentPresentationComponent } from './content-presentation/content-presentation.component'; +import { CommentCreatorPageComponent } from './comment-creator-page/comment-creator-page.component'; const routes: Routes = [ { @@ -45,7 +45,7 @@ const routes: Routes = [ }, { path: 'room/:roomId/comments', - component: CommentListComponent, + component: CommentCreatorPageComponent, canActivate: [AuthenticationGuard], data: { roles: [UserRole.CREATOR] } }, diff --git a/src/app/components/creator/creator.module.ts b/src/app/components/creator/creator.module.ts index bd0dce86a7b46517d424cac55f2982c658200d84..e006cc6eb83ca13bf61b3e2d43bc3079f605a906 100644 --- a/src/app/components/creator/creator.module.ts +++ b/src/app/components/creator/creator.module.ts @@ -21,6 +21,7 @@ import { ContentCreatorComponent } from './content-creator/content-creator.compo import { ContentListComponent } from './content-list/content-list.component'; import { ContentEditComponent } from './_dialogs/content-edit/content-edit.component'; import { ContentPresentationComponent } from './content-presentation/content-presentation.component'; +import { CommentCreatorPageComponent } from './comment-creator-page/comment-creator-page.component'; @NgModule({ imports: [ @@ -50,7 +51,8 @@ import { ContentPresentationComponent } from './content-presentation/content-pre ContentCreatorComponent, ContentListComponent, ContentEditComponent, - ContentPresentationComponent + ContentPresentationComponent, + CommentCreatorPageComponent ], entryComponents: [ RoomDeleteComponent, diff --git a/src/app/components/participant/comment-create-page/comment-create-page.component.html b/src/app/components/participant/comment-create-page/comment-create-page.component.html index ee4cc4d166a10b0d823fc0054d16522a72c293ac..15f1a94f992f3905d07b32dbcfa26964dfd73334 100644 --- a/src/app/components/participant/comment-create-page/comment-create-page.component.html +++ b/src/app/components/participant/comment-create-page/comment-create-page.component.html @@ -4,12 +4,13 @@ <mat-form-field class="input-block"> <input matInput #commentSubject type="text" maxlength="25" placeholder="{{ 'comment-page.enter-title' | translate}}" onkeypress="return event.keyCode !=13;" - [formControl]="emptySubject"> - <mat-hint align="end" *ngIf="!emptyInputs">{{commentSubject.value.length}} / 25</mat-hint> + [formControl]="subjectForm"> + <mat-hint align="end">{{commentSubject.value.length}} / 25</mat-hint> </mat-form-field> <mat-form-field class="input-block"> - <textarea matInput #commentBody placeholder="{{ 'comment-page.enter-comment' | translate}}" matTextareaAutosize - matAutosizeMinRows=1 matAutosizeMaxRows=5 [formControl]="emptyBody"></textarea> + <textarea matInput #commentBody placeholder="{{ 'comment-page.enter-comment' | translate}}" + matAutosizeMinRows=2 matAutosizeMaxRows=5 maxlength="255" [formControl]="bodyForm"></textarea> + <mat-hint align="end">{{commentBody.value.length}} / 255</mat-hint> </mat-form-field> <button mat-raised-button color="accent" (click)="send(commentSubject.value, commentBody.value)">{{ 'comment-page.send' | translate}}</button> @@ -18,4 +19,4 @@ <div fxLayout="row" fxLayoutAlign="center"> <app-comment-list></app-comment-list> </div> -</div> \ No newline at end of file +</div> diff --git a/src/app/components/participant/comment-create-page/comment-create-page.component.scss b/src/app/components/participant/comment-create-page/comment-create-page.component.scss index e1772bc657443a5156ba8b38411311b6614ca46a..1f1de2f029615a8edeffb46607ba3e95c63eb6a8 100644 --- a/src/app/components/participant/comment-create-page/comment-create-page.component.scss +++ b/src/app/components/participant/comment-create-page/comment-create-page.component.scss @@ -14,3 +14,7 @@ button { float: right; min-width: 80px; } + +textarea { + line-height: 120%; +} diff --git a/src/app/components/participant/comment-create-page/comment-create-page.component.ts b/src/app/components/participant/comment-create-page/comment-create-page.component.ts index c472c2187d56a97ae9658c222d0e7b53b42c9b4b..cc9a856544b82c240dd9b5a82583696266feb1dc 100644 --- a/src/app/components/participant/comment-create-page/comment-create-page.component.ts +++ b/src/app/components/participant/comment-create-page/comment-create-page.component.ts @@ -1,10 +1,8 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { Location } from '@angular/common'; import { FormControl, Validators } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; import { Comment } from '../../../models/comment'; -import { RoomService } from '../../../services/http/room.service'; import { CommentService } from '../../../services/http/comment.service'; import { NotificationService } from '../../../services/util/notification.service'; import { AuthenticationService } from '../../../services/http/authentication.service'; @@ -22,15 +20,14 @@ export class CommentCreatePageComponent implements OnInit { roomShortId: string; user: User; private date = new Date(Date.now()); - private emptySubject = new FormControl('', [Validators.required]); - private emptyBody = new FormControl('', [Validators.required]); + subjectForm = new FormControl('', [Validators.required]); + bodyForm = new FormControl('', [Validators.required]); + constructor( protected authenticationService: AuthenticationService, private route: ActivatedRoute, - private roomService: RoomService, private commentService: CommentService, - private location: Location, private notification: NotificationService, private translationService: TranslateService) { } @@ -73,11 +70,6 @@ export class CommentCreatePageComponent implements OnInit { } as Comment).subscribe(() => { this.child.getComments(); this.notification.show(`Comment '${subject}' successfully created.`); - this.goBack(); }); } - - goBack(): void { - this.location.back(); - } } diff --git a/src/app/components/shared/comment-list/comment-list.component.scss b/src/app/components/shared/comment-list/comment-list.component.scss index 77a82d8e448827ecaee2280958add3480d0e99a7..c08119116161a855547715a19a1411dc3a1a0925 100644 --- a/src/app/components/shared/comment-list/comment-list.component.scss +++ b/src/app/components/shared/comment-list/comment-list.component.scss @@ -3,8 +3,9 @@ mat-card { background-color: #4db6ac; } -mat-card-content>:first-child { - margin-top: 20px; +app-comment { + overflow: auto; + overflow-wrap: break-word; } .card-container { @@ -13,20 +14,22 @@ mat-card-content>:first-child { overflow-wrap: break-word; } -mat-card-title { - font-size: 20px; +.outer-card { + border-radius: 8px; } input { border: 2px solid #4db6ac; - border-radius: 30px; - padding: 5px 10px 5px 20px; - width: 50%; + box-sizing: border-box; + padding: 5px 10px 5px 30px; + margin-bottom: 0px; } .search-results li { list-style-type: none; - width: 50%; + display: block; + width: 100%; + margin-top: 0px; } li a { @@ -35,6 +38,12 @@ li a { display: block; color: black; background-color: #b2dfdb; - padding: 10px; - + padding: 10px; +} + +.search-results :hover { + background-color: #4db6ac; +} + +.search-results li a:hover { } \ No newline at end of file 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 151fe845627ec91967151f422bb8d0ec632bd05a..38dbd71b8e970d8d08b972ff759587b72e063919 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -1,8 +1,12 @@ <<<<<<< HEAD -import { Component, OnInit, Pipe, PipeTransform } from '@angular/core'; +<<<<<<< HEAD +import { Component, OnInit } from '@angular/core'; ======= import { Component, Input, OnInit } from '@angular/core'; >>>>>>> a0f6bb05fb39a0233a51dc9debdfa829bf04b279 +======= +import { Component, OnInit } from '@angular/core'; +>>>>>>> b275bae9e04ebe1a7088d23418c209efe7295036 import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; @@ -22,8 +26,12 @@ import { LanguageService } from '../../../services/util/language.service'; templateUrl: './comment-list.component.html', styleUrls: ['./comment-list.component.scss'] }) +<<<<<<< HEAD export class CommentListComponent implements OnInit{ userRoleTemp: any = UserRole.CREATOR; +======= +export class CommentListComponent implements OnInit { +>>>>>>> b275bae9e04ebe1a7088d23418c209efe7295036 userRole: UserRole; user: User; comments: Comment[]; diff --git a/src/app/components/shared/comment/comment.component.html b/src/app/components/shared/comment/comment.component.html index 834776dfaa0ec0d4c5d13c17524ac853a8d67ec3..5293d2f6504fad0399b72aaf98d9a64c266f64b4 100644 --- a/src/app/components/shared/comment/comment.component.html +++ b/src/app/components/shared/comment/comment.component.html @@ -1,5 +1,11 @@ -<mat-card> - <mat-card-title>{{comment.subject}}</mat-card-title> +<mat-card class="card-container"> + <div fxLayout="row" fxLayoutAlign="center center"> + <mat-card-title>{{comment.subject}}</mat-card-title> + <span class="fill-remaining-space"></span> + <button mat-icon-button [disabled]="userRole === 0" (click)="setCorrect(comment)" [matTooltip]="comment.correct ? 'Anwort richtig' : null"> + <mat-icon [ngClass]="{'correct-icon' : comment.correct === true}">check_circle</mat-icon> + </button> + </div> <mat-divider></mat-divider> <mat-card-content> <p>{{comment.body}}</p> diff --git a/src/app/components/shared/comment/comment.component.scss b/src/app/components/shared/comment/comment.component.scss index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..52e87c8f4d46dd26bbe4eadcc2af352633c54a62 100644 --- a/src/app/components/shared/comment/comment.component.scss +++ b/src/app/components/shared/comment/comment.component.scss @@ -0,0 +1,40 @@ +mat-card { + margin-bottom: 20px; + background-color: #b2ebf2; +} + +mat-card-content>:first-child { + margin-top: 20px; +} + +mat-toolbar { + border-radius: 10px; + margin-bottom: 20px; + background-color: #bbdefb; +} + +.card-container { + background-color: #4dd0e1; + opacity: 0.7; + border-radius: 2px; +} + +.outer-card { + border-radius: 8px; +} + +mat-icon { + color: white; +} + +.incorrect-icon { + color: white; +} + +.correct-icon { + color: green; +} + +mat-card-title { + margin: 0px; +} diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 24a9ea824ff980a303370a4e37043d980f5b0ba8..dbbff9b61a1231e154d6ca05efa0ab971d2e0721 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -4,7 +4,6 @@ import { UserRole } from '../../../models/user-roles.enum'; import { User } from '../../../models/user'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { ActivatedRoute } from '@angular/router'; -import { RoomService } from '../../../services/http/room.service'; import { Location } from '@angular/common'; import { CommentService } from '../../../services/http/comment.service'; import { NotificationService } from '../../../services/util/notification.service'; @@ -18,16 +17,12 @@ import { LanguageService } from '../../../services/util/language.service'; }) export class CommentComponent implements OnInit { @Input() comment: Comment; - userRoleTemp: any = UserRole.CREATOR; userRole: UserRole; user: User; isLoading = true; - roomId: string; - roomShortId: string; constructor(protected authenticationService: AuthenticationService, private route: ActivatedRoute, - private roomService: RoomService, private location: Location, private commentService: CommentService, private notification: NotificationService, @@ -38,14 +33,18 @@ export class CommentComponent implements OnInit { ngOnInit() { this.userRole = this.authenticationService.getRole(); this.user = this.authenticationService.getUser(); - this.roomShortId = this.route.snapshot.paramMap.get('roomId'); - this.roomId = localStorage.getItem(`roomId`); this.translateService.use(localStorage.getItem('currentLang')); } + setRead(comment: Comment): void { this.commentService.updateComment(comment).subscribe(); } + setCorrect(comment: Comment): void { + comment.correct = !comment.correct; + this.commentService.updateComment(comment).subscribe(); + } + delete(comment: Comment): void { this.commentService.deleteComment(comment.id).subscribe(room => { this.notification.show(`Comment '${comment.subject}' successfully deleted.`); diff --git a/src/app/models/comment.ts b/src/app/models/comment.ts index aed78ce9a3d621aaf7524545b47ab305c579a924..f13906b2c77f00e9b483ad0470e2dadf375f48d0 100644 --- a/src/app/models/comment.ts +++ b/src/app/models/comment.ts @@ -6,5 +6,6 @@ export class Comment { subject: string; body: string; read: boolean; + correct: boolean; creationTimestamp: number; } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index ffa639f7f505f6f8882a017e6709afa890b801c4..13c5436c8930df40d859f0cac5aa3aac7313f54a 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -77,7 +77,7 @@ export class CommentService extends BaseHttpService { } updateComment(comment: Comment): Observable<any> { - const connectionUrl = this.apiUrl + this.apiUrl.comment + '/' + comment.id; + const connectionUrl = this.apiUrl.base + this.apiUrl.comment + '/' + comment.id; return this.http.put(connectionUrl, comment, httpOptions).pipe( tap(_ => ''), catchError(this.handleError<any>('updateComment'))