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 @@
{{ i }}
</p>
<div *ngFor="let stat of fileStats | keyvalue">
<div *ngFor="let stat of fileStats.types | keyvalue">
<div class="vertical-align-middle">
<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>
<
......@@ -16,6 +16,17 @@ import { GetFileResponseData, CheckWorkspaceResponseData } from '../workspace.in
import { BackendService, FileDeletionReport } from '../backend.service';
import { MainDataService } from '../../maindata.service';
interface FileStats {
types: {
[type: string]: {
all: number;
valid: number;
}
}
all: number;
valid: number;
}
@Component({
templateUrl: './files.component.html',
styleUrls: ['./files.component.css']
......@@ -34,7 +45,11 @@ export class FilesComponent implements OnInit {
public checkInfos = [];
@ViewChild(MatSort, { static: true }) sort: MatSort;
public fileStats: {[type: string]: number};
public fileStats: FileStats = {
types: {},
all: 0,
valid: 0
};
constructor(
@Inject('SERVER_URL') private serverUrl: string,
......@@ -136,18 +151,25 @@ export class FilesComponent implements OnInit {
}
}
private static getStats(fileList: GetFileResponseData[]): {[type: string]: number} {
const stats: {[type: string]: number} = {};
// TODO filter validity
return fileList.reduce((carry, file) => {
if (typeof carry[file.type] === 'undefined') {
// eslint-disable-next-line no-param-reassign
carry[file.type] = 0;
private static getStats(fileList: GetFileResponseData[]): FileStats {
const stats: FileStats = {
types: {},
all: 0,
valid: 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
carry[file.type] += 1;
return carry;
}, stats);
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;
});
return stats;
}
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