71 lines
2.2 KiB
Plaintext
71 lines
2.2 KiB
Plaintext
@page "/admin/servers/all/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.Servers
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
|
|
@using MoonlightServers.Frontend.UI.Components.Servers.UpdateServerPartials
|
|
|
|
@inject HttpApiClient ApiClient
|
|
@inject NavigationManager Navigation
|
|
@inject ToastService ToastService
|
|
|
|
<LazyLoader Load="Load">
|
|
<PageHeader Title="Update Server">
|
|
<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="General">
|
|
<GeneralServerUpdate Request="Request" />
|
|
</Tab>
|
|
<Tab Name="Allocations">
|
|
<AllocationsServerUpdate Request="Request" Server="Server" />
|
|
</Tab>
|
|
<Tab Name="Variables">
|
|
<VariablesServerUpdate Request="Request" Server="Server" />
|
|
</Tab>
|
|
<Tab Name="Advanced">
|
|
<AdvancedServerUpdate Request="Request" />
|
|
</Tab>
|
|
</Tabs>
|
|
</HandleForm>
|
|
</div>
|
|
</LazyLoader>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public int Id { get; set; }
|
|
|
|
private HandleForm Form;
|
|
private UpdateServerRequest Request;
|
|
private ServerDetailResponse Server;
|
|
|
|
private async Task Load(LazyLoader _)
|
|
{
|
|
Server = await ApiClient.GetJson<ServerDetailResponse>($"api/admin/servers/{Id}");
|
|
Request = Mapper.Map<UpdateServerRequest>(Server);
|
|
}
|
|
|
|
private async Task OnSubmit()
|
|
{
|
|
await ApiClient.Patch($"api/admin/servers/{Id}", Request);
|
|
|
|
await ToastService.Success("Successfully updated Server");
|
|
GoBack();
|
|
}
|
|
|
|
private void GoBack()
|
|
=> Navigation.NavigateTo(ComponentHelper.GetRouteOfComponent<Index>()!);
|
|
} |