From 0ff0ce1252616e5305563d8bf0e78327ba83a915 Mon Sep 17 00:00:00 2001 From: Masu Baumgartner Date: Wed, 29 May 2024 21:24:45 +0200 Subject: [PATCH] Testing custom loaders --- .../Models/Forms/Admin/Servers/CreateServerForm.cs | 1 + .../Features/Servers/UI/Views/Admin/Index.razor | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs index e8ee58b4..0ebc5952 100644 --- a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs +++ b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs @@ -50,5 +50,6 @@ public class CreateServerForm [Description("The allocations the server should have")] [MultiSelection("Port", "Port", Icon = "bx-network-chart")] [Section("Deployment", Icon = "bx-cube")] + [CustomItemLoader("FreeAllocations")] public List Allocations { get; set; } = new(); } \ No newline at end of file diff --git a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor index df8821b8..f835af0b 100644 --- a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor +++ b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor @@ -41,6 +41,9 @@ + + + Create a new server in order to manage it using this page. Need help? Check out our documentation @@ -56,9 +59,17 @@ .Get() .Include(x => x.Owner) .Include(x => x.Image) + .Include(x => x.Allocations) .Include(x => x.Node); } + private IEnumerable LoadFreeAllocations(Repository repository) + { + return repository + .Get() + .FromSqlRaw("SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL"); + } + private async Task CustomAdd(Server form) => await ServerService.Create(form); private async Task CustomDelete(Server s) => await ServerService.Delete(s); @@ -71,7 +82,7 @@ if (oldServer.UseVirtualDisk != server.UseVirtualDisk) throw new DisplayException("Unable to switch from/to virtual disks. This is not supported at the moment"); - + return Task.CompletedTask; } } \ No newline at end of file