web/storagenode: memory conversions extended (#3188)
This commit is contained in:
parent
a11619e7f3
commit
4a86906e11
@ -4,7 +4,7 @@
|
||||
<template>
|
||||
<div class="remaining-space-container">
|
||||
<p class="remaining-space-container__title">{{label}}</p>
|
||||
<p class="remaining-space-container__amount"><b>{{remaining}}GB</b></p>
|
||||
<p class="remaining-space-container__amount"><b>{{remaining}}</b></p>
|
||||
<div class="remaining-space-container__bar">
|
||||
<VInfo :text="infoMessage">
|
||||
<VBar
|
||||
@ -22,6 +22,7 @@ import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
|
||||
import VBar from '@/app/components/VBar.vue';
|
||||
import VInfo from '@/app/components/VInfo.vue';
|
||||
import { formatBytes } from '@/app/utils/converter';
|
||||
|
||||
@Component ({
|
||||
components: {
|
||||
@ -46,7 +47,7 @@ export default class BarInfo extends Vue {
|
||||
}
|
||||
|
||||
public get remaining(): string {
|
||||
return this.amount.toFixed(2);
|
||||
return formatBytes(this.amount);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
import { GB, KB, MB } from '@/app/utils/converter';
|
||||
import { GB, KB, MB, PB, TB } from '@/app/utils/converter';
|
||||
import { BandwidthUsed, Stamp } from '@/storagenode/satellite';
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@ export class ChartUtils {
|
||||
public static normalizeChartData(data: number[]): number[] {
|
||||
const maxBytes = Math.ceil(Math.max(...data));
|
||||
|
||||
let divider: number = GB;
|
||||
let divider: number = PB;
|
||||
switch (true) {
|
||||
case maxBytes < MB:
|
||||
divider = KB;
|
||||
@ -24,6 +24,12 @@ export class ChartUtils {
|
||||
case maxBytes < GB:
|
||||
divider = MB;
|
||||
break;
|
||||
case maxBytes < TB:
|
||||
divider = GB;
|
||||
break;
|
||||
case maxBytes < PB:
|
||||
divider = TB;
|
||||
break;
|
||||
}
|
||||
|
||||
return data.map(elem => elem / divider);
|
||||
|
@ -4,6 +4,8 @@
|
||||
export const KB = 1e3;
|
||||
export const MB = 1e6;
|
||||
export const GB = 1e9;
|
||||
export const TB = 1e12;
|
||||
export const PB = 1e15;
|
||||
|
||||
/**
|
||||
* Used to format amount from bytes to more compact unit
|
||||
@ -22,7 +24,11 @@ export function formatBytes(bytes): string {
|
||||
return `${(bytes / KB).toFixed(decimals)}KB`;
|
||||
case _bytes < GB:
|
||||
return `${(bytes / MB).toFixed(decimals)}MB`;
|
||||
default:
|
||||
case _bytes < TB:
|
||||
return `${(bytes / GB).toFixed(decimals)}GB`;
|
||||
case _bytes < PB:
|
||||
return `${(bytes / TB).toFixed(decimals)}TB`;
|
||||
default:
|
||||
return `${(bytes / PB).toFixed(decimals)}PB`;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user