81 lines
2.3 KiB
Plaintext
81 lines
2.3 KiB
Plaintext
@page "/admin/servers/nodes/update/{Id:int}"
|
|
|
|
@using MoonCore.Blazor.FlyonUi.Components
|
|
@using MoonCore.Blazor.FlyonUi.Toasts
|
|
@using MoonCore.Helpers
|
|
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
|
@using MoonlightServers.Frontend.UI.Components.Nodes.UpdatePartials
|
|
|
|
@inject HttpApiClient ApiClient
|
|
@inject NavigationManager Navigation
|
|
@inject ToastService ToastService
|
|
|
|
@attribute [Authorize(Policy = "permissions:admin.servers.nodes.update")]
|
|
|
|
<LazyLoader Load="LoadAsync">
|
|
<PageHeader Title="@Node.Name">
|
|
<a href="/admin/servers/nodes" class="btn btn-secondary">
|
|
<i class="icon-chevron-left"></i>
|
|
Back
|
|
</a>
|
|
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
|
|
<i class="icon-check"></i>
|
|
Update
|
|
</WButton>
|
|
</PageHeader>
|
|
|
|
<div class="mt-5">
|
|
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
|
|
|
|
<Tabs>
|
|
<Tab Name="Overview">
|
|
<Overview Node="Node" />
|
|
</Tab>
|
|
|
|
<Tab Name="Settings">
|
|
<General Request="Request"/>
|
|
</Tab>
|
|
|
|
<Tab Name="Allocations">
|
|
<Allocations Node="Node"/>
|
|
</Tab>
|
|
|
|
<Tab Name="Advanced Settings">
|
|
<Advanced Request="Request"/>
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
</HandleForm>
|
|
</div>
|
|
</LazyLoader>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public int Id { get; set; }
|
|
|
|
private HandleForm Form;
|
|
private UpdateNodeRequest Request;
|
|
private NodeResponse Node;
|
|
|
|
private async Task LoadAsync(LazyLoader _)
|
|
{
|
|
Node = await ApiClient.GetJson<NodeResponse>($"api/admin/servers/nodes/{Id}");
|
|
|
|
Request = new UpdateNodeRequest()
|
|
{
|
|
Name = Node.Name,
|
|
Fqdn = Node.Fqdn,
|
|
FtpPort = Node.FtpPort,
|
|
HttpPort = Node.HttpPort
|
|
};
|
|
}
|
|
|
|
private async Task OnSubmit()
|
|
{
|
|
await ApiClient.Patch($"api/admin/servers/nodes/{Id}", Request);
|
|
|
|
await ToastService.SuccessAsync("Successfully updated Node");
|
|
Navigation.NavigateTo("/admin/servers/nodes");
|
|
}
|
|
} |