mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-01 00:45:53 +00:00
Update status-chart.component.ts
This commit is contained in:
parent
9835c5b4cc
commit
acc41aebe1
@ -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];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user