From 437ba0dbe0e03ea5538a000a66987f534d9ce6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20K=C3=A4sler?= <tom.kaesler@mni.thm.de> Date: Wed, 8 Aug 2018 15:43:48 +0200 Subject: [PATCH] fix use of roomId instead of shortId --- .../comment-list/comment-list.component.ts | 4 +++- .../content-choice-creator.component.ts | 4 +++- .../content-list/content-list.component.ts | 2 +- .../content-text-creator.component.ts | 4 +++- .../fragments/room-join/room-join.component.ts | 2 +- .../comment-create-page.component.ts | 4 +++- .../room-creator-page.component.html | 8 ++++---- .../pages/room-page/room-page.component.ts | 2 +- .../room-participant-page.component.ts | 2 +- src/app/services/http/room.service.ts | 17 +++++++++++++++-- 10 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/app/components/fragments/comment-list/comment-list.component.ts b/src/app/components/fragments/comment-list/comment-list.component.ts index dee58c5af..f58c18928 100644 --- a/src/app/components/fragments/comment-list/comment-list.component.ts +++ b/src/app/components/fragments/comment-list/comment-list.component.ts @@ -21,6 +21,7 @@ export class CommentListComponent implements OnInit { comments: Comment[]; isLoading = true; roomId: string; + roomShortId: string; constructor(protected authenticationService: AuthenticationService, private route: ActivatedRoute, @@ -33,7 +34,8 @@ export class CommentListComponent implements OnInit { ngOnInit() { this.userRole = this.authenticationService.getRole(); this.user = this.authenticationService.getUser(); - this.roomId = this.route.snapshot.paramMap.get('roomId'); + this.roomShortId = this.route.snapshot.paramMap.get('roomId'); + this.roomId = localStorage.getItem(`roomId`); this.getComments(); } diff --git a/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts b/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts index 2807e4513..168be5465 100644 --- a/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts +++ b/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts @@ -55,6 +55,7 @@ export class ContentChoiceCreatorComponent implements OnInit { changesAllowed = false; roomId: string; + roomShortId: string; constructor(private contentService: ContentService, private notificationService: NotificationService, @@ -65,7 +66,8 @@ export class ContentChoiceCreatorComponent implements OnInit { } ngOnInit() { - this.roomId = this.route.snapshot.paramMap.get('roomId'); + this.roomShortId = this.route.snapshot.paramMap.get('roomId'); + this.roomId = localStorage.getItem(`roomId`); this.fillCorrectAnswers(); } 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 d569cfb08..6829ffa1b 100644 --- a/src/app/components/fragments/content-list/content-list.component.ts +++ b/src/app/components/fragments/content-list/content-list.component.ts @@ -76,7 +76,7 @@ export class ContentListComponent implements OnInit { } ngOnInit() { - this.roomId = this.route.snapshot.paramMap.get('roomId'); + this.roomId = localStorage.getItem(`roomId`); this.getContents(this.roomId); } diff --git a/src/app/components/fragments/content-text-creator/content-text-creator.component.ts b/src/app/components/fragments/content-text-creator/content-text-creator.component.ts index f1bc273e4..eab10cd0f 100644 --- a/src/app/components/fragments/content-text-creator/content-text-creator.component.ts +++ b/src/app/components/fragments/content-text-creator/content-text-creator.component.ts @@ -15,6 +15,7 @@ import { ContentDeleteComponent } from '../../dialogs/content-delete/content-del export class ContentTextCreatorComponent implements OnInit { roomId: string; + roomShortId: string; content: ContentText = new ContentText('1', '1', '0', @@ -33,7 +34,8 @@ export class ContentTextCreatorComponent implements OnInit { } ngOnInit() { - this.roomId = this.route.snapshot.paramMap.get('roomId'); + this.roomId = localStorage.getItem(`roomId`); + this.roomShortId = this.route.snapshot.paramMap.get('roomId'); } resetAfterSubmit() { diff --git a/src/app/components/fragments/room-join/room-join.component.ts b/src/app/components/fragments/room-join/room-join.component.ts index 8827f35a6..f8199b4a3 100644 --- a/src/app/components/fragments/room-join/room-join.component.ts +++ b/src/app/components/fragments/room-join/room-join.component.ts @@ -38,7 +38,7 @@ export class RoomJoinComponent implements OnInit { } getRoom(id: string): void { - this.roomService.getRoom(id) + this.roomService.getRoomByShortId(id) .subscribe(room => { this.room = room; if (!room) { diff --git a/src/app/components/pages/comment-create-page/comment-create-page.component.ts b/src/app/components/pages/comment-create-page/comment-create-page.component.ts index 45158e840..a43e05b97 100644 --- a/src/app/components/pages/comment-create-page/comment-create-page.component.ts +++ b/src/app/components/pages/comment-create-page/comment-create-page.component.ts @@ -18,6 +18,7 @@ import { CommentListComponent } from '../../fragments/comment-list/comment-list. export class CommentCreatePageComponent implements OnInit { @ViewChild(CommentListComponent) child: CommentListComponent; roomId: string; + roomShortId: string; user: User; private date = new Date(Date.now()); @@ -31,7 +32,8 @@ export class CommentCreatePageComponent implements OnInit { ngOnInit(): void { this.user = this.authenticationService.getUser(); - this.roomId = this.route.snapshot.paramMap.get('roomId'); + this.roomShortId = this.route.snapshot.paramMap.get('roomId'); + this.roomId = localStorage.getItem(`roomId`); } send(subject: string, body: string): void { diff --git a/src/app/components/pages/room-creator-page/room-creator-page.component.html b/src/app/components/pages/room-creator-page/room-creator-page.component.html index c87b5ce44..8608c4fba 100644 --- a/src/app/components/pages/room-creator-page/room-creator-page.component.html +++ b/src/app/components/pages/room-creator-page/room-creator-page.component.html @@ -23,19 +23,19 @@ <mat-divider></mat-divider> <mat-card-actions> <button mat-button color="primary" matTooltip="Create new content" - routerLink="/creator/room/{{ room.id }}/create-content"> + routerLink="/creator/room/{{ room.shortId }}/create-content"> Create content </button> <button mat-button color="primary" matTooltip="See room comments" - routerLink="/creator/room/{{ room.id }}/comments"> + routerLink="/creator/room/{{ room.shortId }}/comments"> Comments </button> <button mat-button color="primary" matTooltip="See feedback" - routerLink="/creator/room/{{ room.id }}/feedback-barometer"> + routerLink="/creator/room/{{ room.shortId }}/feedback-barometer"> Feedback barometer </button> <button mat-button color="primary" matTooltip="See answer statistics" - routerLink="/creator/room/{{ room.id }}/answer-statistics"> + routerLink="/creator/room/{{ room.shortId }}/answer-statistics"> Answer statistics </button> <button *ngIf="!modify" (click)="showEditDialog()" mat-button color="primary"> diff --git a/src/app/components/pages/room-page/room-page.component.ts b/src/app/components/pages/room-page/room-page.component.ts index 7a79ee8e6..f4360ec49 100644 --- a/src/app/components/pages/room-page/room-page.component.ts +++ b/src/app/components/pages/room-page/room-page.component.ts @@ -25,7 +25,7 @@ export class RoomPageComponent implements OnInit { } getRoom(id: string): void { - this.roomService.getRoom(id).subscribe(room => { + this.roomService.getRoomByShortId(id).subscribe(room => { this.room = room; this.isLoading = false; }); diff --git a/src/app/components/pages/room-participant-page/room-participant-page.component.ts b/src/app/components/pages/room-participant-page/room-participant-page.component.ts index abd076005..0b358b710 100644 --- a/src/app/components/pages/room-participant-page/room-participant-page.component.ts +++ b/src/app/components/pages/room-participant-page/room-participant-page.component.ts @@ -26,7 +26,7 @@ export class RoomParticipantPageComponent implements OnInit { } getRoom(id: string): void { - this.roomService.getRoom(id) + this.roomService.getRoomByShortId(id) .subscribe(room => { this.room = room; this.isLoading = false; diff --git a/src/app/services/http/room.service.ts b/src/app/services/http/room.service.ts index 251826004..42b4aaf4d 100644 --- a/src/app/services/http/room.service.ts +++ b/src/app/services/http/room.service.ts @@ -56,9 +56,18 @@ export class RoomService extends BaseHttpService { } getRoom(id: string): Observable<Room> { - const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/~${ id }`; + const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/${ id }`; return this.http.get<Room>(connectionUrl).pipe( - catchError(this.handleError<Room>(`getRoom id=${ id }`)) + tap(room => this.setRoomId(room)), + catchError(this.handleError<Room>(`getRoom keyword=${ id }`)) + ); + } + + getRoomByShortId(shortId: string): Observable<Room> { + const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/~${ shortId }`; + return this.http.get<Room>(connectionUrl).pipe( + tap(room => this.setRoomId(room)), + catchError(this.handleError<Room>(`getRoom shortId=${ shortId }`)) ); } @@ -82,4 +91,8 @@ export class RoomService extends BaseHttpService { catchError(this.handleError<Room>('deleteRoom')) ); } + + setRoomId(room: Room): void { + localStorage.setItem(`roomId`, room.id); + } } -- GitLab