72 lines
2.0 KiB
Plaintext
72 lines
2.0 KiB
Plaintext
@page "/admin/servers/nodes/create"
|
|
|
|
@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
|
|
|
|
@inject HttpApiClient ApiClient
|
|
@inject NavigationManager Navigation
|
|
@inject ToastService ToastService
|
|
|
|
<PageHeader Title="Create 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>
|
|
Create
|
|
</WButton>
|
|
</PageHeader>
|
|
|
|
<div class="mt-5">
|
|
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
|
<GeneratedForm TForm="CreateNodeRequest" Model="Request" OnConfigure="OnConfigure"/>
|
|
</HandleForm>
|
|
</div>
|
|
|
|
@code
|
|
|
|
{
|
|
private HandleForm Form;
|
|
private CreateNodeRequest Request;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Request = new();
|
|
}
|
|
|
|
private void OnConfigure(FormConfiguration<CreateNodeRequest> configuration)
|
|
{
|
|
configuration.WithField(x => x.Name);
|
|
configuration.WithField(x => x.Fqdn);
|
|
|
|
configuration.WithField(x => x.HttpPort, fieldConfiguration =>
|
|
{
|
|
fieldConfiguration.DefaultValue = 8080;
|
|
});
|
|
|
|
configuration.WithField(x => x.FtpPort, fieldConfiguration =>
|
|
{
|
|
fieldConfiguration.DefaultValue = 2021;
|
|
});
|
|
|
|
var advancedPage = configuration.WithPage("Advanced");
|
|
|
|
advancedPage.WithField(x => x.EnableTransparentMode);
|
|
advancedPage.WithField(x => x.EnableDynamicFirewall);
|
|
}
|
|
|
|
private async Task OnSubmit()
|
|
{
|
|
await ApiClient.Post("api/admin/servers/nodes", Request);
|
|
|
|
await ToastService.Success("Successfully created Node");
|
|
GoBack();
|
|
}
|
|
|
|
private void GoBack()
|
|
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
} |