Skip to content
Snippets Groups Projects
Commit fbd9cd5c authored by David Noah Donges's avatar David Noah Donges
Browse files

Merge branch '80-fix-approuting' into 'master'

Resolve "Fix - AppRouting"

Closes #80

See merge request swtp-block-ws17/arsnova-angular-frontend!66
parents d0ba9e5c bcd65209
No related merge requests found
......@@ -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] }
......
......@@ -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.`);
});
}
......
......@@ -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">
......
......@@ -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">
......
......@@ -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();
});
}
......
......@@ -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>
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 {
......
<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-->
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