From 6264a15b1d61c7ff9fc195695df876b4368fd331 Mon Sep 17 00:00:00 2001 From: Masu Baumgartner Date: Wed, 22 May 2024 16:57:37 +0200 Subject: [PATCH 1/8] Testing and developing new mooncore features with moonlight as a test env --- Moonlight/Core/UI/Views/Test.razor | 160 ++++++++++++++++++ Moonlight/Core/UI/Views/Testy.razor | 110 ++++++++++++ .../Forms/Admin/Servers/CreateServerForm.cs | 11 +- Moonlight/Moonlight.csproj | 7 +- 4 files changed, 282 insertions(+), 6 deletions(-) create mode 100644 Moonlight/Core/UI/Views/Test.razor create mode 100644 Moonlight/Core/UI/Views/Testy.razor diff --git a/Moonlight/Core/UI/Views/Test.razor b/Moonlight/Core/UI/Views/Test.razor new file mode 100644 index 00000000..b30dcaf3 --- /dev/null +++ b/Moonlight/Core/UI/Views/Test.razor @@ -0,0 +1,160 @@ +@page "/test" + +
+
+
+
+ + + + +
+
+
+
+
+ + + +
+ +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + @for (var i = 1; i <= 10; i++) + { + + + + + + + + + } + + +
+
+ +
+
IdEmailUsernameCreated at
+
+ +
+
@(i)admin@masuowo.xyz@(i)masuowo@(i)04/19/2024 12:48:35 +
+ Edit +
+
+
+
+
+ Showing 13 of 100 results +
+
+
+ Per page + +
+
+
+
    + +
  • 1
  • +
  • 2
  • +
  • 3
  • + +
+
+
+
+
+ +@* +
+ +
+ +
+ +
+ +
+ Please choose a username. +
+
*@ + + + +@code +{ + private async Task Do() + { + await Task.Delay(5000); + } +} diff --git a/Moonlight/Core/UI/Views/Testy.razor b/Moonlight/Core/UI/Views/Testy.razor new file mode 100644 index 00000000..5a24759a --- /dev/null +++ b/Moonlight/Core/UI/Views/Testy.razor @@ -0,0 +1,110 @@ +@page "/testy" + +
+
+ + + Back + + + +
+
+ +
+
+
+
+ + +
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+ +
+ + +
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+ +
+ + +
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+ +
+ +
+ + + +
+
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+
+
+
+ +
+
+
+ + Some Section +
+
+
+
+
+ + +
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+ +
+ + +
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+ +
+ +
+ + + +
+
+ dasdfuoiusefiousidfhzuigfzduzfgiudzfogzidufzgduifzguisdzugzduifhgjkdsgkdfh +
+
+
+
+
\ No newline at end of file diff --git a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs index ea411717..7b8fc41e 100644 --- a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs +++ b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs @@ -21,27 +21,28 @@ public class CreateServerForm [Range(1, int.MaxValue, ErrorMessage = "Enter a valid cpu value")] [Description("The cores the server will be able to use. 100 = 1 Core")] - [Section("Resources")] + [Section("Resources", Icon = "bxs-chip")] public int Cpu { get; set; } [Range(1, int.MaxValue, ErrorMessage = "Enter a valid memory value")] [Description("The amount of memory this server will be able to use")] [ByteSize(MinimumUnit = 1, Converter = 1, DefaultUnit = 2)] - [Section("Resources")] + [Section("Resources", Icon = "bxs-chip")] public int Memory { get; set; } [Range(1, int.MaxValue, ErrorMessage = "Enter a valid disk value")] [Description("The amount of disk space this server will be able to use")] [ByteSize(MinimumUnit = 1, Converter = 1, DefaultUnit = 2)] - [Section("Resources")] + [Section("Resources", Icon = "bxs-chip")] public int Disk { get; set; } [Description("Whether to use a virtual disk for storing server files. Dont use this if you want to overallocate as the virtual disks will fill out the space you allocate")] - [Section("Deployment")] + [Section("Deployment", Icon = "bx-cube")] + [RadioButtonBool("Virtual Disk", "Simple Volume", TrueIcon = "bxs-hdd", FalseIcon = "bxs-data")] public bool UseVirtualDisk { get; set; } [Required(ErrorMessage = "You need to specify a server node")] [Selector(SelectorProp = "Name", DisplayProp = "Name", UseDropdown = true)] - [Section("Deployment")] + [Section("Deployment", Icon = "bx-cube")] public ServerNode Node { get; set; } } \ No newline at end of file diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 94c9911c..5da271ff 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -92,10 +92,15 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + ..\..\..\Marcel-Baumgartner\MoonCore\MoonCore\MoonCoreUI\bin\Debug\net7.0\MoonCoreUI.dll + + From 61492bc669552b8bd480e0ca0d47a4b67b7ebc80 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Thu, 23 May 2024 08:18:10 +0200 Subject: [PATCH 2/8] Testing display name property --- .../Servers/Models/Forms/Admin/Servers/CreateServerForm.cs | 1 + Moonlight/Moonlight.csproj | 2 +- 2 files changed, 2 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 7b8fc41e..3a1b8af5 100644 --- a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs +++ b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs @@ -39,6 +39,7 @@ public class CreateServerForm [Description("Whether to use a virtual disk for storing server files. Dont use this if you want to overallocate as the virtual disks will fill out the space you allocate")] [Section("Deployment", Icon = "bx-cube")] [RadioButtonBool("Virtual Disk", "Simple Volume", TrueIcon = "bxs-hdd", FalseIcon = "bxs-data")] + [DisplayName("Storage")] public bool UseVirtualDisk { get; set; } [Required(ErrorMessage = "You need to specify a server node")] diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 5da271ff..62a44ee0 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -100,7 +100,7 @@ - ..\..\..\Marcel-Baumgartner\MoonCore\MoonCore\MoonCoreUI\bin\Debug\net7.0\MoonCoreUI.dll + ..\..\..\Masu-Baumgartner\MoonCore\MoonCore\MoonCoreUI\bin\Debug\net7.0\MoonCoreUI.dll From 83f453da3fe1f6f2e209aa0ceca3cb3e3bd157d0 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 26 May 2024 22:43:16 +0200 Subject: [PATCH 3/8] Switched to new loader --- Moonlight/Features/Servers/UI/Views/Admin/Index.razor | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor index 5c8de937..5cc0b67f 100644 --- a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor +++ b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor @@ -19,7 +19,7 @@ TCreateForm="CreateServerForm" TUpdateForm="CreateServerForm" Title="" - Load="Load" + Loader="Load" CustomAdd="CustomAdd" ValidateUpdate="ValidateUpdate" CustomDelete="CustomDelete"> @@ -51,14 +51,13 @@ @code { - private Server[] Load(Repository repository) + private IEnumerable Load(Repository repository) { return repository .Get() .Include(x => x.Owner) .Include(x => x.Image) - .Include(x => x.Node) - .ToArray(); + .Include(x => x.Node); } private async Task CustomAdd(Server form) => await ServerService.Create(form); From a580e4335bd744ce329250a5541a88d75f4a6833 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Tue, 28 May 2024 22:43:46 +0200 Subject: [PATCH 4/8] More testing of the new mooncore ui changes --- Moonlight/Core/UI/Views/Admin/Users/Index.razor | 4 ++-- .../Models/Forms/Admin/Servers/CreateServerForm.cs | 5 +++++ .../Features/Servers/UI/Views/Admin/Images/Index.razor | 8 ++++---- Moonlight/Features/Servers/UI/Views/Admin/Index.razor | 1 - Moonlight/Moonlight.csproj | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Moonlight/Core/UI/Views/Admin/Users/Index.razor b/Moonlight/Core/UI/Views/Admin/Users/Index.razor index da7a609d..0568ffed 100644 --- a/Moonlight/Core/UI/Views/Admin/Users/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Users/Index.razor @@ -29,11 +29,11 @@ - + - + @code diff --git a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs index 3a1b8af5..e8ee58b4 100644 --- a/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs +++ b/Moonlight/Features/Servers/Models/Forms/Admin/Servers/CreateServerForm.cs @@ -46,4 +46,9 @@ public class CreateServerForm [Selector(SelectorProp = "Name", DisplayProp = "Name", UseDropdown = true)] [Section("Deployment", Icon = "bx-cube")] public ServerNode Node { get; set; } + + [Description("The allocations the server should have")] + [MultiSelection("Port", "Port", Icon = "bx-network-chart")] + [Section("Deployment", Icon = "bx-cube")] + public List Allocations { get; set; } = new(); } \ No newline at end of file diff --git a/Moonlight/Features/Servers/UI/Views/Admin/Images/Index.razor b/Moonlight/Features/Servers/UI/Views/Admin/Images/Index.razor index 7b18549a..1d475184 100644 --- a/Moonlight/Features/Servers/UI/Views/Admin/Images/Index.razor +++ b/Moonlight/Features/Servers/UI/Views/Admin/Images/Index.razor @@ -34,11 +34,11 @@ ValidateAdd="ValidateAdd" CustomDelete="CustomDelete" @ref="Crud"> - + - + @@ -73,7 +73,7 @@ Download and import a image from our repository or create a new one. Need help? Check out our documentation - + Import egg @@ -84,7 +84,7 @@ Import - + @code diff --git a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor index 5cc0b67f..df8821b8 100644 --- a/Moonlight/Features/Servers/UI/Views/Admin/Index.razor +++ b/Moonlight/Features/Servers/UI/Views/Admin/Index.razor @@ -18,7 +18,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 0ff0ce1252616e5305563d8bf0e78327ba83a915 Mon Sep 17 00:00:00 2001 From: Masu Baumgartner Date: Wed, 29 May 2024 21:24:45 +0200 Subject: [PATCH 5/8] 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 From dfb633f6a769bb95d5704dc8b3f21a2f77fff009 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Thu, 30 May 2024 13:34:24 +0200 Subject: [PATCH 6/8] Updated mooncore usage to work with the newer version --- .../Core/Models/Forms/Users/UpdateUserForm.cs | 3 + .../Core/UI/Views/Admin/Users/Index.razor | 20 +++--- .../Core/UI/Views/Admin/Users/Sessions.razor | 26 ++++--- .../Servers/Services/ServerService.cs | 56 +++++++++++---- .../Servers/UI/UserViews/Network.razor | 2 +- .../Servers/UI/Views/Admin/Images/Index.razor | 68 +++++++++---------- .../Servers/UI/Views/Admin/Nodes/Index.razor | 8 +-- .../Servers/UI/Views/Servers/Networks.razor | 9 ++- 8 files changed, 110 insertions(+), 82 deletions(-) diff --git a/Moonlight/Core/Models/Forms/Users/UpdateUserForm.cs b/Moonlight/Core/Models/Forms/Users/UpdateUserForm.cs index 67da5d86..2db50fec 100644 --- a/Moonlight/Core/Models/Forms/Users/UpdateUserForm.cs +++ b/Moonlight/Core/Models/Forms/Users/UpdateUserForm.cs @@ -1,5 +1,6 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using MoonCoreUI.Attributes; namespace Moonlight.Core.Models.Forms.Users; @@ -16,5 +17,7 @@ public class UpdateUserForm public string Email { get; set; } [Description("This toggles the use of the two factor authentication")] + [RadioButtonBool("Enabled", "Disabled", TrueIcon = "bx-lock-alt", FalseIcon = "bx-lock-open-alt")] + [DisplayName("Two factor authentication")] public bool Totp { get; set; } = false; } \ No newline at end of file diff --git a/Moonlight/Core/UI/Views/Admin/Users/Index.razor b/Moonlight/Core/UI/Views/Admin/Users/Index.razor index 0568ffed..106923bd 100644 --- a/Moonlight/Core/UI/Views/Admin/Users/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Users/Index.razor @@ -17,30 +17,30 @@ + TCreateForm="CreateUserForm" + TUpdateForm="UpdateUserForm" + Loader="Load" + CustomAdd="Add" + ValidateUpdate="ValidateUpdate"> - + - + + Change password @code { - private User[] Load(Repository repository) + private IEnumerable Load(Repository repository) { - return repository.Get().ToArray(); + return repository.Get(); } private async Task ChangePassword(User user) diff --git a/Moonlight/Core/UI/Views/Admin/Users/Sessions.razor b/Moonlight/Core/UI/Views/Admin/Users/Sessions.razor index 641eef1c..9d626380 100644 --- a/Moonlight/Core/UI/Views/Admin/Users/Sessions.razor +++ b/Moonlight/Core/UI/Views/Admin/Users/Sessions.razor @@ -22,11 +22,11 @@
-
+