diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 6b23d40b29f2aedf1da21b896d8135c0212e3c1b..43f6b8ba07102c4c1b788b6c63a11e4f7748c5c2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; import { LoginScreenComponent } from './login-screen/login-screen.component'; -import { RoomComponent } from './room/room.component'; import { CreatorHomeScreenComponent } from './creator-home-screen/creator-home-screen.component'; import { CreateCommentComponent } from './create-comment/create-comment.component'; import { ParticipantHomeScreenComponent } from './participant-home-screen/participant-home-screen.component'; @@ -10,7 +9,6 @@ import { AuthenticationGuard } from './authentication.guard'; import { UserRole } from './user-roles.enum'; import { ParticipantRoomComponent } from './participant-room/participant-room.component'; import { CreatorRoomComponent } from './creator-room/creator-room.component'; -import { CommentComponent } from './comment/comment.component'; import { CommentListComponent } from './comment-list/comment-list.component'; const routes: Routes = [ @@ -29,8 +27,8 @@ const routes: Routes = [ data: { roles: [UserRole.PARTICIPANT] } }, { - path: 'room/:roomId', - component: RoomComponent, + path: 'creator/room/:roomId', + component: CreatorRoomComponent, canActivate: [AuthenticationGuard] }, { @@ -39,12 +37,12 @@ const routes: Routes = [ canActivate: [AuthenticationGuard] }, { - path: 'room/:roomId/comments', + path: 'creator/room/:roomId/comments', component: CommentListComponent, canActivate: [AuthenticationGuard], data: { roles: [UserRole.CREATOR] } }, - { path: 'room/:roomId/create-comment', + { path: 'participant/room/:roomId/create-comment', component: CreateCommentComponent, canActivate: [AuthenticationGuard], data: { roles: [UserRole.PARTICIPANT] } diff --git a/src/app/create-comment/create-comment.component.ts b/src/app/create-comment/create-comment.component.ts index b3d5c1afb4a224f3a18ad784f81ffc3aceedfb3f..73e69402cc3109f3681a5616058c05b157ad297e 100644 --- a/src/app/create-comment/create-comment.component.ts +++ b/src/app/create-comment/create-comment.component.ts @@ -45,8 +45,8 @@ export class CreateCommentComponent implements OnInit { subject: subject, body: body, creationTimestamp: new Date(Date.now()) - } as Comment).subscribe(room => { - this.router.navigate([`room/${this.room.id}`]); + } as Comment).subscribe(() => { + this.router.navigate([`/participant/room/${this.room.id}`]); this.notification.show(`Comment '${subject}' successfully created.`); }); } diff --git a/src/app/creator-room/creator-room.component.html b/src/app/creator-room/creator-room.component.html index e0b263da174e6c2209ba29fd19a50496b7c3ad5b..79ca12101fc5b56db7f08b1334709605825578c8 100644 --- a/src/app/creator-room/creator-room.component.html +++ b/src/app/creator-room/creator-room.component.html @@ -19,7 +19,7 @@ <button mat-button color="primary" matTooltip="See contents"> Contents </button> - <button mat-button color="primary" matTooltip="See room comments"> + <button mat-button color="primary" matTooltip="See room comments" routerLink="/creator/room/{{room.id}}/comments"> Comments </button> <button mat-button color="warn" matTooltip="Delete selected room"> diff --git a/src/app/participant-room/participant-room.component.html b/src/app/participant-room/participant-room.component.html index 250352b278958dc693284df5094455d51b06cc88..97cb1722448e84fbb7847902cd9d74add2f563f4 100644 --- a/src/app/participant-room/participant-room.component.html +++ b/src/app/participant-room/participant-room.component.html @@ -14,7 +14,7 @@ </mat-card-content> <mat-divider></mat-divider> <mat-card-actions> - <button mat-icon-button color="primary" matTooltip="Ask something" routerLink="room/{{room.id}}/create-comment"> + <button mat-icon-button color="primary" matTooltip="Create comment" routerLink="/participant/room/{{ room.id }}/create-comment"> <mat-icon>question_answer</mat-icon> </button> <button mat-icon-button color="primary" matTooltip="Give feedback"> diff --git a/src/app/room-creation/room-creation.component.ts b/src/app/room-creation/room-creation.component.ts index 7b4d24e278acf53cbe0f3bcd915ff594ff2906d2..dddc2900b19009c4d8cffbc99bbbc74415fd0480 100644 --- a/src/app/room-creation/room-creation.component.ts +++ b/src/app/room-creation/room-creation.component.ts @@ -37,7 +37,7 @@ export class RoomCreationComponent implements OnInit { this.roomService.addRoom({ name: longRoomName, abbreviation: shortRoomName } as Room) .subscribe(room => { this.notification.show(`Room '${room.name}' successfully created.`); - this.router.navigate([`creator/room/${room.id}`]); + this.router.navigate([`/creator/room/${room.id}`]); this.dialogRef.close(); }); } diff --git a/src/app/room-list/room-list.component.html b/src/app/room-list/room-list.component.html index abc862f2d89b478caa0511f8ff912a8911215afe..28a577a9dd214a14e16e897d6ca291441e0c8e29 100644 --- a/src/app/room-list/room-list.component.html +++ b/src/app/room-list/room-list.component.html @@ -12,7 +12,7 @@ {{ room.description }} </p> <mat-action-row> - <button mat-button routerLink="room/{{ room.id }}">Join room</button> + <button mat-button routerLink="/{{ baseUrl }}/room/{{ room.id }}">Join room</button> </mat-action-row> </mat-expansion-panel> </mat-accordion> diff --git a/src/app/room-list/room-list.component.ts b/src/app/room-list/room-list.component.ts index effcbed6ce821c6a5dd162c6e705ef40be0241f4..a5dd6a3d2de3f4a0ddc07df670d6be02b3e9cea1 100644 --- a/src/app/room-list/room-list.component.ts +++ b/src/app/room-list/room-list.component.ts @@ -1,6 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { Room } from '../room'; import { RoomService } from '../room.service'; +import { AuthenticationService} from '../authentication.service'; +import {UserRole} from '../user-roles.enum'; @Component({ selector: 'app-room-list', @@ -10,12 +12,23 @@ import { RoomService } from '../room.service'; export class RoomListComponent implements OnInit { rooms: Room[]; closedRooms: Room[]; + baseUrl: string; - constructor(protected roomService: RoomService) { - } + constructor( + private roomService: RoomService, + protected authenticationService: AuthenticationService) {} ngOnInit() { this.getRooms(); + this.getPath(); + } + + getPath() { + if (this.authenticationService.getRole() === UserRole.CREATOR) { + this.baseUrl = 'creator'; + } else { + this.baseUrl = 'participant'; + } } getRooms(): void { diff --git a/src/app/room/room.component.html b/src/app/room/room.component.html index 581e828d571ba5ae17e6fcd65018df714e08dfeb..e4bc6fc71b268e206ec1c5b1e2810a5eeef31dfa 100644 --- a/src/app/room/room.component.html +++ b/src/app/room/room.component.html @@ -1,4 +1,3 @@ - <mat-list *ngIf="room"> <mat-list-item>ID: {{room.id}}</mat-list-item> <mat-list-item>Revision: {{room.revision}}</mat-list-item> @@ -7,14 +6,6 @@ <mat-list-item>Name: {{room.name}}</mat-list-item> <mat-list-item>Description: {{room.description}}</mat-list-item> <mat-list-item>Closed: {{room.closed}}</mat-list-item> - - <button mat-button routerLink="/room/{{room.id}}/create-comment"> - Create comment <!-- Only for participant --> - </button> - - <button mat-button routerLink="/room/{{room.id}}/comments"> - Visit comments <!-- Only for creator --> - </button> </mat-list> <!-- content-type of room-->