diff --git a/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor b/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor index b524dbe..39e8671 100644 --- a/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor +++ b/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor @@ -1,3 +1,4 @@ +@using System.Text.Json @using MoonlightServers.Shared.Http.Responses.Admin.Nodes @implements IDisposable @@ -5,7 +6,7 @@ @inject HttpApiClient HttpApiClient -
+
@if (IsOffline) { x), 2) + "%"; var memoryUsage = $"{Formatter.FormatSize((long)(Status.MemoryTotal - Status.MemoryAvailable))} / {Formatter.FormatSize((long)Status.MemoryTotal)}"; var uptime = Formatter.FormatUptime(Status.Uptime); - var diskUsage = $"{Formatter.FormatSize((long)Status.DiskFree)} / {Formatter.FormatSize((long)Status.DiskTotal)}"; + var diskUsage = $"{Formatter.FormatSize((long)(Status.DiskTotal - Status.DiskFree))} / {Formatter.FormatSize((long)Status.DiskTotal)}";
@@ -31,6 +32,28 @@
+ +
+

+ CPU Cores +

+

+ View the nodes cpu usage in detail +

+
+ +
+ @{ + int index = 1; + } + + @foreach (var usage in Status.CpuUsage) + { + + + index++; + } +
}
@@ -67,6 +90,8 @@ try { Status = await HttpApiClient.GetJson($"admin/servers/nodes/{NodeId}/status"); + + Console.WriteLine(JsonSerializer.Serialize(Status)); } catch (Exception) { diff --git a/MoonlightServers.Client/UI/Components/Partials/TestC.razor b/MoonlightServers.Client/UI/Components/Partials/TestC.razor new file mode 100644 index 0000000..63aa802 --- /dev/null +++ b/MoonlightServers.Client/UI/Components/Partials/TestC.razor @@ -0,0 +1,63 @@ +
+
+ @if (!string.IsNullOrEmpty(Icon)) + { +
+
+ +
+
+ } +

@(Title)

+
+ +
+
+ @{ + var percent = CalculatePercent(); + var percentRounded = Math.Round(percent); + + string color; + + if (UsePercentColor) + { + if (percentRounded >= 60 && percentRounded < 80) + color = "bg-amber-400"; + else if (percentRounded >= 80) + color = "bg-red-400"; + else + color = "bg-blue-500"; + } + else + color = ProgressColor; + } + +
+ @if (ShowPercent) + { + @(percentRounded)% + } +
+
+
+
+ +@code +{ + [Parameter] public string Icon { get; set; } = ""; + [Parameter] public string IconColor { get; set; } = "bg-indigo-600"; + [Parameter] public string Title { get; set; } = ""; + [Parameter] public double CurrentValue { get; set; } = 0; + [Parameter] public double MaxValue { get; set; } = 0; + [Parameter] public bool ShowPercent { get; set; } = false; + [Parameter] public bool UsePercentColor { get; set; } = true; + [Parameter] public string ProgressColor { get; set; } = ""; + + private double CalculatePercent() + { + if (MaxValue <= 0 || CurrentValue <= 0) + return 0; + + return CurrentValue * MaxValue / 100; + } +} \ No newline at end of file