From a0f0c5a6a2ed9dc4f3b71547edf1b57cd487bd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Tue, 4 Dec 2018 11:48:28 +0100 Subject: [PATCH] Make statuses variable --- .../list-statistic.component.html | 18 +++++++++--------- .../list-statistic/list-statistic.component.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) 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 09912ff27..e6f008d92 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.html +++ b/src/app/components/shared/list-statistic/list-statistic.component.html @@ -1,25 +1,25 @@ <mat-toolbar></mat-toolbar> <mat-progress-bar class="progress-theme" mode="determinate" value="{{total}}" - *ngIf="total > 85" color="primary"></mat-progress-bar> + *ngIf="total > statusGood" color="primary"></mat-progress-bar> <mat-progress-bar class="progress-theme" mode="determinate" value="{{total}}" - *ngIf="total < 85 && total > 49" color="accent"></mat-progress-bar> + *ngIf="total < statusGood && total >= statusOkay" color="accent"></mat-progress-bar> <mat-progress-bar class="progress-theme" mode="determinate" value="{{total}}" - *ngIf="total < 49" color="warn"></mat-progress-bar> + *ngIf="total < statusOkay && total > statusEmpty" color="warn"></mat-progress-bar> <mat-toolbar></mat-toolbar> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <ng-container matColumnDef="content"> <mat-header-cell *matHeaderCellDef> Content </mat-header-cell> - <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent > 85, - 'okayC' : cp.percent > 49 && cp.percent < 85, 'negativeC' : cp.percent < 50, - 'emptyCC' : cp.percent < 0 }">{{cp.content.subject}}</mat-cell> + <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent > statusGood, + 'okayC' : cp.percent >= statusOkay && cp.percent < statusGood, 'negativeC' : cp.percent < statusOkay, + 'emptyCC' : cp.percent < statusZero }">{{cp.content.subject}}</mat-cell> </ng-container> <ng-container matColumnDef="percentage"> <mat-header-cell *matHeaderCellDef> Percentage </mat-header-cell> - <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent > 85, - 'okayC' : cp.percent > 49 && cp.percent < 85, 'negativeC' : cp.percent < 50, - 'emptyC' : cp.percent < 0 }">{{cp.percent.toFixed() + ' %'}}</mat-cell> + <mat-cell *matCellDef="let cp" [ngClass]="{'positiveC' : cp.percent > statusGood, + 'okayC' : cp.percent >= statusOkay && cp.percent < statusGood, 'negativeC' : cp.percent < statusOkay, + 'emptyC' : cp.percent < statusZero }">{{cp.percent.toFixed() + ' %'}}</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 63bf4ebdb..dcb90044c 100644 --- a/src/app/components/shared/list-statistic/list-statistic.component.ts +++ b/src/app/components/shared/list-statistic/list-statistic.component.ts @@ -25,6 +25,10 @@ export class ListStatisticComponent implements OnInit { @Input() contentGroup: ContentGroup; contents: Content[] = []; displayedColumns = ['content', 'percentage']; + statusGood = 85; + statusOkay = 50; + statusEmpty = -1; + statusZero = 0; dataSource: ContentPercents[]; total = 0; totalP = 0; @@ -56,6 +60,8 @@ export class ListStatisticComponent implements OnInit { console.log(percent); this.totalP += percent; this.total = this.totalP / this.contentCounter; + } else { + this.total = -1; } }); } else { @@ -68,7 +74,7 @@ export class ListStatisticComponent implements OnInit { this.correctCounts = 0; this.totalCounts = 0; const length = options.length; - let correctIndex = new Array<number>(); + const correctIndex = new Array<number>(); let res: number; if (multiple) { let cic = 0; @@ -79,7 +85,7 @@ export class ListStatisticComponent implements OnInit { cic++; } } - let corrects = new Array<number>(); + const corrects = new Array<number>(); for (let i = 0; i < length; i++) { if (correctIndex.includes(i)) { corrects[cac] = indCounts[i]; -- GitLab