Added allocation selection for create form. Improved Use Virtual Disk toggle
This commit is contained in:
@@ -143,4 +143,24 @@ public class NodeAllocationsController : Controller
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[HttpGet("{nodeId:int}/allocations/free")]
|
||||
[RequirePermission("admin.servers.nodes.get")]
|
||||
public async Task<IPagedData<NodeAllocationDetailResponse>> GetFree([FromRoute] int nodeId, [FromQuery] int page, [FromQuery] int pageSize)
|
||||
{
|
||||
var node = NodeRepository
|
||||
.Get()
|
||||
.FirstOrDefault(x => x.Id == nodeId);
|
||||
|
||||
if (node == null)
|
||||
throw new HttpApiException("A node with this id could not be found", 404);
|
||||
|
||||
Node = node;
|
||||
|
||||
CrudHelper.QueryModifier = variables => variables
|
||||
.Where(x => x.Node.Id == node.Id)
|
||||
.Where(x => x.Server == null);
|
||||
|
||||
return await CrudHelper.Get(page, pageSize);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,28 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
||||
@using MoonlightServers.Frontend.UI.Components.Forms
|
||||
@using MoonCore.Blazor.Tailwind.Inputs
|
||||
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-white">Use Virtual Disk</label>
|
||||
<label class="block text-sm font-medium leading-6 text-white">Storage</label>
|
||||
<div class="mt-2">
|
||||
<Switch @bind-Value="Request.UseVirtualDisk"/>
|
||||
<InputCustomSelect TValue="bool" @bind-Value="Request.UseVirtualDisk">
|
||||
<CustomSelectOption Value="false">
|
||||
<Template>
|
||||
<span>
|
||||
<i class="icon-database me-1 align-middle"></i>
|
||||
<span class="align-middle">Docker Volume</span>
|
||||
</span>
|
||||
</Template>
|
||||
</CustomSelectOption>
|
||||
<CustomSelectOption Value="true">
|
||||
<Template>
|
||||
<span>
|
||||
<i class="icon-hard-drive me-1 align-middle"></i>
|
||||
<span class="align-middle">Virtual Disk</span>
|
||||
</span>
|
||||
</Template>
|
||||
</CustomSelectOption>
|
||||
</InputCustomSelect>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
||||
@using MoonCore.Blazor.Tailwind.Inputs
|
||||
@using MoonCore.Helpers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-white">Allocations</label>
|
||||
<div class="mt-2">
|
||||
<InputMultiSelect TItem="NodeAllocationDetailResponse"
|
||||
TProperty="int"
|
||||
@bind-Value="Request.AllocationIds"
|
||||
Loader="Loader"
|
||||
AllowSearch="true"
|
||||
DisplayProperty="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
ValueProperty="@(x => x.Id)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter] public CreateServerRequest Request { get; set; }
|
||||
|
||||
private async Task<NodeAllocationDetailResponse[]> Loader()
|
||||
{
|
||||
// Handle unselected node
|
||||
if (Request.NodeId <= 0)
|
||||
return [];
|
||||
|
||||
var data = await ApiClient.GetJson<PagedData<NodeAllocationDetailResponse>>(
|
||||
$"api/admin/servers/nodes/{Request.NodeId}/allocations/free?page=0&pageSize=50"
|
||||
);
|
||||
|
||||
return data.Items;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,9 @@
|
||||
<Tab Name="General">
|
||||
<GeneralServerCreate Request="Request" />
|
||||
</Tab>
|
||||
<Tab Name="Allocations">
|
||||
<AllocationsServerCrete Request="Request" />
|
||||
</Tab>
|
||||
<Tab Name="Advanced">
|
||||
<AdvancedServerCreate Request="Request" />
|
||||
</Tab>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations;
|
||||
|
||||
namespace MoonlightServers.Shared.Http.Responses.Admin.Nodes;
|
||||
|
||||
public class NodeDetailResponse
|
||||
|
||||
Reference in New Issue
Block a user