Files
Servers/MoonlightServers.Frontend/UI/Components/Nodes/Modals/UpdateAllocationModal.razor
ChiaraBm 680827e0ea Added node allocations ui and crud controller
Multi actions are not done though
2024-12-13 22:33:29 +01:00

50 lines
1.6 KiB
Plaintext

@using MoonCore.Blazor.Tailwind.Modals.Components
@using MoonCore.Blazor.Tailwind.Components
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@inherits BaseModal
<h1 class="mb-5 font-semibold text-xl">Update allocation</h1>
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
<div class="grid grid-cols-1 gap-2">
<div class="col-span-1">
<label class="block text-sm font-medium leading-6 text-white">IP Address</label>
<input @bind="Form.IpAddress" type="text" class="form-input w-full"/>
</div>
<div class="col-span-1">
<label class="block text-sm font-medium leading-6 text-white">Port</label>
<input @bind="Form.Port" type="text" class="form-input w-full"/>
</div>
</div>
</HandleForm>
<div class="mt-5 flex space-x-2">
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Update</WButton>
</div>
@code
{
[Parameter] public Func<UpdateNodeAllocationRequest, Task> OnSubmit { get; set; }
[Parameter] public NodeAllocationDetailResponse Allocation { get; set; }
private UpdateNodeAllocationRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
Form = Mapper.Map<UpdateNodeAllocationRequest>(Allocation);
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await Hide();
}
private Task Submit() => HandleForm.Submit();
}