Update status-chart.component.ts

This commit is contained in:
piotrpekala7 2020-01-20 16:54:57 +01:00
parent 9835c5b4cc
commit acc41aebe1

View File

@ -12,5 +12,19 @@ export class StatusChartComponent implements OnInit {
constructor() {}
ngOnInit() {}
ngOnInit() {
// console.log('Memory total ', this.formatBytes(this.computeStatistics.statistics.memory_total));
}
formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
}