diff --git a/Moonlight/App/Helpers/Formatter.cs b/Moonlight/App/Helpers/Formatter.cs index 78fbfc55..d23d3b5e 100644 --- a/Moonlight/App/Helpers/Formatter.cs +++ b/Moonlight/App/Helpers/Formatter.cs @@ -8,7 +8,7 @@ public static class Formatter { TimeSpan t = TimeSpan.FromMilliseconds(uptime); - return $"{t.Hours}h {t.Minutes}m {t.Seconds}s"; + return $"{t.Days}d {t.Hours}h {t.Minutes}m {t.Seconds}s"; } private static double Round(this double d, int decimals) diff --git a/Moonlight/Shared/Views/Servers/Index.razor b/Moonlight/Shared/Views/Servers/Index.razor index b0131db7..dcc2405d 100644 --- a/Moonlight/Shared/Views/Servers/Index.razor +++ b/Moonlight/Shared/Views/Servers/Index.razor @@ -1,5 +1,4 @@ @page "/servers" -@using Moonlight.App.Services.Sessions @using Moonlight.App.Repositories.Servers @using Microsoft.EntityFrameworkCore @using Moonlight.App.Database.Entities @@ -9,9 +8,97 @@ @inject IServiceScopeFactory ServiceScopeFactory - @if (AllServers.Any()) +@if (AllServers.Any()) +{ + if (UseSortedServerView) { - @foreach (var server in AllServers) + var groupedServers = AllServers + .OrderBy(x => x.Name) + .GroupBy(x => x.Image.Name); + + foreach (var groupedServer in groupedServers) + { +
@(groupedServer.Key)
+
+ @foreach (var server in groupedServer) + { +
+ +
+
+
+
+ +
+
+ + @(server.Name) + + + @(Math.Round(server.Memory / 1024D, 2)) GB / @(Math.Round(server.Disk / 1024D, 2)) GB / @(server.Node.Name) - @(server.Image.Name) + +
+
+
+
+ @(server.Node.Fqdn):@(server.MainAllocation.Port) +
+
+ @if (StatusCache.ContainsKey(server)) + { + var status = StatusCache[server]; + + switch (status) + { + case "offline": + + Offline + + break; + case "stopping": + + Stopping + + break; + case "starting": + + Starting + + break; + case "running": + + Running + + break; + case "failed": + + Failed + + break; + default: + + Offline + + break; + } + } + else + { + + Loading + + } +
+
+ +
+ } +
+ } + } + else + { + foreach (var server in AllServers) {
@@ -42,28 +129,42 @@ switch (status) { case "offline": - Offline + + Offline + break; case "stopping": - Stopping + + Stopping + break; case "starting": - Starting + + Starting + break; case "running": - Running + + Running + break; case "failed": - Failed + + Failed + break; default: - Offline + + Offline + break; } } else { - Loading + + Loading + }
@@ -71,29 +172,53 @@ } } - else - { -
-
-

- You have no servers -

- - We were not able to find any servers associated with your account - +} +else +{ +
+
+

+ You have no servers +

+ + We were not able to find any servers associated with your account + +
+
+} + +
+
+
+
+ Beta
- } +
+
+ +
+
+ + +
+
+
+
+
+
@code { [CascadingParameter] public User User { get; set; } - + private Server[] AllServers; private readonly Dictionary StatusCache = new(); + private bool UseSortedServerView = false; + private Task Load(LazyLoader arg) { AllServers = ServerRepository @@ -123,11 +248,11 @@ } }); } - + return Task.CompletedTask; } - private void AddStatus(App.Database.Entities.Server server, string status) + private void AddStatus(Server server, string status) { lock (StatusCache) {