diff --git a/Moonlight/App/Helpers/ByteSizeValue.cs b/Moonlight/App/Helpers/ByteSizeValue.cs new file mode 100644 index 00000000..d761b0d7 --- /dev/null +++ b/Moonlight/App/Helpers/ByteSizeValue.cs @@ -0,0 +1,56 @@ +namespace Moonlight.App.Helpers; + +public class ByteSizeValue +{ + public long Bytes { get; set; } + + public long KiloBytes + { + get => Bytes / 1024; + set => Bytes = value * 1024; + } + + public long MegaBytes + { + get => KiloBytes / 1024; + set => KiloBytes = value * 1024; + } + + public long GigaBytes + { + get => MegaBytes / 1024; + set => MegaBytes = value * 1024; + } + + public static ByteSizeValue FromBytes(long bytes) + { + return new() + { + Bytes = bytes + }; + } + + public static ByteSizeValue FromKiloBytes(long kiloBytes) + { + return new() + { + KiloBytes = kiloBytes + }; + } + + public static ByteSizeValue FromMegaBytes(long megaBytes) + { + return new() + { + MegaBytes = megaBytes + }; + } + + public static ByteSizeValue FromGigaBytes(long gigaBytes) + { + return new() + { + GigaBytes = gigaBytes + }; + } +} \ No newline at end of file diff --git a/Moonlight/Shared/Views/Admin/Nodes/View.razor b/Moonlight/Shared/Views/Admin/Nodes/View.razor index 6b27e3f2..fa1c1c3d 100644 --- a/Moonlight/Shared/Views/Admin/Nodes/View.razor +++ b/Moonlight/Shared/Views/Admin/Nodes/View.razor @@ -88,7 +88,7 @@ else else { - @(Formatter.FormatSize(MemoryMetrics.Used)) of @(Formatter.FormatSize(MemoryMetrics.Total)) memory used + @(Formatter.FormatSize(ByteSizeValue.FromKiloBytes(MemoryMetrics.Used).Bytes)) of @(Formatter.FormatSize(ByteSizeValue.FromKiloBytes(MemoryMetrics.Total).Bytes)) memory used }