mirror of
https://github.com/Dvorinka/Dash.git
synced 2026-10-29 00:01:24 +00:00
fix: byte formatting + exactOptionalPropertyTypes
fmtBytes used 1<<40 — a 32-bit shift in JS evaluates to 1<<8=256, so every value >=256 bytes rendered as TB. Also drop undefined-valued props that exactOptionalPropertyTypes rejects in incident/status-page bodies. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
c84a4be876
commit
97b8f5e87f
4 files changed
+16
-6
No files matched your search
@@ -11,10 +11,14 @@ import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const TB = 2 ** 40;
|
||||
const GB = 2 ** 30;
|
||||
const MB = 2 ** 20;
|
||||
|
||||
export function fmtBytes(b: number) {
|
||||
if (b >= 1 << 40) return `${(b / (1 << 40)).toFixed(1)} TB`;
|
||||
if (b >= 1 << 30) return `${(b / (1 << 30)).toFixed(1)} GB`;
|
||||
return `${(b / (1 << 20)).toFixed(0)} MB`;
|
||||
if (b >= TB) return `${(b / TB).toFixed(1)} TB`;
|
||||
if (b >= GB) return `${(b / GB).toFixed(1)} GB`;
|
||||
return `${(b / MB).toFixed(0)} MB`;
|
||||
}
|
||||
|
||||
export function fmtUptime(s: number) {
|
||||
|
||||
Reference in new issue
Block a user