Skip to content
Snippets Groups Projects
Verified Commit 94bc92cb authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Refactor AppRoutingeModule

Remove unnecassary api call for room to get room id (?!)
parent d2c925ae
1 merge request!86Resolve "content types (classes)"
Pipeline #13450 passed with stage
in 33 seconds
...@@ -58,7 +58,7 @@ const routes: Routes = [ ...@@ -58,7 +58,7 @@ const routes: Routes = [
data: { roles: [UserRole.CREATOR] } data: { roles: [UserRole.CREATOR] }
}, },
{ {
path: 'creator/room/:roomId/:id', path: 'creator/room/:roomId/:contentId',
component: ContentDetailComponent, component: ContentDetailComponent,
canActivate: [AuthenticationGuard], canActivate: [AuthenticationGuard],
data: { roles: [UserRole.CREATOR] } data: { roles: [UserRole.CREATOR] }
......
...@@ -18,12 +18,12 @@ export class ContentDetailComponent implements OnInit { ...@@ -18,12 +18,12 @@ export class ContentDetailComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
this.getContent(params['id']); this.getContent(params['contentId']);
}); });
} }
getContent(id: string): void { getContent(contentId: string): void {
this.contentService.getContent(id) this.contentService.getContent(contentId)
.subscribe(content => this.content = content); .subscribe(content => this.content = content);
} }
} }
...@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import { ContentService } from '../content.service'; import { ContentService } from '../content.service';
import { Content } from '../content'; import { Content } from '../content';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { RoomService } from '../room.service';
@Component({ @Component({
selector: 'app-content-list', selector: 'app-content-list',
...@@ -12,29 +11,20 @@ import { RoomService } from '../room.service'; ...@@ -12,29 +11,20 @@ import { RoomService } from '../room.service';
export class ContentListComponent implements OnInit { export class ContentListComponent implements OnInit {
contents: Content[]; contents: Content[];
constructor( constructor(private contentService: ContentService,
private contentService: ContentService, private route: ActivatedRoute) {
private route: ActivatedRoute, }
private roomService: RoomService,
) { }
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
this.getRoom(params['roomId']); this.getContents(params['roomId']);
}); });
} }
getRoom(id: string): void {
this.roomService.getRoom(id).subscribe(
params => {
this.getContents(params['id']);
});
}
getContents(roomId: string): void { getContents(roomId: string): void {
this.contentService.getContents(roomId) this.contentService.getContents(roomId)
.subscribe(contents => { .subscribe(contents => {
this.contents = contents; this.contents = contents;
}); });
} }
} }
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