fix: byte units (#4419)
This commit is contained in:
parent
e0e0689846
commit
597821b3bb
4 changed files with 19 additions and 19 deletions
|
@ -17,7 +17,7 @@ export default () => {
|
|||
const previous = useRef<Record<'tx' | 'rx', number>>({ tx: -1, rx: -1 });
|
||||
|
||||
const cpu = useChartTickLabel('CPU', limits.cpu, '%', 2);
|
||||
const memory = useChartTickLabel('Memory', limits.memory, 'MB');
|
||||
const memory = useChartTickLabel('Memory', limits.memory, 'MiB');
|
||||
const network = useChart('Network', {
|
||||
sets: 2,
|
||||
options: {
|
||||
|
|
|
@ -21,22 +21,22 @@ describe('@/lib/formatters.ts', function () {
|
|||
[100.998, '101 Bytes'],
|
||||
[512, '512 Bytes'],
|
||||
[1000, '1000 Bytes'],
|
||||
[1024, '1 KB'],
|
||||
[5068, '4.95 KB'],
|
||||
[10_000, '9.77 KB'],
|
||||
[10_240, '10 KB'],
|
||||
[11_864, '11.59 KB'],
|
||||
[1_000_000, '976.56 KB'],
|
||||
[1_024_000, '1000 KB'],
|
||||
[1_025_000, '1000.98 KB'],
|
||||
[1_048_576, '1 MB'],
|
||||
[1_356_000, '1.29 MB'],
|
||||
[1_000_000_000, '953.67 MB'],
|
||||
[1_070_000_100, '1020.43 MB'],
|
||||
[1_073_741_824, '1 GB'],
|
||||
[1_678_342_000, '1.56 GB'],
|
||||
[1_000_000_000_000, '931.32 GB'],
|
||||
[1_099_511_627_776, '1 TB'],
|
||||
[1024, '1 KiB'],
|
||||
[5068, '4.95 KiB'],
|
||||
[10_000, '9.77 KiB'],
|
||||
[10_240, '10 KiB'],
|
||||
[11_864, '11.59 KiB'],
|
||||
[1_000_000, '976.56 KiB'],
|
||||
[1_024_000, '1000 KiB'],
|
||||
[1_025_000, '1000.98 KiB'],
|
||||
[1_048_576, '1 MiB'],
|
||||
[1_356_000, '1.29 MiB'],
|
||||
[1_000_000_000, '953.67 MiB'],
|
||||
[1_070_000_100, '1020.43 MiB'],
|
||||
[1_073_741_824, '1 GiB'],
|
||||
[1_678_342_000, '1.56 GiB'],
|
||||
[1_000_000_000_000, '931.32 GiB'],
|
||||
[1_099_511_627_776, '1 TiB'],
|
||||
])('should format %d bytes as "%s"', function (input, output) {
|
||||
expect(bytesToString(input)).toBe(output);
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ function bytesToString(bytes: number, decimals = 2): string {
|
|||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const value = Number((bytes / Math.pow(k, i)).toFixed(decimals));
|
||||
|
||||
return `${value} ${['Bytes', 'KB', 'MB', 'GB', 'TB'][i]}`;
|
||||
return `${value} ${['Bytes', 'KiB', 'MiB', 'GiB', 'TiB'][i]}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
@if($server->disk === 0)
|
||||
<code>Unlimited</code>
|
||||
@else
|
||||
<code>{{ $server->disk }}MB</code>
|
||||
<code>{{ $server->disk }}MiB</code>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue