Skip to content
Snippets Groups Projects
Commit 864fe0d6 authored by paf's avatar paf
Browse files

count stats of files

parent 67c9631e
No related branches found
No related tags found
No related merge requests found
...@@ -99,6 +99,8 @@ ...@@ -99,6 +99,8 @@
{{ i }} {{ i }}
</p> </p>
<pre>{{fileStats | json}}</pre>
<br/> <br/>
</div> </div>
......
...@@ -34,6 +34,7 @@ export class FilesComponent implements OnInit { ...@@ -34,6 +34,7 @@ export class FilesComponent implements OnInit {
public checkInfos = []; public checkInfos = [];
@ViewChild(MatSort, { static: true }) sort: MatSort; @ViewChild(MatSort, { static: true }) sort: MatSort;
private fileStats: {[type: string]: number};
constructor( constructor(
@Inject('SERVER_URL') private serverUrl: string, @Inject('SERVER_URL') private serverUrl: string,
...@@ -131,12 +132,27 @@ export class FilesComponent implements OnInit { ...@@ -131,12 +132,27 @@ export class FilesComponent implements OnInit {
(fileList: GetFileResponseData[]) => { (fileList: GetFileResponseData[]) => {
this.serverfiles = new MatTableDataSource(fileList); this.serverfiles = new MatTableDataSource(fileList);
this.serverfiles.sort = this.sort; this.serverfiles.sort = this.sort;
this.fileStats = FilesComponent.getStats(fileList);
this.mds.setSpinnerOff(); this.mds.setSpinnerOff();
} }
); );
} }
} }
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;
}
// eslint-disable-next-line no-param-reassign
carry[file.type] += 1;
return carry;
}, stats);
}
download(element: GetFileResponseData): void { download(element: GetFileResponseData): void {
this.mds.setSpinnerOn(); this.mds.setSpinnerOn();
this.bs.downloadFile(element.type, element.filename) this.bs.downloadFile(element.type, element.filename)
......
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