Skip to content

Commit 597821b

Browse files
authored
fix: byte units (pterodactyl#4419)
1 parent e0e0689 commit 597821b

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

resources/scripts/components/server/console/StatGraphs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default () => {
1717
const previous = useRef<Record<'tx' | 'rx', number>>({ tx: -1, rx: -1 });
1818

1919
const cpu = useChartTickLabel('CPU', limits.cpu, '%', 2);
20-
const memory = useChartTickLabel('Memory', limits.memory, 'MB');
20+
const memory = useChartTickLabel('Memory', limits.memory, 'MiB');
2121
const network = useChart('Network', {
2222
sets: 2,
2323
options: {

resources/scripts/lib/formatters.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ describe('@/lib/formatters.ts', function () {
2121
[100.998, '101 Bytes'],
2222
[512, '512 Bytes'],
2323
[1000, '1000 Bytes'],
24-
[1024, '1 KB'],
25-
[5068, '4.95 KB'],
26-
[10_000, '9.77 KB'],
27-
[10_240, '10 KB'],
28-
[11_864, '11.59 KB'],
29-
[1_000_000, '976.56 KB'],
30-
[1_024_000, '1000 KB'],
31-
[1_025_000, '1000.98 KB'],
32-
[1_048_576, '1 MB'],
33-
[1_356_000, '1.29 MB'],
34-
[1_000_000_000, '953.67 MB'],
35-
[1_070_000_100, '1020.43 MB'],
36-
[1_073_741_824, '1 GB'],
37-
[1_678_342_000, '1.56 GB'],
38-
[1_000_000_000_000, '931.32 GB'],
39-
[1_099_511_627_776, '1 TB'],
24+
[1024, '1 KiB'],
25+
[5068, '4.95 KiB'],
26+
[10_000, '9.77 KiB'],
27+
[10_240, '10 KiB'],
28+
[11_864, '11.59 KiB'],
29+
[1_000_000, '976.56 KiB'],
30+
[1_024_000, '1000 KiB'],
31+
[1_025_000, '1000.98 KiB'],
32+
[1_048_576, '1 MiB'],
33+
[1_356_000, '1.29 MiB'],
34+
[1_000_000_000, '953.67 MiB'],
35+
[1_070_000_100, '1020.43 MiB'],
36+
[1_073_741_824, '1 GiB'],
37+
[1_678_342_000, '1.56 GiB'],
38+
[1_000_000_000_000, '931.32 GiB'],
39+
[1_099_511_627_776, '1 TiB'],
4040
])('should format %d bytes as "%s"', function (input, output) {
4141
expect(bytesToString(input)).toBe(output);
4242
});

resources/scripts/lib/formatters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function bytesToString(bytes: number, decimals = 2): string {
2020
const i = Math.floor(Math.log(bytes) / Math.log(k));
2121
const value = Number((bytes / Math.pow(k, i)).toFixed(decimals));
2222

23-
return `${value} ${['Bytes', 'KB', 'MB', 'GB', 'TB'][i]}`;
23+
return `${value} ${['Bytes', 'KiB', 'MiB', 'GiB', 'TiB'][i]}`;
2424
}
2525

2626
/**

resources/views/admin/servers/view/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
@if($server->disk === 0)
102102
<code>Unlimited</code>
103103
@else
104-
<code>{{ $server->disk }}MB</code>
104+
<code>{{ $server->disk }}MiB</code>
105105
@endif
106106
</td>
107107
</tr>

0 commit comments

Comments
 (0)