diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index e146fa219697ba8a43c1a87d4d65d2fd7dba2105..dc9a91ab681a9eff8e359e6c4bd542512d5a4c8c 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -58,7 +58,7 @@ const routes: Routes = [ data: { roles: [UserRole.CREATOR] } }, { - path: 'creator/room/:roomId/content', + path: 'creator/room/:roomId/:contentGroup', component: ContentListComponent, canActivate: [AuthenticationGuard], data: { roles: [UserRole.CREATOR] } 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 37abd9e9b7d72f9a4fb36abe4d30fae89d1e564c..6fc4941376d87e8e111754cf746df6d2c55752f5 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,5 @@ - <mat-card *ngFor="let contentGroup of displayedContentGroups"> + <mat-card *ngFor="let contentGroup of displayedContentGroups" (click)="getContents(contentGroup)"> <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 483aa103ee790b9fb30ed6352fc040f6eb16663d..b54ef72c3b7071e0eafddd8115962eb8afeb4814 100644 --- a/src/app/components/fragments/content-groups/content-groups.component.ts +++ b/src/app/components/fragments/content-groups/content-groups.component.ts @@ -1,4 +1,8 @@ -import { Component, Input, OnInit} from '@angular/core'; +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'; class ContentGroup { name: string; @@ -21,11 +25,17 @@ export class ContentGroupsComponent implements OnInit { @Input() public contentGroups: {[key: string]: [string]}; displayedContentGroups: ContentGroup[] = []; + roomShortId: string; + contents: ContentText[]; - constructor () { + constructor (private route: ActivatedRoute, + private router: Router, + private contentService: ContentService + ) { } ngOnInit() { + this.roomShortId = this.route.snapshot.paramMap.get('roomId'); Object.keys(this.contentGroups).forEach(key => { if (key === '') { const cg = new ContentGroup( @@ -42,4 +52,12 @@ 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); + } } 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 38cff133558789ad3c98902a0a8b362762f4cec9..05c7e4f6e16b8223aebbe2af763f8a39e9a1ad69 100644 --- a/src/app/components/fragments/content-list/content-list.component.ts +++ b/src/app/components/fragments/content-list/content-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { ContentService } from '../../../services/http/content.service'; import { Content } from '../../../models/content'; import { ActivatedRoute } from '@angular/router'; @@ -19,7 +19,7 @@ import { NotificationService } from '../../../services/util/notification.service }) export class ContentListComponent implements OnInit { - contents = []; + @Input('contents') contents: ContentText[]; contentBackup: Content; diff --git a/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts b/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts index 88ad6abf428f4c38b3c4d69edce1b42857e5bfdc..62409b074aef0595048f242f9049afdf6b96d62d 100644 --- a/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts +++ b/src/app/components/pages/content-carousel-page/content-carousel-page.component.ts @@ -5,6 +5,7 @@ import { ContentChoice } from '../../../models/content-choice'; import { ContentText } from '../../../models/content-text'; import { ContentService } from '../../../services/http/content.service'; import { ActivatedRoute } from '@angular/router'; +import { Content } from '../../../models/content'; @Component({ selector: 'app-content-carousel-page', @@ -14,8 +15,7 @@ import { ActivatedRoute } from '@angular/router'; export class ContentCarouselPageComponent implements OnInit { ContentType: typeof ContentType = ContentType; -// contents: Content[]; - contents = []; + contents: Content[]; constructor(private contentService: ContentService, private route: ActivatedRoute) { @@ -23,10 +23,9 @@ export class ContentCarouselPageComponent implements OnInit { ngOnInit() { this.route.params.subscribe(params => { - // ToDo: Check api call - /* this.contentService.getContent(params['roomId']).subscribe(result => { + this.contentService.getContents(params['roomId']).subscribe(result => { this.contents = result; - }); */ + }); }); } } diff --git a/src/app/services/http/content.service.ts b/src/app/services/http/content.service.ts index 9cfb93f7a9e2d58d2b1aa583dd39b032572f24ec..64d49e0d418d810f388ef5207e6ee279f61b8f66 100644 --- a/src/app/services/http/content.service.ts +++ b/src/app/services/http/content.service.ts @@ -33,7 +33,7 @@ export class ContentService extends BaseHttpService { } getContentsByIds(ids: string[]): Observable<Content[]> { - const connectionUrl = this.apiUrl.base + this.apiUrl.content + ids.toString(); + const connectionUrl = this.apiUrl.base + this.apiUrl.content + '/' + ids.toString(); return this.http.get<Content[]>(connectionUrl).pipe( tap(() => ''), catchError(this.handleError('getContentsByIds', []))