From 0a244ac4749c3f0da3b6e96da45a6a390864f1a1 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 16 Apr 2023 16:01:19 +0200 Subject: [PATCH] Fixed my stupid mistakes --- Moonlight/App/Services/ServerService.cs | 4 +- Moonlight/Shared/Views/Admin/Nodes/Edit.razor | 42 +++++++++++++++++++ Moonlight/Shared/Views/Servers/Create.razor | 6 +-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Moonlight/App/Services/ServerService.cs b/Moonlight/App/Services/ServerService.cs index 1ccf204d..ae724ac9 100644 --- a/Moonlight/App/Services/ServerService.cs +++ b/Moonlight/App/Services/ServerService.cs @@ -259,7 +259,7 @@ public class ServerService } public async Task Create(string name, int cpu, long memory, long disk, User u, Image i, Node? n = null, - Action? modifyDetails = null, int allocations = 1) + Action? modifyDetails = null) { var user = UserRepository .Get() @@ -271,6 +271,8 @@ public class ServerService .Include(x => x.DockerImages) .First(x => x.Id == i.Id); + var allocations = image.Allocations; + Node node = n ?? NodeRepository.Get().First(); NodeAllocation[] freeAllocations; diff --git a/Moonlight/Shared/Views/Admin/Nodes/Edit.razor b/Moonlight/Shared/Views/Admin/Nodes/Edit.razor index b9583492..21b7a9cc 100644 --- a/Moonlight/Shared/Views/Admin/Nodes/Edit.razor +++ b/Moonlight/Shared/Views/Admin/Nodes/Edit.razor @@ -109,6 +109,25 @@ OnClick="CreateAllocation"> +
+ + +
+
+ + +
+
+ + +
@@ -142,6 +161,9 @@ private int Port = 2000; + private int StartPort = 2000; + private int EndPort = 3000; + private Task Load(LazyLoader arg) { Node = NodeRepository @@ -183,4 +205,24 @@ await LazyLoader.Reload(); } + + private async Task CreateAllocationRange() + { + for (int i = StartPort; i < EndPort; i++) + { + var nodeAllocation = new NodeAllocation() + { + Port = i + }; + + Node!.Allocations.Add(nodeAllocation); + } + + NodeRepository.Update(Node); + + StartPort = 2000; + EndPort = 3000; + + await LazyLoader.Reload(); + } } \ No newline at end of file diff --git a/Moonlight/Shared/Views/Servers/Create.razor b/Moonlight/Shared/Views/Servers/Create.razor index b6c6c318..30f687d6 100644 --- a/Moonlight/Shared/Views/Servers/Create.razor +++ b/Moonlight/Shared/Views/Servers/Create.razor @@ -209,10 +209,8 @@ disk, User, Model.Image, - DeployNode, - null, - Model.Image.Allocations - ); + DeployNode + ); NavigationManager.NavigateTo($"/server/{server.Uuid}"); }