44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
|
@using MoonCore.Helpers
|
|
@using MoonCore.Models
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
|
|
@using MoonCore.Blazor.FlyonUi.Forms
|
|
@using MoonlightServers.Frontend.UI.Views.Admin.All
|
|
|
|
@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-base-content">Allocations</label>
|
|
<div class="mt-2">
|
|
<InputMultipleItem TItem="NodeAllocationResponse"
|
|
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
|
|
SearchField="@(x => $"{x.IpAddress}:{x.Port}")"
|
|
Value="Parent.Allocations"
|
|
ItemSource="ItemSourceAsync">
|
|
</InputMultipleItem>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public CreateServerRequest Request { get; set; }
|
|
[Parameter] public Create Parent { get; set; }
|
|
|
|
private async Task<NodeAllocationResponse[]> ItemSourceAsync()
|
|
{
|
|
// Handle unselected node
|
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
|
if (Parent.Node == null)
|
|
return [];
|
|
|
|
var items = await CountedData<NodeAllocationResponse>.LoadAllAsync(async (startIndex, count) =>
|
|
await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
|
$"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
|
|
)
|
|
);
|
|
|
|
return items;
|
|
}
|
|
} |