85 lines
2.6 KiB
Plaintext
85 lines
2.6 KiB
Plaintext
@page "/admin/servers/nodes/update/{Id:int}"
|
|
|
|
@using MoonCore.Blazor.Tailwind.Components
|
|
@using MoonCore.Blazor.Tailwind.Forms
|
|
@using MoonCore.Blazor.Tailwind.Toasts
|
|
@using MoonCore.Helpers
|
|
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
|
@using MoonlightServers.Frontend.UI.Components.Nodes.UpdateNodePartials
|
|
|
|
@inject HttpApiClient ApiClient
|
|
@inject NavigationManager Navigation
|
|
@inject ToastService ToastService
|
|
|
|
<LazyLoader Load="Load">
|
|
<PageHeader Title="Update Node">
|
|
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
|
<i class="icon-chevron-left mr-1"></i>
|
|
Back
|
|
</button>
|
|
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
|
<i class="icon-check mr-1"></i>
|
|
Update
|
|
</WButton>
|
|
</PageHeader>
|
|
|
|
<div class="mt-5">
|
|
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
|
|
|
<Tabs>
|
|
<Tab Name="Settings">
|
|
<GeneralNodeUpdate Request="Request"/>
|
|
</Tab>
|
|
|
|
<Tab Name="Allocations">
|
|
<AllocationsNodeUpdate Node="Node" />
|
|
</Tab>
|
|
|
|
<Tab Name="Advanced Settings">
|
|
<AdvancedNodeUpdate Request="Request"/>
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
</HandleForm>
|
|
</div>
|
|
</LazyLoader>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public int Id { get; set; }
|
|
|
|
private HandleForm Form;
|
|
private UpdateNodeRequest Request;
|
|
private NodeDetailResponse Node;
|
|
|
|
private async Task Load(LazyLoader _)
|
|
{
|
|
Node = await ApiClient.GetJson<NodeDetailResponse>($"api/admin/servers/nodes/{Id}");
|
|
Request = Mapper.Map<UpdateNodeRequest>(Node);
|
|
}
|
|
|
|
private void OnConfigure(FormConfiguration<UpdateNodeRequest> configuration)
|
|
{
|
|
configuration.WithField(x => x.Name);
|
|
configuration.WithField(x => x.Fqdn);
|
|
configuration.WithField(x => x.HttpPort);
|
|
configuration.WithField(x => x.FtpPort);
|
|
|
|
var advancedPage = configuration.WithPage("Advanced");
|
|
|
|
advancedPage.WithField(x => x.EnableTransparentMode);
|
|
advancedPage.WithField(x => x.EnableDynamicFirewall);
|
|
}
|
|
|
|
private async Task OnSubmit()
|
|
{
|
|
await ApiClient.Patch($"api/admin/servers/nodes/{Id}", Request);
|
|
|
|
await ToastService.Success("Successfully updated Node");
|
|
GoBack();
|
|
}
|
|
|
|
private void GoBack()
|
|
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
} |