From 7659403dc88af3075cddd83edd85ac21f0cb250a Mon Sep 17 00:00:00 2001 From: Masu Baumgartner <=> Date: Fri, 13 Sep 2024 14:59:49 +0000 Subject: [PATCH] Changed node stats ui --- .../UI/Components/Partials/NodeOverview.razor | 21 +++++-- .../UI/Components/Partials/TestC.razor | 63 ------------------- 2 files changed, 16 insertions(+), 68 deletions(-) delete mode 100644 MoonlightServers.Client/UI/Components/Partials/TestC.razor diff --git a/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor b/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor index 39e8671..1369329 100644 --- a/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor +++ b/MoonlightServers.Client/UI/Components/Partials/NodeOverview.razor @@ -17,6 +17,17 @@ } else { + @* +
+

+ Node overview +

+

+ See all important details of this node at one quick look +

+
+*@ + var cpuUsage = Math.Round(Status.CpuUsage.Average(x => x), 2) + "%"; var memoryUsage = $"{Formatter.FormatSize((long)(Status.MemoryTotal - Status.MemoryAvailable))} / {Formatter.FormatSize((long)Status.MemoryTotal)}"; var uptime = Formatter.FormatUptime(Status.Uptime); @@ -32,7 +43,7 @@ - +

CPU Cores @@ -41,15 +52,15 @@ View the nodes cpu usage in detail

- +
@{ int index = 1; } - + @foreach (var usage in Status.CpuUsage) { - + index++; } @@ -90,7 +101,7 @@ 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 deleted file mode 100644 index 63aa802..0000000 --- a/MoonlightServers.Client/UI/Components/Partials/TestC.razor +++ /dev/null @@ -1,63 +0,0 @@ -
-
- @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