Skip to content
Snippets Groups Projects
Commit 13079f28 authored by paflov's avatar paflov
Browse files

nicer display of file-stats

parent 2dea9ccc
No related branches found
No related tags found
No related merge requests found
...@@ -99,12 +99,26 @@ ...@@ -99,12 +99,26 @@
{{ i }} {{ i }}
</p> </p>
<div *ngFor="let stat of fileStats | keyvalue"> <div *ngFor="let stat of fileStats.types | keyvalue">
<div class="vertical-align-middle"> <div class="vertical-align-middle">
<mat-icon class="report-info">info</mat-icon> <mat-icon class="report-info">info</mat-icon>
<alert text="{{stat.value}} Dateien vom Typ `{{stat.key}}`"></alert> <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 + ')' : ''}}
</span>
</div>
</div>
<div *ngIf="fileStats.valid < fileStats.all">
<div class="vertical-align-middle">
<mat-icon class="report-warning">warning</mat-icon>
<span>
{{fileStats.valid}} Datei{{fileStats.valid == 1 ? '' : 'en'}} von {{fileStats.all}}
sind nicht valide oder haben fehlende Abhängigkeiten und werden ignoriert!
</span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<
...@@ -16,6 +16,17 @@ import { GetFileResponseData, CheckWorkspaceResponseData } from '../workspace.in ...@@ -16,6 +16,17 @@ import { GetFileResponseData, CheckWorkspaceResponseData } from '../workspace.in
import { BackendService, FileDeletionReport } from '../backend.service'; import { BackendService, FileDeletionReport } from '../backend.service';
import { MainDataService } from '../../maindata.service'; import { MainDataService } from '../../maindata.service';
interface FileStats {
types: {
[type: string]: {
all: number;
valid: number;
}
}
all: number;
valid: number;
}
@Component({ @Component({
templateUrl: './files.component.html', templateUrl: './files.component.html',
styleUrls: ['./files.component.css'] styleUrls: ['./files.component.css']
...@@ -34,7 +45,11 @@ export class FilesComponent implements OnInit { ...@@ -34,7 +45,11 @@ export class FilesComponent implements OnInit {
public checkInfos = []; public checkInfos = [];
@ViewChild(MatSort, { static: true }) sort: MatSort; @ViewChild(MatSort, { static: true }) sort: MatSort;
public fileStats: {[type: string]: number}; public fileStats: FileStats = {
types: {},
all: 0,
valid: 0
};
constructor( constructor(
@Inject('SERVER_URL') private serverUrl: string, @Inject('SERVER_URL') private serverUrl: string,
...@@ -136,18 +151,25 @@ export class FilesComponent implements OnInit { ...@@ -136,18 +151,25 @@ export class FilesComponent implements OnInit {
} }
} }
private static getStats(fileList: GetFileResponseData[]): {[type: string]: number} { private static getStats(fileList: GetFileResponseData[]): FileStats {
const stats: {[type: string]: number} = {}; const stats: FileStats = {
// TODO filter validity types: {},
return fileList.reduce((carry, file) => { all: 0,
if (typeof carry[file.type] === 'undefined') { valid: 0
// eslint-disable-next-line no-param-reassign };
carry[file.type] = 0; fileList.forEach(file => {
if (typeof stats.types[file.type] === 'undefined') {
stats.types[file.type] = {
all: 0,
valid: 0
};
} }
// eslint-disable-next-line no-param-reassign stats.types[file.type].all += 1;
carry[file.type] += 1; stats.types[file.type].valid += (file.report.error && file.report.error.length) ? 1 : 0;
return carry; stats.all += 1;
}, stats); stats.valid += (file.report.error && file.report.error.length) ? 1 : 0;
});
return stats;
} }
download(element: GetFileResponseData): void { download(element: GetFileResponseData): void {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment