Updated the usage of mooncore components
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
@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
|
||||
@@ -11,10 +10,10 @@
|
||||
@inject ToastService ToastService
|
||||
|
||||
<PageHeader Title="Create Node">
|
||||
<button @onclick="GoBack" type="button" class="btn btn-secondary">
|
||||
<a href="/admin/servers/nodes" class="btn btn-secondary">
|
||||
<i class="icon-chevron-left mr-1"></i>
|
||||
Back
|
||||
</button>
|
||||
</a>
|
||||
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
|
||||
<i class="icon-check mr-1"></i>
|
||||
Create
|
||||
@@ -23,12 +22,40 @@
|
||||
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
||||
<GeneratedForm TForm="CreateNodeRequest" Model="Request" OnConfigure="OnConfigure"/>
|
||||
<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">Name</label>
|
||||
<div class="mt-2">
|
||||
<input @bind="Request.Name" type="text" autocomplete="off" class="form-input w-full">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-white">Fqdn</label>
|
||||
<div class="mt-2">
|
||||
<input @bind="Request.Fqdn" type="text" autocomplete="off" class="form-input w-full">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-white">HttpPort</label>
|
||||
<div class="mt-2">
|
||||
<input @bind="Request.HttpPort" type="number" autocomplete="off" class="form-input w-full">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-white">FtpPort</label>
|
||||
<div class="mt-2">
|
||||
<input @bind="Request.FtpPort" type="number" autocomplete="off" class="form-input w-full">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@*
|
||||
TODO: EnableTransparentMode, EnableDynamicFirewall
|
||||
*@
|
||||
|
||||
@code
|
||||
{
|
||||
private HandleForm Form;
|
||||
private CreateNodeRequest Request;
|
||||
@@ -37,36 +64,12 @@
|
||||
{
|
||||
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();
|
||||
await ToastService.Success("Successfully created node");
|
||||
Navigation.NavigateTo("/admin/servers/nodes");
|
||||
}
|
||||
|
||||
private void GoBack()
|
||||
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
||||
}
|
||||
Reference in New Issue
Block a user