diff --git a/src/app/components/shared/list-statistic/list-statistic.component.html b/src/app/components/shared/list-statistic/list-statistic.component.html index 65fb3bca8ad3057038491d08a0b8b31d737c6418..27862d1f62ec988e1858e97298c5c9b7b8e2413c 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.html +++ b/src/app/components/shared/list-statistic/list-statistic.component.html @@ -14,7 +14,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyCC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.content.subject}}</mat-cell> + 'emptyCC' : cp.percent < status.zero }" (click)="goToStats(cp.contentId)">{{cp.content.subject}}</mat-cell> </ng-container> <ng-container matColumnDef="percentage"> @@ -23,7 +23,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.percent.toFixed() + ' %'}}</mat-cell> + 'emptyC' : cp.percent < status.zero }" (click)="goToStats(cp.contentId)">{{cp.percent.toFixed() + ' %'}}</mat-cell> </ng-container> <ng-container matColumnDef="counts"> @@ -32,7 +32,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.counts}}</mat-cell> + 'emptyC' : cp.percent < status.zero }" (click)="goToStats(cp.contentId)">{{cp.counts}}</mat-cell> </ng-container> <ng-container matColumnDef="abstentions"> @@ -41,7 +41,7 @@ 'positiveC' : cp.percent >= status.good, 'okayC' : cp.percent >= status.okay && cp.percent < status.good, 'negativeC' : cp.percent < status.okay, - 'emptyC' : cp.percent < status.zero }" routerLink="{{nextLink}}{{cp.contentId}}">{{cp.abstentions}}</mat-cell> + 'emptyC' : cp.percent < status.zero }" (click)="goToStats(cp.contentId)">{{cp.abstentions}}</mat-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> diff --git a/src/app/components/shared/list-statistic/list-statistic.component.ts b/src/app/components/shared/list-statistic/list-statistic.component.ts index 68a2344b24951964f9f5c647edc559bef2046d09..20b1834ad38bcc111884266dc0168a5e43a09f08 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.ts +++ b/src/app/components/shared/list-statistic/list-statistic.component.ts @@ -8,7 +8,7 @@ import { ContentChoice } from '../../../models/content-choice'; import { Combination } from '../../../models/round-statistics'; import { TranslateService } from '@ngx-translate/core'; import { LanguageService } from '../../../services/util/language.service'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { UserRole } from '../../../models/user-roles.enum'; @@ -49,10 +49,11 @@ export class ListStatisticComponent implements OnInit { totalP = 0; contentCounter = 0; roomId: number; - nextLink: string; + baseUrl: string; constructor(private contentService: ContentService, private translateService: TranslateService, + private router: Router, protected langService: LanguageService, protected route: ActivatedRoute, protected authService: AuthenticationService) { @@ -62,16 +63,24 @@ export class ListStatisticComponent implements OnInit { ngOnInit() { this.route.params.subscribe(params => { this.roomId = params['roomId']; - if (this.authService.getRole() === UserRole.CREATOR) { - this.nextLink = `/creator/room/${ this.roomId }/statistics/`; - } else { - this.nextLink = `/participant/room/${ this.roomId }/statistics/`; - } }); this.translateService.use(localStorage.getItem('currentLang')); this.contentService.getContentChoiceByIds(this.contentGroup.contentIds).subscribe(contents => { this.getData(contents); }); + this.getBaseUrl(); + } + + getBaseUrl() { + if (this.authService.getRole() === UserRole.CREATOR) { + this.baseUrl = `/creator/room/${ this.roomId }/statistics/`; + } else { + this.baseUrl = `/participant/room/${ this.roomId }/statistics/`; + } + } + + goToStats(id: string) { + this.router.navigate([`${this.baseUrl}${id}`]); } getData(contents: ContentChoice[]) {