From 91f41b026f60ea6d5adc211da330f83cdbe8d72f Mon Sep 17 00:00:00 2001 From: paf <paf@titelfrei.de> Date: Wed, 6 Jan 2021 11:10:34 +0100 Subject: [PATCH] add info field to GetFileResponseData interface and display the the additional useful data it can contain --- .../files/files.component.html | 22 ++++++++++++--- .../workspace-admin/files/files.component.ts | 28 +++++++++++-------- .../workspace-admin/workspace.interfaces.ts | 3 ++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/app/workspace-admin/files/files.component.html b/src/app/workspace-admin/files/files.component.html index 9afd02a8..d376b64f 100644 --- a/src/app/workspace-admin/files/files.component.html +++ b/src/app/workspace-admin/files/files.component.html @@ -54,7 +54,12 @@ <ng-container matColumnDef="filesize"> <mat-header-cell *matHeaderCellDef mat-sort-header> Größe </mat-header-cell> - <mat-cell *matCellDef="let element"> {{element.filesizestr}} </mat-cell> + <mat-cell *matCellDef="let element"> + {{element.filesizestr}} + <span *ngIf="element.info.totalSize"> + / {{element.info.totalSize | bytes }} + </span> + </mat-cell> </ng-container> @@ -104,16 +109,25 @@ <mat-icon class="report-info">info</mat-icon> <span> {{stat.value.valid}} valide Datei{{stat.value.valid == 1 ? '' : 'en'}} vom Typ {{stat.key}} - {{(stat.value.all > stat.value.valid) ? '(von insgesamt ' + stat.value.all + ')' : ''}} + {{(stat.value.total > stat.value.valid) ? '(von insgesamt ' + stat.value.total + ')' : ''}} + </span> + </div> + </div> + + <div> + <div class="vertical-align-middle"> + <mat-icon class="report-warning">warning</mat-icon> + <span> + {{fileStats.testtakers}} Testteilnehmer definiert. </span> </div> </div> - <div *ngIf="fileStats.valid < fileStats.all"> + <div *ngIf="fileStats.valid < fileStats.total"> <div class="vertical-align-middle"> <mat-icon class="report-warning">warning</mat-icon> <span> - {{fileStats.valid}} Datei{{fileStats.valid == 1 ? '' : 'en'}} von {{fileStats.all}} + {{fileStats.valid}} Datei{{fileStats.valid == 1 ? '' : 'en'}} von {{fileStats.total}} sind nicht valide oder haben fehlende Abhängigkeiten und werden ignoriert! </span> </div> diff --git a/src/app/workspace-admin/files/files.component.ts b/src/app/workspace-admin/files/files.component.ts index b205901c..8bfd5e17 100644 --- a/src/app/workspace-admin/files/files.component.ts +++ b/src/app/workspace-admin/files/files.component.ts @@ -19,12 +19,13 @@ import { MainDataService } from '../../maindata.service'; interface FileStats { types: { [type: string]: { - all: number; + total: number; valid: number; } } - all: number; + total: number; valid: number; + testtakers: number; } @Component({ @@ -47,8 +48,9 @@ export class FilesComponent implements OnInit { @ViewChild(MatSort, { static: true }) sort: MatSort; public fileStats: FileStats = { types: {}, - all: 0, - valid: 0 + total: 0, + valid: 0, + testtakers: 0 }; constructor( @@ -154,20 +156,24 @@ export class FilesComponent implements OnInit { private static getStats(fileList: GetFileResponseData[]): FileStats { const stats: FileStats = { types: {}, - all: 0, - valid: 0 + total: 0, + valid: 0, + testtakers: 0 }; fileList.forEach(file => { if (typeof stats.types[file.type] === 'undefined') { stats.types[file.type] = { - all: 0, + total: 0, valid: 0 }; } - stats.types[file.type].all += 1; - stats.types[file.type].valid += (file.report.error && file.report.error.length) ? 1 : 0; - stats.all += 1; - stats.valid += (file.report.error && file.report.error.length) ? 1 : 0; + stats.types[file.type].total += 1; + stats.total += 1; + if (file.report.error && file.report.error.length) { + stats.valid += 1; + stats.types[file.type].valid += 1; + stats.testtakers += (typeof file.info.testtakers !== "undefined") ? file.info.testtakers : 0; + } }); return stats; } diff --git a/src/app/workspace-admin/workspace.interfaces.ts b/src/app/workspace-admin/workspace.interfaces.ts index bc5f1ca7..aeb16634 100644 --- a/src/app/workspace-admin/workspace.interfaces.ts +++ b/src/app/workspace-admin/workspace.interfaces.ts @@ -17,6 +17,9 @@ export interface GetFileResponseData { error: string[]; warning: string[]; info: string[]; + }, + info: { + [key: string]: number; } } -- GitLab