Updated to latest moonlight and mooncore version. Done refactoring to async scheme and other changes. Recreated database migrations and cleaned models
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
@using System.Diagnostics.CodeAnalysis
|
||||
@using Microsoft.AspNetCore.Components
|
||||
|
||||
@* TODO: Extract to mooncore? *@
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@using System.Text.Json.Serialization
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using XtermBlazor
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
@@ -15,11 +14,11 @@
|
||||
Addons="Parent.Addons"
|
||||
Options="Parent.Options"
|
||||
Class="h-full w-full"
|
||||
OnFirstRender="HandleFirstRender"/>
|
||||
OnFirstRender="HandleFirstRenderAsync"/>
|
||||
}
|
||||
|
||||
<div class="absolute top-4 right-4">
|
||||
<button @onclick="Hide" class="btn btn-error btn-square">
|
||||
<button @onclick="HideAsync" class="btn btn-error btn-square">
|
||||
<i class="icon-x text-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -50,13 +49,13 @@
|
||||
}
|
||||
|
||||
// Subscribe to parent events
|
||||
Parent.OnWrite += HandleWrite;
|
||||
Parent.OnWrite += HandleWriteAsync;
|
||||
|
||||
IsInitialized = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task HandleFirstRender()
|
||||
private async Task HandleFirstRenderAsync()
|
||||
{
|
||||
IsReadyToWrite = true;
|
||||
|
||||
@@ -73,7 +72,7 @@
|
||||
await Terminal.Write(outputToWrite);
|
||||
}
|
||||
|
||||
private async Task HandleWrite(string content)
|
||||
private async Task HandleWriteAsync(string content)
|
||||
{
|
||||
if (!IsReadyToWrite)
|
||||
return;
|
||||
@@ -83,7 +82,7 @@
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
Parent.OnWrite -= HandleWrite;
|
||||
Parent.OnWrite -= HandleWriteAsync;
|
||||
await Terminal.DisposeAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,25 +3,38 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Add a new allocation</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">IP Address</label>
|
||||
<input @bind="Form.IpAddress" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-ethernet-port text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Port</label>
|
||||
<input @bind="Form.Port" type="text" class="input w-full"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Add a new allocation</h3>
|
||||
<p class="text-base-content/80">Add a new allocation to the selected node</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Create</WButton>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">IP Address</label>
|
||||
<input class="input" @bind="Form.IpAddress" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Port</label>
|
||||
<input class="input" @bind="Form.Port" type="number"/>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -42,8 +55,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
|
||||
@@ -3,30 +3,42 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Add a range of new allocations</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">IP Address</label>
|
||||
<input @bind="Form.IpAddress" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-ethernet-port text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Start Port</label>
|
||||
<input @bind="Form.Start" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">End Port</label>
|
||||
<input @bind="Form.End" type="text" class="input w-full"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Add multiple allocations</h3>
|
||||
<p class="text-base-content/80">Add a range of new allocations to the selected node</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Create</WButton>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">IP Address</label>
|
||||
<input class="input" @bind="Form.IpAddress" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Start Port</label>
|
||||
<input class="input" @bind="Form.Start" type="number"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">End Port</label>
|
||||
<input class="input" @bind="Form.End" type="number"/>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -49,8 +61,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
@@ -4,25 +4,38 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Update allocation</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">IP Address</label>
|
||||
<input @bind="Form.IpAddress" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-ethernet-port text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Port</label>
|
||||
<input @bind="Form.Port" type="text" class="input w-full"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Update allocation</h3>
|
||||
<p class="text-base-content/80">Update an existing allocation</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Update</WButton>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">IP Address</label>
|
||||
<input class="input" @bind="Form.IpAddress" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Port</label>
|
||||
<input class="input" @bind="Form.Port" type="number"/>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Update
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -45,8 +58,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
@@ -2,26 +2,7 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
|
||||
|
||||
<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-base-content">Enable Transparent
|
||||
Mode
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<div class="flex items-center">
|
||||
<Switch @bind-Value="Request.EnableTransparentMode"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">
|
||||
Enable Dynamic Firewall
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<div class="flex items-center">
|
||||
<Switch @bind-Value="Request.EnableDynamicFirewall"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@code
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@using MoonCore.Blazor.FlyonUi.Alerts
|
||||
@using MoonCore.Blazor.FlyonUi.DataTables
|
||||
@using MoonCore.Blazor.FlyonUi.Grid
|
||||
@using MoonCore.Blazor.FlyonUi.Grid.Columns
|
||||
@using MoonCore.Blazor.FlyonUi.Modals
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||
@@ -22,38 +23,38 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="flex flex-col gap-y-3">
|
||||
<button type="button" @onclick="AddAllocation" class="btn btn-primary">Create</button>
|
||||
<button type="button" @onclick="AddAllocationRange" class="btn btn-accent">Create multiple</button>
|
||||
<button type="button" @onclick="DeleteAllAllocations" class="btn btn-error">Delete all</button>
|
||||
<button type="button" @onclick="AddAllocationAsync" class="btn btn-primary">Create</button>
|
||||
<button type="button" @onclick="AddAllocationRangeAsync" class="btn btn-accent">Create multiple
|
||||
</button>
|
||||
<button type="button" @onclick="DeleteAllAllocationsAsync" class="btn btn-error">Delete all</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-span-1 md:col-span-2 -mb-3">
|
||||
<DataTable @ref="Table" TItem="NodeAllocationResponse">
|
||||
<Configuration>
|
||||
<Pagination TItem="NodeAllocationResponse" ItemSource="LoadData"/>
|
||||
|
||||
<DataTableColumn TItem="NodeAllocationResponse" Field="@(x => x.IpAddress)" Name="IP Address"/>
|
||||
<DataTableColumn TItem="NodeAllocationResponse" Field="@(x => x.Port)" Name="Port"/>
|
||||
<DataTableColumn TItem="NodeAllocationResponse">
|
||||
<ColumnTemplate>
|
||||
<div class="flex justify-end items-center">
|
||||
<a @onclick="() => UpdateAllocation(context)"
|
||||
@onclick:preventDefault href="#"
|
||||
class="text-primary mr-2 sm:mr-3">
|
||||
<i class="icon-pencil text-base"></i>
|
||||
</a>
|
||||
<a @onclick="() => DeleteAllocation(context)"
|
||||
@onclick:preventDefault href="#"
|
||||
class="text-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</a>
|
||||
</div>
|
||||
</ColumnTemplate>
|
||||
</DataTableColumn>
|
||||
</Configuration>
|
||||
</DataTable>
|
||||
<DataGrid @ref="Grid"
|
||||
TGridItem="NodeAllocationResponse"
|
||||
EnablePagination="true"
|
||||
ItemsProvider="ItemsProviderAsync">
|
||||
<PropertyColumn Field="x => x.IpAddress" Title="IP Address" />
|
||||
<PropertyColumn Field="x => x.Port"/>
|
||||
<TemplateColumn>
|
||||
<td>
|
||||
<div class="flex justify-end items-center">
|
||||
<a @onclick="() => UpdateAllocationAsync(context)"
|
||||
@onclick:preventDefault href="#"
|
||||
class="text-primary mr-2 sm:mr-3">
|
||||
<i class="icon-pencil text-base"></i>
|
||||
</a>
|
||||
<a @onclick="() => DeleteAllocationAsync(context)"
|
||||
@onclick:preventDefault href="#"
|
||||
class="text-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</TemplateColumn>
|
||||
</DataGrid>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -61,84 +62,94 @@
|
||||
{
|
||||
[Parameter] public NodeResponse Node { get; set; }
|
||||
|
||||
private DataTable<NodeAllocationResponse> Table;
|
||||
|
||||
private async Task<IPagedData<NodeAllocationResponse>> LoadData(PaginationOptions options)
|
||||
private DataGrid<NodeAllocationResponse> Grid;
|
||||
|
||||
private async Task<DataGridItemResult<NodeAllocationResponse>> ItemsProviderAsync(
|
||||
DataGridItemRequest request
|
||||
)
|
||||
{
|
||||
return await ApiClient.GetJson<PagedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Node.Id}/allocations?page={options.Page}&pageSize={options.PerPage}"
|
||||
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
|
||||
|
||||
var countedData = await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Node.Id}/allocations{query}"
|
||||
);
|
||||
|
||||
return new()
|
||||
{
|
||||
TotalCount = countedData.TotalCount,
|
||||
Items = countedData.Items
|
||||
};
|
||||
}
|
||||
|
||||
private async Task AddAllocationRange()
|
||||
private async Task AddAllocationRangeAsync()
|
||||
{
|
||||
Func<CreateNodeAllocationRangeRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations/range", request);
|
||||
|
||||
await ToastService.Success("Successfully created allocations");
|
||||
await Table.Refresh();
|
||||
await ToastService.SuccessAsync("Successfully created allocations");
|
||||
await Grid.RefreshAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<CreateMultipleAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
||||
await ModalService.LaunchAsync<CreateMultipleAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
||||
}
|
||||
|
||||
private async Task AddAllocation()
|
||||
private async Task AddAllocationAsync()
|
||||
{
|
||||
Func<CreateNodeAllocationRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations", request);
|
||||
|
||||
await ToastService.Success("Successfully created allocation");
|
||||
await Table.Refresh();
|
||||
await ToastService.SuccessAsync("Successfully created allocation");
|
||||
await Grid.RefreshAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<CreateAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
||||
await ModalService.LaunchAsync<CreateAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
|
||||
}
|
||||
|
||||
private async Task UpdateAllocation(NodeAllocationResponse allocation)
|
||||
private async Task UpdateAllocationAsync(NodeAllocationResponse allocation)
|
||||
{
|
||||
Func<UpdateNodeAllocationRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Patch($"api/admin/servers/nodes/{Node.Id}/allocations/{allocation.Id}", request);
|
||||
|
||||
await ToastService.Success("Successfully updated allocation");
|
||||
await Table.Refresh();
|
||||
await ToastService.SuccessAsync("Successfully updated allocation");
|
||||
await Grid.RefreshAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<UpdateAllocationModal>(parameters =>
|
||||
await ModalService.LaunchAsync<UpdateAllocationModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
parameters.Add("Allocation", allocation);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task DeleteAllocation(NodeAllocationResponse allocation)
|
||||
private async Task DeleteAllocationAsync(NodeAllocationResponse allocation)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Delete allocation",
|
||||
"Do you really want to delete the selected allocation? This cannot be undone",
|
||||
async () =>
|
||||
{
|
||||
await ApiClient.Delete($"api/admin/servers/nodes/{Node.Id}/allocations/{allocation.Id}");
|
||||
|
||||
await ToastService.Success("Successfully deleted allocation");
|
||||
await Table.Refresh();
|
||||
await ToastService.SuccessAsync("Successfully deleted allocation");
|
||||
await Grid.RefreshAsync();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private async Task DeleteAllAllocations()
|
||||
private async Task DeleteAllAllocationsAsync()
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Delete all allocations",
|
||||
"Do you really want to delete all allocations? This cannot be undone",
|
||||
async () =>
|
||||
{
|
||||
await ApiClient.Delete($"api/admin/servers/nodes/{Node.Id}/allocations/all");
|
||||
|
||||
await ToastService.Success("Successfully deleted allocations");
|
||||
await Table.Refresh();
|
||||
await ToastService.SuccessAsync("Successfully deleted allocations");
|
||||
await Grid.RefreshAsync();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
|
||||
<div class="mb-3 mt-5 text-xl font-semibold">
|
||||
Overview
|
||||
@@ -176,27 +176,27 @@
|
||||
|
||||
private Timer? UpdateTimer;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
Statistics = await NodeService.GetStatistics(Node.Id);
|
||||
DockerStatistics = await NodeService.GetDockerStatistics(Node.Id);
|
||||
Statistics = await NodeService.GetStatisticsAsync(Node.Id);
|
||||
DockerStatistics = await NodeService.GetDockerStatisticsAsync(Node.Id);
|
||||
|
||||
UpdateTimer = new Timer(HandleUpdate, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3));
|
||||
UpdateTimer = new Timer(HandleUpdateAsync, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3));
|
||||
}
|
||||
|
||||
private async void HandleUpdate(object? _)
|
||||
private async void HandleUpdateAsync(object? _)
|
||||
{
|
||||
try
|
||||
{
|
||||
Statistics = await NodeService.GetStatistics(Node.Id);
|
||||
DockerStatistics = await NodeService.GetDockerStatistics(Node.Id);
|
||||
Statistics = await NodeService.GetStatisticsAsync(Node.Id);
|
||||
DockerStatistics = await NodeService.GetDockerStatisticsAsync(Node.Id);
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogWarning("An error occured while fetching status update: {e}", e);
|
||||
await ToastService.Error("Unable to fetch status update", e.Message);
|
||||
await ToastService.ErrorAsync("Unable to fetch status update", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,7 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
|
||||
<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-base-content">Storage</label>
|
||||
<div class="mt-2">
|
||||
<div class="select">
|
||||
<span class="icon-hard-drive text-base-content/80 my-auto"></span>
|
||||
<label class="sr-only" for="virtual-disk">Select the storage provider</label>
|
||||
<select @bind="Request.UseVirtualDisk" id="virtual-disk">
|
||||
<option value="false">Volume</option>
|
||||
<option value="true">Virtual Disk</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sm:col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Bandwidth</label>
|
||||
<div class="mt-2">
|
||||
<input @bind="Request.Bandwidth" type="number" autocomplete="off" class="input w-full">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@code
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
|
||||
@using MoonCore.Blazor.FlyonUi.Forms
|
||||
@using MoonlightServers.Frontend.UI.Views.Admin.All
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
|
||||
@@ -16,7 +15,7 @@
|
||||
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
SearchField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
Value="Parent.Allocations"
|
||||
ItemSource="ItemSource">
|
||||
ItemSource="ItemSourceAsync">
|
||||
</InputMultipleItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -27,16 +26,16 @@
|
||||
[Parameter] public CreateServerRequest Request { get; set; }
|
||||
[Parameter] public Create Parent { get; set; }
|
||||
|
||||
private async Task<NodeAllocationResponse[]> ItemSource()
|
||||
private async Task<NodeAllocationResponse[]> ItemSourceAsync()
|
||||
{
|
||||
// Handle unselected node
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
if (Parent.Node == null)
|
||||
return [];
|
||||
|
||||
var items = await PagedData<NodeAllocationResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?page={page}&pageSize={pageSize}"
|
||||
var items = await CountedData<NodeAllocationResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<InputItem TItem="UserResponse"
|
||||
DisplayField="@(x => x.Username)"
|
||||
SearchField="@(x => x.Username)"
|
||||
ItemSource="LoadUsers"
|
||||
ItemSource="LoadUsersAsync"
|
||||
@bind-Value="Parent.Owner">
|
||||
</InputItem>
|
||||
</div>
|
||||
@@ -35,7 +35,7 @@
|
||||
<InputItem TItem="StarResponse"
|
||||
DisplayField="@(x => x.Name)"
|
||||
SearchField="@(x => x.Name)"
|
||||
ItemSource="LoadStars"
|
||||
ItemSource="LoadStarsAsync"
|
||||
@bind-Value="Parent.Star">
|
||||
</InputItem>
|
||||
</div>
|
||||
@@ -47,7 +47,7 @@
|
||||
<InputItem TItem="NodeResponse"
|
||||
DisplayField="@(x => x.Name)"
|
||||
SearchField="@(x => x.Name)"
|
||||
ItemSource="LoadNodes"
|
||||
ItemSource="LoadNodesAsync"
|
||||
@bind-Value="Parent.Node">
|
||||
</InputItem>
|
||||
</div>
|
||||
@@ -91,29 +91,29 @@
|
||||
[Parameter] public CreateServerRequest Request { get; set; }
|
||||
[Parameter] public Create Parent { get; set; }
|
||||
|
||||
private async Task<StarResponse[]> LoadStars()
|
||||
private async Task<StarResponse[]> LoadStarsAsync()
|
||||
{
|
||||
return await PagedData<StarResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<StarResponse>>(
|
||||
$"api/admin/servers/stars?page={page}&pageSize={pageSize}"
|
||||
return await CountedData<StarResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarResponse>>(
|
||||
$"api/admin/servers/stars?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task<NodeResponse[]> LoadNodes()
|
||||
private async Task<NodeResponse[]> LoadNodesAsync()
|
||||
{
|
||||
return await PagedData<NodeResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<NodeResponse>>(
|
||||
$"api/admin/servers/nodes?page={page}&pageSize={pageSize}"
|
||||
return await CountedData<NodeResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<NodeResponse>>(
|
||||
$"api/admin/servers/nodes?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task<UserResponse[]> LoadUsers()
|
||||
private async Task<UserResponse[]> LoadUsersAsync()
|
||||
{
|
||||
return await PagedData<UserResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<UserResponse>>(
|
||||
$"api/admin/users?page={page}&pageSize={pageSize}"
|
||||
return await CountedData<UserResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<UserResponse>>(
|
||||
$"api/admin/users?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Frontend.UI.Views.Admin.All
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.ServerVariables
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
@foreach (var variable in StarVariables)
|
||||
{
|
||||
@@ -28,7 +27,7 @@
|
||||
class="input placeholder-base-content/50 w-full"
|
||||
value="@value"
|
||||
placeholder="@variable.DefaultValue"
|
||||
@onchange="@(args => UpdateValue(variable, args))"/>
|
||||
@onchange="@(args => UpdateValueAsync(variable, args))"/>
|
||||
</div>
|
||||
<p class="mt-1 text-sm leading-6 text-base-content/60">
|
||||
@variable.Description
|
||||
@@ -45,7 +44,7 @@
|
||||
|
||||
private StarVariableResponse[] StarVariables;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
if (Parent.Star == null)
|
||||
{
|
||||
@@ -53,14 +52,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
StarVariables = await PagedData<StarVariableResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Parent.Star.Id}/variables?page={page}&pageSize={pageSize}"
|
||||
StarVariables = await CountedData<StarVariableResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Parent.Star.Id}/variables?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task UpdateValue(StarVariableResponse starVariable, ChangeEventArgs args)
|
||||
private async Task UpdateValueAsync(StarVariableResponse starVariable, ChangeEventArgs args)
|
||||
{
|
||||
var value = args.Value?.ToString() ?? "";
|
||||
|
||||
|
||||
@@ -5,21 +5,37 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<div class="text-lg font-semibold mb-5">
|
||||
Create a new share
|
||||
</div>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Request" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mb-8">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Username</label>
|
||||
<input @bind="Request.Username" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-share-2 text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Create a new share</h3>
|
||||
<p class="text-base-content/80">Grant access to this server to other users</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Request" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Username</label>
|
||||
<input class="input" @bind="Request.Username" type="text"/>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<PermissionEditor Server="Server" PermissionLevels="Permissions" />
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
<PermissionEditor Server="Server" PermissionLevels="Permissions" />
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-8 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Create</WButton>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -33,16 +49,6 @@
|
||||
|
||||
private Dictionary<string, ServerPermissionLevel> Permissions = new();
|
||||
|
||||
private string[] Names =
|
||||
[
|
||||
"console",
|
||||
"power",
|
||||
"shares",
|
||||
"files",
|
||||
"variables",
|
||||
"settings"
|
||||
];
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Request = new()
|
||||
@@ -51,20 +57,20 @@
|
||||
};
|
||||
}
|
||||
|
||||
private async Task Set(string name, ServerPermissionLevel level)
|
||||
private async Task SetAsync(string name, ServerPermissionLevel level)
|
||||
{
|
||||
Permissions[name] = level;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task Submit()
|
||||
=> await HandleForm.Submit();
|
||||
private async Task SubmitAsync()
|
||||
=> await HandleForm.SubmitAsync();
|
||||
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
Request.Permissions = Permissions;
|
||||
|
||||
await OnSubmit.Invoke(Request);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@inject IEnumerable<IServerPermissionProvider> PermissionProviders
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-y-3">
|
||||
@foreach (var permission in AvailablePermissions)
|
||||
{
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<input @onclick="() => Set(permission.Identifier, ServerPermissionLevel.None)"
|
||||
<input @onclick="() => SetAsync(permission.Identifier, ServerPermissionLevel.None)"
|
||||
class="join-item btn btn-soft"
|
||||
type="radio" name="share-@permission.Identifier" aria-label="None"/>
|
||||
}
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<input @onclick="() => Set(permission.Identifier, ServerPermissionLevel.Read)"
|
||||
<input @onclick="() => SetAsync(permission.Identifier, ServerPermissionLevel.Read)"
|
||||
class="join-item btn btn-soft"
|
||||
type="radio" name="share-@permission.Identifier" aria-label="Read"/>
|
||||
}
|
||||
@@ -56,7 +56,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<input @onclick="() => Set(permission.Identifier, ServerPermissionLevel.ReadWrite)"
|
||||
<input @onclick="() => SetAsync(permission.Identifier, ServerPermissionLevel.ReadWrite)"
|
||||
class="join-item btn btn-soft"
|
||||
type="radio" name="share-@permission.Identifier" aria-label="Read & Write"/>
|
||||
}
|
||||
@@ -73,21 +73,21 @@
|
||||
|
||||
private ServerPermission[] AvailablePermissions;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
var permissions = new List<ServerPermission>();
|
||||
|
||||
foreach (var provider in PermissionProviders)
|
||||
{
|
||||
permissions.AddRange(
|
||||
await provider.GetPermissions(Server)
|
||||
await provider.GetPermissionsAsync(Server)
|
||||
);
|
||||
}
|
||||
|
||||
AvailablePermissions = permissions.ToArray();
|
||||
}
|
||||
|
||||
private async Task Set(string name, ServerPermissionLevel level)
|
||||
private async Task SetAsync(string name, ServerPermissionLevel level)
|
||||
{
|
||||
PermissionLevels[name] = level;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -174,8 +174,8 @@
|
||||
|
||||
try
|
||||
{
|
||||
Status = await ServerService.GetStatus(Server.Id);
|
||||
Stats = await ServerService.GetStats(Server.Id);
|
||||
Status = await ServerService.GetStatusAsync(Server.Id);
|
||||
Stats = await ServerService.GetStatsAsync(Server.Id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
HubConnection.On<string>("ConsoleOutput", async content =>
|
||||
{
|
||||
if (XtermConsole != null)
|
||||
await XtermConsole.Write(content);
|
||||
await XtermConsole.WriteAsync(content);
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
@@ -31,9 +31,9 @@
|
||||
|
||||
private async Task OnAfterConsoleInitialized()
|
||||
{
|
||||
await XtermConsole!.Write(InitialConsoleMessage);
|
||||
await XtermConsole!.WriteAsync(InitialConsoleMessage);
|
||||
}
|
||||
|
||||
private async Task OnCommand(string command)
|
||||
=> await ServerService.RunCommand(Server.Id, command + "\n");
|
||||
=> await ServerService.RunCommandAsync(Server.Id, command + "\n");
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<WButton CssClasses="btn btn-primary" OnClick="Reinstall">
|
||||
<WButton CssClasses="btn btn-primary" OnClick="ReinstallAsync">
|
||||
<i class="align-middle icon-hammer"></i>
|
||||
<span class="align-middle">Reinstall</span>
|
||||
</WButton>
|
||||
@@ -29,12 +29,12 @@
|
||||
|
||||
@code
|
||||
{
|
||||
private async Task Reinstall(WButton _)
|
||||
private async Task ReinstallAsync(WButton _)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Server installation",
|
||||
"Do you really want to reinstall the server? This can potentially lead to loss of data",
|
||||
() => ServerService.Install(Server.Id)
|
||||
() => ServerService.InstallAsync(Server.Id)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
<div class="flex flex-row mb-5">
|
||||
<input @bind="UsernameInput" class="input grow placeholder-base-content/50 me-1.5" autocomplete="none" placeholder="Enter a username"/>
|
||||
<button @onclick="OpenCreateModal" class="btn btn-primary">
|
||||
<button @onclick="OpenCreateModalAsync" class="btn btn-primary">
|
||||
<i class="icon-send me-1"></i>
|
||||
<span>Invite</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
|
||||
@if (Shares.Length == 0)
|
||||
{
|
||||
<IconAlert Title="No shares found" Color="text-primary" Icon="icon-search">
|
||||
@@ -40,11 +40,11 @@
|
||||
<span>@share.Username</span>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<WButton OnClick="_ => OpenUpdateModal(share)" CssClasses="btn btn-primary me-1.5">
|
||||
<WButton OnClick="_ => OpenUpdateModalAsync(share)" CssClasses="btn btn-primary me-1.5">
|
||||
<i class="icon-settings-2 me-1"></i>
|
||||
<span>Edit</span>
|
||||
</WButton>
|
||||
<WButton OnClick="_ => Delete(share)" CssClasses="btn btn-error">
|
||||
<WButton OnClick="_ => DeleteAsync(share)" CssClasses="btn btn-error">
|
||||
<i class="icon-trash-2 me-1"></i>
|
||||
<span>Delete</span>
|
||||
</WButton>
|
||||
@@ -63,60 +63,60 @@
|
||||
|
||||
private LazyLoader LazyLoader;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
Shares = await PagedData<ServerShareResponse>.All(async (page, pageSize)
|
||||
=> await ShareService.Get(Server.Id, page, pageSize)
|
||||
Shares = await CountedData<ServerShareResponse>.LoadAllAsync(async (startIndex, count)
|
||||
=> await ShareService.GetAsync(Server.Id, startIndex, count)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task OpenCreateModal()
|
||||
private async Task OpenCreateModalAsync()
|
||||
{
|
||||
await ModalService.Launch<CreateShareModal>(parameters =>
|
||||
await ModalService.LaunchAsync<CreateShareModal>(parameters =>
|
||||
{
|
||||
parameters["Username"] = UsernameInput;
|
||||
parameters["Server"] = Server;
|
||||
parameters["OnSubmit"] = SubmitCreate;
|
||||
parameters["OnSubmit"] = SubmitCreateAsync;
|
||||
}, size: "max-w-2xl");
|
||||
}
|
||||
|
||||
private async Task SubmitCreate(CreateShareRequest request)
|
||||
private async Task SubmitCreateAsync(CreateShareRequest request)
|
||||
{
|
||||
await ShareService.Create(Server.Id, request);
|
||||
await ShareService.CreateAsync(Server.Id, request);
|
||||
|
||||
await ToastService.Success("Share successfully created");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Share successfully created");
|
||||
await LazyLoader.ReloadAsync();
|
||||
}
|
||||
|
||||
private async Task OpenUpdateModal(ServerShareResponse share)
|
||||
private async Task OpenUpdateModalAsync(ServerShareResponse share)
|
||||
{
|
||||
await ModalService.Launch<UpdateShareModal>(parameters =>
|
||||
await ModalService.LaunchAsync<UpdateShareModal>(parameters =>
|
||||
{
|
||||
parameters["Share"] = share;
|
||||
parameters["Server"] = Server;
|
||||
parameters["OnSubmit"] = (UpdateShareRequest request) => SubmitUpdate(share.Id, request);
|
||||
parameters["OnSubmit"] = (UpdateShareRequest request) => SubmitUpdateAsync(share.Id, request);
|
||||
}, size: "max-w-2xl");
|
||||
}
|
||||
|
||||
private async Task SubmitUpdate(int shareId, UpdateShareRequest request)
|
||||
private async Task SubmitUpdateAsync(int shareId, UpdateShareRequest request)
|
||||
{
|
||||
await ShareService.Update(Server.Id, shareId, request);
|
||||
await ShareService.UpdateAsync(Server.Id, shareId, request);
|
||||
|
||||
await ToastService.Success("Share successfully updated");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Share successfully updated");
|
||||
await LazyLoader.ReloadAsync();
|
||||
}
|
||||
|
||||
private async Task Delete(ServerShareResponse share)
|
||||
private async Task DeleteAsync(ServerShareResponse share)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Share deletion",
|
||||
$"Do you really want to delete the share for the user '{share.Username}'? This cannot be undone",
|
||||
async () =>
|
||||
{
|
||||
await ShareService.Delete(Server.Id, share.Id);
|
||||
await ShareService.DeleteAsync(Server.Id, share.Id);
|
||||
|
||||
await ToastService.Success("Successfully deleted share");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully deleted share");
|
||||
await LazyLoader.ReloadAsync();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@inject ServerService ServerService
|
||||
@inject ToastService ToastService
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
@foreach (var variable in Variables)
|
||||
{
|
||||
@@ -24,7 +24,7 @@
|
||||
@variable.Description
|
||||
</p>
|
||||
<div class="mt-auto">
|
||||
<input @onchange="e => UpdateVariable(variable, e)"
|
||||
<input @onchange="e => UpdateVariableAsync(variable, e)"
|
||||
value="@variable.Value"
|
||||
type="text"
|
||||
class="input w-full">
|
||||
@@ -40,26 +40,26 @@
|
||||
private ServerVariableDetailResponse[] Variables;
|
||||
private LazyLoader LazyLoader;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
Variables = await PagedData<ServerVariableDetailResponse>.All(async (page, pageSize)
|
||||
=> await ServerService.GetVariables(Server.Id, page, pageSize)
|
||||
Variables = await CountedData<ServerVariableDetailResponse>.LoadAllAsync(async (startIndex, count)
|
||||
=> await ServerService.GetVariablesAsync(Server.Id, startIndex, count)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task UpdateVariable(ServerVariableDetailResponse variable, ChangeEventArgs args)
|
||||
private async Task UpdateVariableAsync(ServerVariableDetailResponse variable, ChangeEventArgs args)
|
||||
{
|
||||
var value = args.Value?.ToString() ?? "";
|
||||
|
||||
await ServerService.UpdateVariable(Server.Id, new()
|
||||
await ServerService.UpdateVariableAsync(Server.Id, new()
|
||||
{
|
||||
Key = variable.Key,
|
||||
Value = value
|
||||
});
|
||||
|
||||
// Fetch the current data to make sure the user sees the latest data
|
||||
await LazyLoader.Reload();
|
||||
await LazyLoader.ReloadAsync();
|
||||
|
||||
await ToastService.Success("Successfully updated variable");
|
||||
await ToastService.SuccessAsync("Successfully updated variable");
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,6 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
|
||||
|
||||
<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-base-content">Bandwidth</label>
|
||||
<div class="mt-2">
|
||||
<input @bind="Request.Bandwidth" type="number" autocomplete="off" class="input w-full">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
Value="Parent.Allocations"
|
||||
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
SearchField="@(x => $"{x.IpAddress}:{x.Port}")"
|
||||
ItemSource="Loader">
|
||||
ItemSource="LoaderAsync">
|
||||
</InputMultipleItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,11 +28,11 @@
|
||||
[Parameter] public ServerResponse Server { get; set; }
|
||||
[Parameter] public Update Parent { get; set; }
|
||||
|
||||
private async Task<NodeAllocationResponse[]> Loader()
|
||||
private async Task<NodeAllocationResponse[]> LoaderAsync()
|
||||
{
|
||||
return await PagedData<NodeAllocationResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Server.NodeId}/allocations/free?page={page}&pageSize={pageSize}&serverId={Server.Id}"
|
||||
return await CountedData<NodeAllocationResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
|
||||
$"api/admin/servers/nodes/{Server.NodeId}/allocations/free?startIndex={startIndex}&count={count}&serverId={Server.Id}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
DisplayField="@(x => x.Username)"
|
||||
SearchField="@(x => x.Username)"
|
||||
@bind-Value="Parent.Owner"
|
||||
ItemSource="Loader">
|
||||
ItemSource="LoaderAsync">
|
||||
</InputItem>
|
||||
|
||||
</div>
|
||||
@@ -64,11 +64,11 @@
|
||||
[Parameter] public UpdateServerRequest Request { get; set; }
|
||||
[Parameter] public Update Parent { get; set; }
|
||||
|
||||
private async Task<UserResponse[]> Loader()
|
||||
private async Task<UserResponse[]> LoaderAsync()
|
||||
{
|
||||
return await PagedData<UserResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<UserResponse>>(
|
||||
$"api/admin/users?page={page}&pageSize={pageSize}"
|
||||
return await CountedData<UserResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<UserResponse>>(
|
||||
$"api/admin/users?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
@foreach (var variable in ServerVariables)
|
||||
{
|
||||
@@ -30,7 +30,7 @@
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input type="text" class="input w-full" value="@value"
|
||||
@onchange="@(args => UpdateValue(variable, args))"/>
|
||||
@onchange="@(args => UpdateValueAsync(variable, args))"/>
|
||||
</div>
|
||||
<p class="mt-1 text-sm leading-6 text-base-content/60">
|
||||
@starVariable.Description
|
||||
@@ -48,22 +48,22 @@
|
||||
private StarVariableResponse[] StarVariables;
|
||||
private ServerVariableResponse[] ServerVariables;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
StarVariables = await PagedData<StarVariableResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Server.StarId}/variables?page={page}&pageSize={pageSize}"
|
||||
StarVariables = await CountedData<StarVariableResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Server.StarId}/variables?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
|
||||
ServerVariables = await PagedData<ServerVariableResponse>.All(async (page, pageSize) =>
|
||||
await ApiClient.GetJson<PagedData<ServerVariableResponse>>(
|
||||
$"api/admin/servers/{Server.Id}/variables?page={page}&pageSize={pageSize}"
|
||||
ServerVariables = await CountedData<ServerVariableResponse>.LoadAllAsync(async (startIndex, count) =>
|
||||
await ApiClient.GetJson<CountedData<ServerVariableResponse>>(
|
||||
$"api/admin/servers/{Server.Id}/variables?startIndex={startIndex}&count={count}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task UpdateValue(ServerVariableResponse serverVariable, ChangeEventArgs args)
|
||||
private async Task UpdateValueAsync(ServerVariableResponse serverVariable, ChangeEventArgs args)
|
||||
{
|
||||
var value = args.Value?.ToString() ?? "";
|
||||
|
||||
|
||||
@@ -3,21 +3,34 @@
|
||||
@using MoonlightServers.Shared.Http.Requests.Client.Servers.Shares
|
||||
@using MoonlightServers.Shared.Http.Responses.Client.Servers
|
||||
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Shares
|
||||
@using MoonlightServers.Shared.Models
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<div class="text-lg font-semibold mb-5">
|
||||
Update share for @Share.Username
|
||||
</div>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Request" OnValidSubmit="OnValidSubmit">
|
||||
<PermissionEditor Server="Server" PermissionLevels="Permissions" />
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-8 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Update</WButton>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-share-2 text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Update share for @Share.Username</h3>
|
||||
<p class="text-base-content/80">Grant access to this server to other users</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Request" OnValidSubmit="OnValidSubmit">
|
||||
<PermissionEditor Server="Server" PermissionLevels="Permissions" />
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -31,16 +44,6 @@
|
||||
|
||||
private Dictionary<string, ServerPermissionLevel> Permissions = new();
|
||||
|
||||
private string[] Names =
|
||||
[
|
||||
"console",
|
||||
"power",
|
||||
"shares",
|
||||
"files",
|
||||
"variables",
|
||||
"settings"
|
||||
];
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Request = new();
|
||||
@@ -48,20 +51,20 @@
|
||||
Permissions = Share.Permissions;
|
||||
}
|
||||
|
||||
private async Task Set(string name, ServerPermissionLevel level)
|
||||
private async Task SetAsync(string name, ServerPermissionLevel level)
|
||||
{
|
||||
Permissions[name] = level;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task Submit()
|
||||
=> await HandleForm.Submit();
|
||||
private async Task SubmitAsync()
|
||||
=> await HandleForm.SubmitAsync();
|
||||
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
Request.Permissions = Permissions;
|
||||
|
||||
await OnSubmit.Invoke(Request);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
}
|
||||
@@ -4,30 +4,42 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Add a new variable</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Display Name</label>
|
||||
<input @bind="Form.DisplayName" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-container text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Identifier</label>
|
||||
<input @bind="Form.Identifier" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Automatic pulling</label>
|
||||
<Switch @bind-Value="Form.AutoPulling"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Add a new docker image</h3>
|
||||
<p class="text-base-content/80">Add a new docker image to the star</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Create</WButton>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Display Name</label>
|
||||
<input class="input" @bind="Form.DisplayName" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Identifier</label>
|
||||
<input class="input" @bind="Form.Identifier" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Automatic pulling</label>
|
||||
<Switch @bind-Value="Form.AutoPulling"/>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -49,8 +61,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
@@ -4,47 +4,57 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Add a new parse configuration</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-x-2 gap-y-4">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">File</label>
|
||||
<input @bind="Form.File" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-braces text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Type</label>
|
||||
<select @bind="Form.Parser" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<FileParsers>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Add a parse configuration</h3>
|
||||
<p class="text-base-content/80">Add a new parse configuration to the star</p>
|
||||
</div>
|
||||
|
||||
<div class="col-span-2">
|
||||
<button type="button" @onclick="AddEntry" class="btn btn-primary w-full">Add entry</button>
|
||||
</div>
|
||||
|
||||
@foreach (var entry in Form.Entries)
|
||||
{
|
||||
<div class="col-span-2">
|
||||
<div class="flex flex-row">
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">File</label>
|
||||
<input class="input" @bind="Form.File" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Parser</label>
|
||||
<select @bind="Form.Parser" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<FileParsers>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button type="button" @onclick="AddEntryAsync" class="btn btn-primary w-full">Add entry</button>
|
||||
</div>
|
||||
|
||||
@foreach (var entry in Form.Entries)
|
||||
{
|
||||
<div class="flex flex-row mt-2">
|
||||
<input @bind="entry.Key" placeholder="Key" class="input placeholder-base-content/50 grow rounded-r-none"/>
|
||||
<input @bind="entry.Value" placeholder="Value" class="input placeholder-base-content/50 grow rounded-none"/>
|
||||
<button type="button" @onclick="() => RemoveEntry(entry)" class="btn btn-error grow-0 rounded-l-none">
|
||||
<button type="button" @onclick="() => RemoveEntryAsync(entry)" class="btn btn-error grow-0 rounded-l-none">
|
||||
<i class="icon-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Create</WButton>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -57,20 +67,20 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
|
||||
private async Task AddEntry()
|
||||
private async Task AddEntryAsync()
|
||||
{
|
||||
Form.Entries.Add(new());
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task RemoveEntry(ParseConfiguration.ParseConfigurationEntry entry)
|
||||
private async Task RemoveEntryAsync(ParseConfiguration.ParseConfigurationEntry entry)
|
||||
{
|
||||
Form.Entries.Remove(entry);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,60 +5,76 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Add a new variable</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Name</label>
|
||||
<input @bind="Form.Name" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-variable text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Description</label>
|
||||
<input @bind="Form.Description" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Key</label>
|
||||
<input @bind="Form.Key" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Default Value</label>
|
||||
<input @bind="Form.DefaultValue" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Allow Viewing</label>
|
||||
<Switch @bind-Value="Form.AllowViewing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Allow Editing</label>
|
||||
<Switch @bind-Value="Form.AllowEditing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Type</label>
|
||||
<select @bind="Form.Type" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<StarVariableType>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Filter</label>
|
||||
<input @bind="Form.Filter" type="text" class="input w-full"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Add a new variable</h3>
|
||||
<p class="text-base-content/80">Add a new variable to the star</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Name</label>
|
||||
<input @bind="Form.Name" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Create</WButton>
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Description</label>
|
||||
<input @bind="Form.Description" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Key</label>
|
||||
<input @bind="Form.Key" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Default Value</label>
|
||||
<input @bind="Form.DefaultValue" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Allow Viewing</label>
|
||||
<Switch @bind-Value="Form.AllowViewing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Allow Editing</label>
|
||||
<Switch @bind-Value="Form.AllowEditing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Type</label>
|
||||
<select @bind="Form.Type" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<StarVariableType>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Filter</label>
|
||||
<input @bind="Form.Filter" type="text" class="input w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Create
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -71,8 +87,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
|
||||
@@ -5,30 +5,42 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Update variable</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Display Name</label>
|
||||
<input @bind="Form.DisplayName" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-container text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Identifier</label>
|
||||
<input @bind="Form.Identifier" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-2">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Automatic pulling</label>
|
||||
<Switch @bind-Value="Form.AutoPulling"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Update docker image</h3>
|
||||
<p class="text-base-content/80">Update docker image properties</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Update</WButton>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Display Name</label>
|
||||
<input class="input" @bind="Form.DisplayName" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Identifier</label>
|
||||
<input class="input" @bind="Form.Identifier" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Automatic pulling</label>
|
||||
<Switch @bind-Value="Form.AutoPulling"/>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Update
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -52,8 +64,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
@@ -4,46 +4,57 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Update parse configuration</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-x-2 gap-y-4">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">File</label>
|
||||
<input @bind="Form.File" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-braces text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Type</label>
|
||||
<select @bind="Form.Parser" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<FileParsers>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Update parse configuration</h3>
|
||||
<p class="text-base-content/80">Update parse configuration properties</p>
|
||||
</div>
|
||||
|
||||
<div class="col-span-2">
|
||||
<button type="button" @onclick="AddEntry" class="btn btn-primary w-full">Add entry</button>
|
||||
</div>
|
||||
|
||||
@foreach (var entry in Form.Entries)
|
||||
{
|
||||
<div class="col-span-2">
|
||||
<div class="flex flex-row">
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="mt-2">
|
||||
<label class="label-text">File</label>
|
||||
<input class="input" @bind="Form.File" type="text"/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<label class="label-text">Parser</label>
|
||||
<select @bind="Form.Parser" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<FileParsers>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button type="button" @onclick="AddEntryAsync" class="btn btn-primary w-full">Add entry</button>
|
||||
</div>
|
||||
|
||||
@foreach (var entry in Form.Entries)
|
||||
{
|
||||
<div class="flex flex-row mt-2">
|
||||
<input @bind="entry.Key" placeholder="Key" class="input placeholder-base-content/50 grow rounded-r-none"/>
|
||||
<input @bind="entry.Value" placeholder="Value" class="input placeholder-base-content/50 grow rounded-none"/>
|
||||
<button type="button" @onclick="() => RemoveEntry(entry)" class="btn btn-error grow-0 rounded-l-none">
|
||||
<button type="button" @onclick="() => RemoveEntryAsync(entry)" class="btn btn-error grow-0 rounded-l-none">
|
||||
<i class="icon-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Update
|
||||
</WButton>
|
||||
</div>
|
||||
</HandleForm>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Save changes</WButton>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -63,18 +74,18 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
|
||||
private async Task AddEntry()
|
||||
private async Task AddEntryAsync()
|
||||
{
|
||||
Form.Entries.Add(new());
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task RemoveEntry(ParseConfiguration.ParseConfigurationEntry entry)
|
||||
private async Task RemoveEntryAsync(ParseConfiguration.ParseConfigurationEntry entry)
|
||||
{
|
||||
Form.Entries.Remove(entry);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -6,60 +6,76 @@
|
||||
|
||||
@inherits MoonCore.Blazor.FlyonUi.Modals.Components.BaseModal
|
||||
|
||||
<h1 class="mb-5 font-semibold text-xl">Update variable</h1>
|
||||
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Name</label>
|
||||
<input @bind="Form.Name" type="text" class="input w-full"/>
|
||||
<div class="p-5">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="avatar avatar-placeholder max-sm:hidden">
|
||||
<div class="border-base-content/20 rounded-box w-13 border-1">
|
||||
<span class="icon-variable text-xl"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Description</label>
|
||||
<input @bind="Form.Description" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Key</label>
|
||||
<input @bind="Form.Key" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Default Value</label>
|
||||
<input @bind="Form.DefaultValue" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Allow Viewing</label>
|
||||
<Switch @bind-Value="Form.AllowViewing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Allow Editing</label>
|
||||
<Switch @bind-Value="Form.AllowEditing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Type</label>
|
||||
<select @bind="Form.Type" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<StarVariableType>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="block text-sm font-medium leading-6 text-base-content">Filter</label>
|
||||
<input @bind="Form.Filter" type="text" class="input w-full"/>
|
||||
<div class="space-y-1">
|
||||
<h3 class="text-base-content text-2xl font-semibold">Update variable</h3>
|
||||
<p class="text-base-content/80">Update variable properties</p>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
<div class="mt-5">
|
||||
<HandleForm @ref="HandleForm" Model="Form" OnValidSubmit="OnValidSubmit">
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Name</label>
|
||||
<input @bind="Form.Name" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 flex space-x-2">
|
||||
<WButton OnClick="_ => Hide()" CssClasses="btn btn-secondary grow">Cancel</WButton>
|
||||
<WButton OnClick="_ => Submit()" CssClasses="btn btn-primary grow">Update</WButton>
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Description</label>
|
||||
<input @bind="Form.Description" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Key</label>
|
||||
<input @bind="Form.Key" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Default Value</label>
|
||||
<input @bind="Form.DefaultValue" type="text" class="input w-full"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Allow Viewing</label>
|
||||
<Switch @bind-Value="Form.AllowViewing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Allow Editing</label>
|
||||
<Switch @bind-Value="Form.AllowEditing"/>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Type</label>
|
||||
<select @bind="Form.Type" class="select w-full">
|
||||
@foreach (var val in Enum.GetValues<StarVariableType>())
|
||||
{
|
||||
<option value="@val">@val</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<label class="label-text">Filter</label>
|
||||
<input @bind="Form.Filter" type="text" class="input w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
</HandleForm>
|
||||
</div>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<button @onclick="HideAsync" type="button" class="btn btn-secondary me-2">
|
||||
Cancel
|
||||
</button>
|
||||
<WButton OnClick="SubmitAsync">
|
||||
Update
|
||||
</WButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -88,8 +104,8 @@
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
await OnSubmit.Invoke(Form);
|
||||
await Hide();
|
||||
await HideAsync();
|
||||
}
|
||||
|
||||
private Task Submit() => HandleForm.Submit();
|
||||
private Task SubmitAsync() => HandleForm.SubmitAsync();
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
@inject ToastService ToastService
|
||||
@inject AlertService AlertService
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
|
||||
<div class="flex justify-end">
|
||||
<button type="button" @onclick="AddDockerImage" class="btn btn-primary">Add docker image</button>
|
||||
<button type="button" @onclick="AddDockerImageAsync" class="btn btn-primary">Add docker image</button>
|
||||
</div>
|
||||
|
||||
<div class="grid sm:grid-cols-2 xl:grid-cols-3 gap-4 mt-5">
|
||||
@@ -30,11 +30,11 @@
|
||||
</div>
|
||||
|
||||
<div class="gap-x-2">
|
||||
<button type="button" @onclick="() => UpdateDockerImage(dockerImage)" class="btn btn-primary">
|
||||
<button type="button" @onclick="() => UpdateDockerImageAsync(dockerImage)" class="btn btn-primary">
|
||||
<i class="icon-settings text-base"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" @onclick="() => DeleteDockerImage(dockerImage)" class="btn btn-error">
|
||||
<button type="button" @onclick="() => DeleteDockerImageAsync(dockerImage)" class="btn btn-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -51,59 +51,61 @@
|
||||
private StarDockerImageResponse[] DockerImages;
|
||||
private LazyLoader LazyLoader;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
var pagedVariables = await ApiClient.GetJson<PagedData<StarDockerImageResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/dockerImages?page=0&pageSize=50"
|
||||
var pagedVariables = await ApiClient.GetJson<CountedData<StarDockerImageResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex=0&count=100"
|
||||
);
|
||||
|
||||
// TODO: Improve paged stuff
|
||||
|
||||
DockerImages = pagedVariables.Items;
|
||||
}
|
||||
|
||||
private async Task AddDockerImage()
|
||||
private async Task AddDockerImageAsync()
|
||||
{
|
||||
Func<CreateStarDockerImageRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Post($"api/admin/servers/stars/{Star.Id}/dockerImages", request);
|
||||
|
||||
await ToastService.Success("Successfully created docker image");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully created docker image");
|
||||
await LazyLoader.ReloadAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<CreateDockerImageModal>(parameters =>
|
||||
await ModalService.LaunchAsync<CreateDockerImageModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task UpdateDockerImage(StarDockerImageResponse dockerImage)
|
||||
private async Task UpdateDockerImageAsync(StarDockerImageResponse dockerImage)
|
||||
{
|
||||
Func<UpdateStarDockerImageRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Patch($"api/admin/servers/stars/{Star.Id}/dockerImages/{dockerImage.Id}", request);
|
||||
|
||||
await ToastService.Success("Successfully updated docker image");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully updated docker image");
|
||||
await LazyLoader.ReloadAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<UpdateDockerImageModal>(parameters =>
|
||||
await ModalService.LaunchAsync<UpdateDockerImageModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
parameters.Add("DockerImage", dockerImage);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task DeleteDockerImage(StarDockerImageResponse dockerImage)
|
||||
private async Task DeleteDockerImageAsync(StarDockerImageResponse dockerImage)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Delete docker image",
|
||||
"Do you really want to delete the selected docker image? This cannot be undone",
|
||||
async () =>
|
||||
{
|
||||
await ApiClient.Delete($"api/admin/servers/stars/{Star.Id}/dockerImages/{dockerImage.Id}");
|
||||
|
||||
await ToastService.Success("Successfully deleted docker image");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully deleted docker image");
|
||||
await LazyLoader.ReloadAsync();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
|
||||
private async Task OnFocusOut()
|
||||
{
|
||||
Request.InstallScript = await CodeEditor.GetValue();
|
||||
Request.InstallScript = await CodeEditor.GetValueAsync();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<LazyLoader Load="LoadAsync">
|
||||
<div>
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
<div class="sm:col-span-2">
|
||||
@@ -53,11 +53,13 @@
|
||||
|
||||
private List<StarDockerImageResponse> DockerImages;
|
||||
|
||||
private async Task Load(LazyLoader _)
|
||||
private async Task LoadAsync(LazyLoader _)
|
||||
{
|
||||
var pagedVariables = await ApiClient.GetJson<PagedData<StarDockerImageResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/dockerImages?page=0&pageSize=50"
|
||||
var pagedVariables = await ApiClient.GetJson<CountedData<StarDockerImageResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex=0&count=100"
|
||||
);
|
||||
|
||||
// TODO: Fix this
|
||||
|
||||
DockerImages = pagedVariables
|
||||
.Items
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
@inject ToastService ToastService
|
||||
|
||||
<div class="flex justify-end mb-5">
|
||||
<button type="button" @onclick="AddConfig" class="btn btn-primary">Add parse configuration</button>
|
||||
<button type="button" @onclick="AddConfigAsync" class="btn btn-primary">Add parse configuration</button>
|
||||
</div>
|
||||
|
||||
@if (HasParseError)
|
||||
@@ -33,11 +33,11 @@ else
|
||||
</div>
|
||||
|
||||
<div class="gap-x-2">
|
||||
<button type="button" @onclick="() => UpdateConfig(configuration)" class="btn btn-primary">
|
||||
<button type="button" @onclick="() => UpdateConfigAsync(configuration)" class="btn btn-primary">
|
||||
<i class="icon-settings text-base"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" @onclick="() => DeleteConfig(configuration)" class="btn btn-error">
|
||||
<button type="button" @onclick="() => DeleteConfigAsync(configuration)" class="btn btn-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -60,7 +60,7 @@ else
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task AddConfig()
|
||||
private async Task AddConfigAsync()
|
||||
{
|
||||
Func<ParseConfiguration, Task> onSubmit = async configuration =>
|
||||
{
|
||||
@@ -68,35 +68,35 @@ else
|
||||
SaveChanges();
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await ToastService.Success("Successfully created parse configuration");
|
||||
await ToastService.SuccessAsync("Successfully created parse configuration");
|
||||
};
|
||||
|
||||
await ModalService.Launch<CreateParseConfigModal>(parameters =>
|
||||
await ModalService.LaunchAsync<CreateParseConfigModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
}, "max-w-xl");
|
||||
}
|
||||
|
||||
private async Task UpdateConfig(ParseConfiguration configuration)
|
||||
private async Task UpdateConfigAsync(ParseConfiguration configuration)
|
||||
{
|
||||
Func<ParseConfiguration, Task> onSubmit = async _ =>
|
||||
{
|
||||
SaveChanges();
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await ToastService.Success("Successfully updated parse configuration");
|
||||
await ToastService.SuccessAsync("Successfully updated parse configuration");
|
||||
};
|
||||
|
||||
await ModalService.Launch<UpdateParseConfigModal>(parameters =>
|
||||
await ModalService.LaunchAsync<UpdateParseConfigModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
parameters.Add("Configuration", configuration);
|
||||
}, "max-w-xl");
|
||||
}
|
||||
|
||||
private async Task DeleteConfig(ParseConfiguration configuration)
|
||||
private async Task DeleteConfigAsync(ParseConfiguration configuration)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Parse configuration deletion",
|
||||
"Do you really want to delete the selected parse configuration",
|
||||
async () =>
|
||||
@@ -105,7 +105,7 @@ else
|
||||
SaveChanges();
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await ToastService.Success("Successfully deleted parse configuration");
|
||||
await ToastService.SuccessAsync("Successfully deleted parse configuration");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
@inject ToastService ToastService
|
||||
|
||||
<div class="flex justify-end mb-5">
|
||||
<button type="button" @onclick="AddVariable" class="btn btn-primary">Add variable</button>
|
||||
<button type="button" @onclick="AddVariableAsync" class="btn btn-primary">Add variable</button>
|
||||
</div>
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
|
||||
<div class="grid sm:grid-cols-2 xl:grid-cols-3 gap-4">
|
||||
@foreach (var variable in CurrentVariables)
|
||||
{
|
||||
@@ -30,11 +30,11 @@
|
||||
</div>
|
||||
|
||||
<div class="gap-x-2">
|
||||
<button type="button" @onclick="() => UpdateVariable(variable)" class="btn btn-primary">
|
||||
<button type="button" @onclick="() => UpdateVariableAsync(variable)" class="btn btn-primary">
|
||||
<i class="icon-settings text-base"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" @onclick="() => DeleteVariable(variable)" class="btn btn-error">
|
||||
<button type="button" @onclick="() => DeleteVariableAsync(variable)" class="btn btn-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -51,59 +51,59 @@
|
||||
private StarVariableResponse[] CurrentVariables;
|
||||
private LazyLoader LazyLoader;
|
||||
|
||||
private async Task Load(LazyLoader arg)
|
||||
private async Task LoadAsync(LazyLoader arg)
|
||||
{
|
||||
var pagedVariables = await ApiClient.GetJson<PagedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/variables?page=0&pageSize=50"
|
||||
var pagedVariables = await ApiClient.GetJson<CountedData<StarVariableResponse>>(
|
||||
$"api/admin/servers/stars/{Star.Id}/variables?startIndex=0&count=100"
|
||||
);
|
||||
|
||||
CurrentVariables = pagedVariables.Items;
|
||||
}
|
||||
|
||||
private async Task AddVariable()
|
||||
private async Task AddVariableAsync()
|
||||
{
|
||||
Func<CreateStarVariableRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Post($"api/admin/servers/stars/{Star.Id}/variables", request);
|
||||
|
||||
await ToastService.Success("Successfully created variable");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully created variable");
|
||||
await LazyLoader.ReloadAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<CreateVariableModal>(parameters =>
|
||||
await ModalService.LaunchAsync<CreateVariableModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
}, "max-w-xl");
|
||||
}
|
||||
|
||||
private async Task UpdateVariable(StarVariableResponse variable)
|
||||
private async Task UpdateVariableAsync(StarVariableResponse variable)
|
||||
{
|
||||
Func<UpdateStarVariableRequest, Task> onSubmit = async request =>
|
||||
{
|
||||
await ApiClient.Patch($"api/admin/servers/stars/{Star.Id}/variables/{variable.Id}", request);
|
||||
|
||||
await ToastService.Success("Successfully updated variable");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully updated variable");
|
||||
await LazyLoader.ReloadAsync();
|
||||
};
|
||||
|
||||
await ModalService.Launch<UpdateVariableModal>(parameters =>
|
||||
await ModalService.LaunchAsync<UpdateVariableModal>(parameters =>
|
||||
{
|
||||
parameters.Add("OnSubmit", onSubmit);
|
||||
parameters.Add("Variable", variable);
|
||||
}, "max-w-xl");
|
||||
}
|
||||
|
||||
private async Task DeleteVariable(StarVariableResponse variable)
|
||||
private async Task DeleteVariableAsync(StarVariableResponse variable)
|
||||
{
|
||||
await AlertService.ConfirmDanger(
|
||||
await AlertService.ConfirmDangerAsync(
|
||||
"Delete variable",
|
||||
"Do you really want to delete the selected variable? This cannot be undone",
|
||||
async () =>
|
||||
{
|
||||
await ApiClient.Delete($"api/admin/servers/stars/{Star.Id}/variables/{variable.Id}");
|
||||
|
||||
await ToastService.Success("Successfully deleted variable");
|
||||
await LazyLoader.Reload();
|
||||
await ToastService.SuccessAsync("Successfully deleted variable");
|
||||
await LazyLoader.ReloadAsync();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@using System.Collections.Concurrent
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using MoonCore.Blazor.FlyonUi.Modals
|
||||
@using MoonCore.Helpers
|
||||
@@ -18,12 +17,12 @@
|
||||
Addons="Addons"
|
||||
Options="Options"
|
||||
Class="h-full w-full"
|
||||
OnFirstRender="HandleFirstRender"/>
|
||||
OnFirstRender="HandleFirstRenderAsync"/>
|
||||
}
|
||||
|
||||
<div class="flex flex-row w-full mt-1.5">
|
||||
<input @bind="CommandInput" @onkeyup="HandleKey" type="text" placeholder="Type here..." class="input grow"/>
|
||||
<WButton OnClick="_ => SubmitCommand()" CssClasses="btn btn-square btn-primary grow-0 ms-1.5">
|
||||
<input @bind="CommandInput" @onkeyup="HandleKeyAsync" type="text" placeholder="Type here..." class="input grow"/>
|
||||
<WButton OnClick="_ => SubmitCommandAsync()" CssClasses="btn btn-square btn-primary grow-0 ms-1.5">
|
||||
<i class="icon-send-horizontal text-lg"></i>
|
||||
</WButton>
|
||||
</div>
|
||||
@@ -32,18 +31,18 @@
|
||||
<div class="flex flex-col gap-y-1.5">
|
||||
@if (IsPaused)
|
||||
{
|
||||
<button @onclick="TogglePause" class="btn btn-primary btn-square">
|
||||
<button @onclick="TogglePauseAsync" class="btn btn-primary btn-square">
|
||||
<i class="icon-play text-lg"></i>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button @onclick="TogglePause" class="btn btn-secondary btn-square">
|
||||
<button @onclick="TogglePauseAsync" class="btn btn-secondary btn-square">
|
||||
<i class="icon-pause text-lg"></i>
|
||||
</button>
|
||||
}
|
||||
|
||||
<button @onclick="OpenFullscreen" class="btn btn-secondary btn-square">
|
||||
<button @onclick="OpenFullscreenAsync" class="btn btn-secondary btn-square">
|
||||
<i class="icon-maximize text-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -110,7 +109,7 @@
|
||||
await OnAfterInitialized.Invoke();
|
||||
}
|
||||
|
||||
private async Task HandleFirstRender()
|
||||
private async Task HandleFirstRenderAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -133,17 +132,17 @@
|
||||
await OnFirstRender.Invoke();
|
||||
}
|
||||
|
||||
public async Task Write(string content)
|
||||
public async Task WriteAsync(string content)
|
||||
{
|
||||
// We cache messages here as there is the chance that the console isn't ready for input while receiving write tasks
|
||||
|
||||
if (IsReadyToWrite && !IsPaused)
|
||||
await HandleWrite(content);
|
||||
await HandleWriteAsync(content);
|
||||
else
|
||||
WriteQueue.Add(content);
|
||||
}
|
||||
|
||||
private async Task HandleWrite(string content)
|
||||
private async Task HandleWriteAsync(string content)
|
||||
{
|
||||
// Update output cache and prune it if required
|
||||
if (OutputCache.Count > MaxOutputCacheSize)
|
||||
@@ -162,12 +161,12 @@
|
||||
await Terminal.Write(content);
|
||||
}
|
||||
|
||||
private async Task OpenFullscreen()
|
||||
private async Task OpenFullscreenAsync()
|
||||
{
|
||||
await ModalService.Launch<FullScreenModal>(parameters => { parameters["Parent"] = this; }, size: "max-w-none");
|
||||
await ModalService.LaunchAsync<FullScreenModal>(parameters => { parameters["Parent"] = this; }, size: "max-w-none");
|
||||
}
|
||||
|
||||
private async Task TogglePause()
|
||||
private async Task TogglePauseAsync()
|
||||
{
|
||||
IsPaused = !IsPaused;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
@@ -178,10 +177,10 @@
|
||||
var queueContent = string.Concat(WriteQueue);
|
||||
WriteQueue.Clear();
|
||||
|
||||
await HandleWrite(queueContent);
|
||||
await HandleWriteAsync(queueContent);
|
||||
}
|
||||
|
||||
private async Task SubmitCommand()
|
||||
private async Task SubmitCommandAsync()
|
||||
{
|
||||
CommandHistory.Add(CommandInput);
|
||||
|
||||
@@ -194,12 +193,12 @@
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task HandleKey(KeyboardEventArgs keyboard)
|
||||
private async Task HandleKeyAsync(KeyboardEventArgs keyboard)
|
||||
{
|
||||
switch (keyboard.Code)
|
||||
{
|
||||
case "Enter":
|
||||
await SubmitCommand();
|
||||
await SubmitCommandAsync();
|
||||
break;
|
||||
|
||||
case "ArrowUp" or "ArrowDown":
|
||||
|
||||
Reference in New Issue
Block a user