diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index dc9a91ab681a9eff8e359e6c4bd542512d5a4c8c..f3934198f80bf6a22962ce8e02eb2f7cc6edee73 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -88,7 +88,7 @@ const routes: Routes = [ data: { roles: [UserRole.PARTICIPANT] } }, { - path: 'participant/room/:roomId/questions', + path: 'participant/room/:roomId/:contentGroup', component: ContentCarouselPageComponent, canActivate: [AuthenticationGuard], data: { roles: [UserRole.PARTICIPANT] } diff --git a/src/app/components/fragments/content-groups/content-groups.component.html b/src/app/components/fragments/content-groups/content-groups.component.html index 6fc4941376d87e8e111754cf746df6d2c55752f5..3f2e3642de4d0bd075c02e08eb5d80c6a3c9c5c7 100644 --- a/src/app/components/fragments/content-groups/content-groups.component.html +++ b/src/app/components/fragments/content-groups/content-groups.component.html @@ -1,5 +1,6 @@ - <mat-card *ngFor="let contentGroup of displayedContentGroups" (click)="getContents(contentGroup)"> + <mat-card *ngFor="let contentGroup of displayedContentGroups" (click)="viewContents(contentGroup)"> + <mat-divider></mat-divider> <mat-card-header> <mat-card-title> <h4>{{contentGroup.name}}<mat-icon matBadge="{{contentGroup.contentIds.length}}" matBadgePosition="after"></mat-icon></h4> diff --git a/src/app/components/fragments/content-groups/content-groups.component.ts b/src/app/components/fragments/content-groups/content-groups.component.ts index b54ef72c3b7071e0eafddd8115962eb8afeb4814..e4ea34f24c82d8ddfedae1b326439f672a5ef37c 100644 --- a/src/app/components/fragments/content-groups/content-groups.component.ts +++ b/src/app/components/fragments/content-groups/content-groups.component.ts @@ -1,8 +1,8 @@ import { Component, Input, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { ContentService } from '../../../services/http/content.service'; import { Content } from '../../../models/content'; -import { ContentText } from '../../../models/content-text'; +import { AuthenticationService } from '../../../services/http/authentication.service'; +import { UserRole } from '../../../models/user-roles.enum'; class ContentGroup { name: string; @@ -26,11 +26,10 @@ export class ContentGroupsComponent implements OnInit { @Input() public contentGroups: {[key: string]: [string]}; displayedContentGroups: ContentGroup[] = []; roomShortId: string; - contents: ContentText[]; constructor (private route: ActivatedRoute, private router: Router, - private contentService: ContentService + protected authService: AuthenticationService ) { } @@ -53,11 +52,13 @@ export class ContentGroupsComponent implements OnInit { }); } - getContents(contentGroup: ContentGroup) { - this.contentService.getContentsByIds(contentGroup.contentIds).subscribe( contents => { - this.contents = contents; - }); - this.router.navigate([`creator/room/${this.roomShortId}/${contentGroup.name}`]); - console.log(contentGroup.contentIds); + viewContents(contentGroup: ContentGroup) { + if (this.authService.getRole() === UserRole.CREATOR) { + this.router.navigate([`creator/room/${this.roomShortId}/${contentGroup.name}`]); + + } else { + this.router.navigate([`participant/room/${this.roomShortId}/${contentGroup.name}`]); + } + sessionStorage.setItem('contentGroup', JSON.stringify(contentGroup)); } } diff --git a/src/app/components/fragments/content-list/content-list.component.html b/src/app/components/fragments/content-list/content-list.component.html index 756295061ad1c9f6378274d66d5efdad82d291d0..aee7145dca929d33ca19d3f2e7df87b922f84d32 100644 --- a/src/app/components/fragments/content-list/content-list.component.html +++ b/src/app/components/fragments/content-list/content-list.component.html @@ -1,7 +1,6 @@ <mat-list> - <mat-list-item *ngFor="let content of contents"> - <button mat-button (click)="editContent(content.subject)"> + <mat-list-item *ngFor="let content of contents" (click)="editContent(content.subject)"> {{content.subject}} - </button> + <mat-divider></mat-divider> </mat-list-item> </mat-list> diff --git a/src/app/components/fragments/content-list/content-list.component.ts b/src/app/components/fragments/content-list/content-list.component.ts index 62806aa2d78cf80119376ffeade61aad174cb783..dda115925fde363d9798d1d9a1918db36b61d3f1 100644 --- a/src/app/components/fragments/content-list/content-list.component.ts +++ b/src/app/components/fragments/content-list/content-list.component.ts @@ -11,15 +11,31 @@ import { ContentChoiceCreatorComponent } from '../content-choice-creator/content import { ContentLikertCreatorComponent } from '../content-likert-creator/content-likert-creator.component'; import { ContentTextCreatorComponent } from '../content-text-creator/content-text-creator.component'; import { NotificationService } from '../../../services/util/notification.service'; +import { Room } from '../../../models/room'; +import { RoomService } from '../../../services/http/room.service'; + +class ContentGroup { + name: string; + contentIds: string[]; + autoSort: boolean; + + constructor(name: string, contentIds: string[], autoSort: boolean) { + this.name = name; + this.contentIds = contentIds; + this.autoSort = autoSort; + } +} @Component({ selector: 'app-content-list', templateUrl: './content-list.component.html', styleUrls: ['./content-list.component.scss'] }) + + export class ContentListComponent implements OnInit { - @Input('contents') contents: ContentText[]; + contents: Content[]; contentBackup: Content; @@ -27,7 +43,12 @@ export class ContentListComponent implements OnInit { roomId: string; + contentGroup: ContentGroup; + + room: Room; + constructor(private contentService: ContentService, + private roomService: RoomService, private route: ActivatedRoute, private notificationService: NotificationService, public dialog: MatDialog) { @@ -35,7 +56,14 @@ export class ContentListComponent implements OnInit { ngOnInit() { this.roomId = localStorage.getItem(`roomId`); - + this.roomService.getRoom(this.roomId).subscribe(room => { + this.room = room; + }); + this.contentGroup = JSON.parse(sessionStorage.getItem('contentGroup')); + this.contentService.getContentsByIds(this.contentGroup.contentIds).subscribe( contents => { + this.contents = contents; + }); + console.log(this.contents); } findIndexOfSubject(subject: string): number { diff --git a/src/app/components/pages/room-participant-page/room-participant-page.component.html b/src/app/components/pages/room-participant-page/room-participant-page.component.html index 4abb5f64ffd672416c855e7ff16eeafe2ddd741e..0d1a0a2248c7ee447d8c9eb8cef11f0c07abbb3f 100644 --- a/src/app/components/pages/room-participant-page/room-participant-page.component.html +++ b/src/app/components/pages/room-participant-page/room-participant-page.component.html @@ -28,9 +28,7 @@ </mat-grid-tile> </mat-grid-list> <mat-nav-list> - <mat-list-item matTooltip="Join question round" routerLink="/participant/room/{{ room.id }}/questions"> - Contents - </mat-list-item> + <app-content-groups *ngIf="room" [contentGroups]="room.contentGroups"></app-content-groups> <mat-list-item matTooltip="See room comments"> Comments </mat-list-item>