From e4c21c74a51ce3ddb6b5b38f8c5af7a8e7ddb61f Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 9 Jul 2023 19:46:18 +0200 Subject: [PATCH 1/2] Added custom scroll bar --- Moonlight/wwwroot/assets/css/blazor.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Moonlight/wwwroot/assets/css/blazor.css b/Moonlight/wwwroot/assets/css/blazor.css index cbe7e5a..0ce3863 100644 --- a/Moonlight/wwwroot/assets/css/blazor.css +++ b/Moonlight/wwwroot/assets/css/blazor.css @@ -41,6 +41,7 @@ .components-reconnect-rejected > .rejected { display: block; } + .components-reconnect-hide > div { display: none; } @@ -55,4 +56,17 @@ .components-reconnect-rejected { display: block; +} + +::-webkit-scrollbar { + width: 12px; + background: var(--kt-card-bg); +} + +::-webkit-scrollbar-thumb { + background: #6964E4; +} + +::-webkit-scrollbar-thumb:hover { + background: #6964E4; } \ No newline at end of file From 151bc82998b55d1d167c8e83cb1ab898fcab912e Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 9 Jul 2023 19:46:32 +0200 Subject: [PATCH 2/2] Added better server image seletor --- Moonlight/Shared/Views/Servers/Create.razor | 83 +++++++++++++++------ 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/Moonlight/Shared/Views/Servers/Create.razor b/Moonlight/Shared/Views/Servers/Create.razor index 30f687d..853fcd4 100644 --- a/Moonlight/Shared/Views/Servers/Create.razor +++ b/Moonlight/Shared/Views/Servers/Create.razor @@ -48,7 +48,9 @@
- +
@(DeployNode.Name)
@if (Model.Image != null) @@ -56,12 +58,16 @@ var limit = Images[Model.Image];
- +
@(Model.Image.Name)
- +
@{ var cpu = limit.ReadValue("cpu"); @@ -76,12 +82,16 @@
- +
@(limit.ReadValue("memory")) MB
- +
@(limit.ReadValue("disk")) MB
} @@ -108,15 +118,6 @@
@if (Images.Any()) { - - - - @@ -125,13 +126,45 @@ {
- You reached the maximum amount of servers for every image of your subscription: @(Subscription == null ? SmartTranslateService.Translate("Default") : Subscription.Name) + We could not find any image in your subscription you have access to: @(Subscription == null ? SmartTranslateService.Translate("Default") : Subscription.Name)
}
+ +
+ @foreach (var keyValuePair in Images) + { + bool selected = Model.Image != null && Model.Image.Id == keyValuePair.Key.Id; + +
+ @if (ServerCounts[keyValuePair.Key] > keyValuePair.Value.Amount) + { +
+
+
@(keyValuePair.Key.Name)
+

+ @(keyValuePair.Key.Description) +

+
+
+ } + else + { + +
+
@(keyValuePair.Key.Name)
+

+ @(keyValuePair.Key.Description) +

+
+
+ } +
+ } +
} @@ -141,11 +174,12 @@ { [CascadingParameter] public User User { get; set; } - + private Node? DeployNode; private Subscription? Subscription; private Dictionary Images = new(); + private Dictionary ServerCounts = new(); private ServerOrderDataModel Model = new(); @@ -176,9 +210,9 @@ .Include(x => x.Image) .Where(x => x.Owner.Id == User.Id) .Count(x => x.Image.Id == image.Id); - - if(serversCount < limit.Amount) - Images.Add(image, limit); + + Images.Add(image, limit); + ServerCounts.Add(image, serversCount); } } } @@ -198,7 +232,7 @@ if (serversCount < limit.Amount) { - if(int.TryParse(limit.ReadValue("cpu"), out int cpu) && + if (int.TryParse(limit.ReadValue("cpu"), out int cpu) && int.TryParse(limit.ReadValue("memory"), out int memory) && int.TryParse(limit.ReadValue("disk"), out int disk)) { @@ -211,7 +245,7 @@ Model.Image, DeployNode ); - + NavigationManager.NavigateTo($"/server/{server.Uuid}"); } else @@ -221,4 +255,11 @@ } } } + + private async Task SelectImage(Image image) + { + Model.Image = image; + + await InvokeAsync(StateHasChanged); + } } \ No newline at end of file