79 lines
2.4 KiB
Plaintext
79 lines
2.4 KiB
Plaintext
@page "/admin/servers/all/create"
|
|
|
|
@using MoonCore.Blazor.FlyonUi.Components
|
|
@using MoonCore.Blazor.FlyonUi.Toasts
|
|
@using MoonCore.Helpers
|
|
@using Moonlight.Shared.Http.Responses.Admin.Users
|
|
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
|
@using MoonlightServers.Frontend.UI.Components.Servers.CreateServerPartials
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
|
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
|
|
|
@inject HttpApiClient ApiClient
|
|
@inject NavigationManager Navigation
|
|
@inject ToastService ToastService
|
|
|
|
@attribute [Authorize(Policy = "permissions:admin.servers.create")]
|
|
|
|
<PageHeader Title="Create Server">
|
|
<a href="/admin/servers/all" class="btn btn-secondary">
|
|
<i class="icon-chevron-left mr-1"></i>
|
|
Back
|
|
</a>
|
|
<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">
|
|
<Tabs>
|
|
<Tab Name="General">
|
|
<GeneralServerCreate Request="Request" Star="Star" Node="Node" User="Owner" />
|
|
</Tab>
|
|
<Tab Name="Allocations">
|
|
<AllocationsServerCreate Request="Request" Allocations="Allocations" Node="Node" />
|
|
</Tab>
|
|
<Tab Name="Variables">
|
|
<VariablesServerCreate Request="Request" Star="Star" />
|
|
</Tab>
|
|
<Tab Name="Advanced">
|
|
<AdvancedServerCreate Request="Request" />
|
|
</Tab>
|
|
</Tabs>
|
|
</HandleForm>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
private HandleForm Form;
|
|
private CreateServerRequest Request;
|
|
|
|
private List<NodeAllocationResponse> Allocations = new();
|
|
private UserResponse? Owner;
|
|
private StarDetailResponse? Star;
|
|
private NodeResponse? Node;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Request = new();
|
|
}
|
|
|
|
private async Task OnSubmit()
|
|
{
|
|
Request.AllocationIds = Allocations
|
|
.Select(x => x.Id)
|
|
.ToArray();
|
|
|
|
Request.StarId = Star?.Id ?? -1;
|
|
Request.NodeId = Node?.Id ?? -1;
|
|
Request.OwnerId = Owner?.Id ?? -1;
|
|
|
|
await ApiClient.Post("api/admin/servers", Request);
|
|
|
|
await ToastService.Success("Successfully created Server");
|
|
Navigation.NavigateTo("/admin/servers/all");
|
|
}
|
|
} |