Recreated plugin with new project template. Started implementing server system daemon

This commit is contained in:
2026-03-01 21:09:29 +01:00
parent f6b71f4de6
commit 52dbd13fb5
350 changed files with 2795 additions and 21553 deletions

View File

@@ -0,0 +1,74 @@
@using Moonlight.Frontend.Helpers
@using MoonlightServers.Shared
@using MoonlightServers.Shared.Http.Requests
@using MoonlightServers.Shared.Http.Responses
@using ShadcnBlazor.Buttons
@using ShadcnBlazor.Dialogs
@using ShadcnBlazor.Extras.AlertDialogs
@using ShadcnBlazor.Extras.Forms
@using ShadcnBlazor.Fields
@using ShadcnBlazor.Inputs
@inherits ShadcnBlazor.Extras.Dialogs.DialogBase
@inject HttpClient HttpClient
@inject AlertDialogService AlertDialogService
<DialogHeader>
<DialogTitle>Example Form</DialogTitle>
<DialogDescription>This forms removes all spaces from the input</DialogDescription>
</DialogHeader>
<EnhancedEditForm @ref="Form" OnValidSubmit="OnSubmit" Model="Dto">
<DataAnnotationsValidator/>
<FieldSet>
<FormValidationSummary/>
<FieldGroup>
<Field>
<FieldLabel for="formInput">Form Input</FieldLabel>
<TextInputField id="formInput" @bind-Value="Dto.TextField"/>
<FieldDescription>Input you want to remove the spaces from</FieldDescription>
</Field>
</FieldGroup>
</FieldSet>
</EnhancedEditForm>
<DialogFooter>
<Button @onclick="() => Form.SubmitAsync()">Submit</Button>
<DialogClose/>
</DialogFooter>
@code
{
private FormSubmitDto Dto = new();
private EnhancedEditForm Form;
private async Task<bool> OnSubmit(EditContext editContext, ValidationMessageStore validationMessageStore)
{
var response = await HttpClient.PostAsJsonAsync(
"api/form",
Dto,
SerializationContext.Default.Options
);
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadFromJsonAsync<FormResultDto>(
SerializationContext.Default.Options
);
if (data == null)
return true;
await AlertDialogService.InfoAsync("Result", data.Result);
await CloseAsync();
return true;
}
await ProblemDetailsHelper.HandleProblemDetailsAsync(response, Dto, validationMessageStore);
return false;
}
}

View File

@@ -1,29 +0,0 @@
@using System.Diagnostics.CodeAnalysis
@* TODO: Extract to mooncore? *@
@inherits InputBase<bool>
<div class="flex items-center gap-1">
<input @bind="CurrentValue" type="checkbox" class="switch switch-primary" id="switch-@GetHashCode()" />
<label class="label-text text-base" for="switch-@GetHashCode()">
@if (CurrentValue)
{
<span>On</span>
}
else
{
<span>Off</span>
}
</label>
</div>
@code
{
protected override bool TryParseValueFromString(string? value, out bool result, [NotNullWhen(false)] out string? validationErrorMessage)
{
validationErrorMessage = null;
result = string.Equals(value, "true", StringComparison.OrdinalIgnoreCase);
return true;
}
}

View File

@@ -1,88 +0,0 @@
@using Microsoft.Extensions.Logging
@using XtermBlazor
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
@inject IJSRuntime JsRuntime
@inject ILogger<FullScreenModal> Logger
@implements IAsyncDisposable
<div class="bg-black p-2 relative w-full h-[90vh] rounded-lg">
@if (IsInitialized)
{
<Xterm @ref="Terminal"
Addons="Parent.Addons"
Options="Parent.Options"
Class="h-full w-full"
OnFirstRender="HandleFirstRenderAsync"/>
}
<div class="absolute top-4 right-4">
<button @onclick="HideAsync" class="btn btn-error btn-square">
<i class="icon-x text-lg"></i>
</button>
</div>
</div>
@code
{
[Parameter] public XtermConsole Parent { get; set; }
private bool IsInitialized = false;
private bool IsReadyToWrite = false;
private Xterm Terminal;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
// Initialize addons
try
{
await JsRuntime.InvokeVoidAsync("moonlightServers.loadAddons");
}
catch (Exception e)
{
Logger.LogError("An error occured while initializing addons: {e}", e);
}
// Subscribe to parent events
Parent.OnWrite += HandleWriteAsync;
IsInitialized = true;
await InvokeAsync(StateHasChanged);
}
private async Task HandleFirstRenderAsync()
{
IsReadyToWrite = true;
try
{
await Terminal.Addon("addon-fit").InvokeVoidAsync("fit");
}
catch (Exception e)
{
Logger.LogError("An error occured while calling addons: {e}", e);
}
var outputToWrite = string.Concat(Parent.OutputCache.ToArray());
await Terminal.Write(outputToWrite);
}
private async Task HandleWriteAsync(string content)
{
if (!IsReadyToWrite)
return;
await Terminal.Write(content);
}
public async ValueTask DisposeAsync()
{
Parent.OnWrite -= HandleWriteAsync;
await Terminal.DisposeAsync();
}
}

View File

@@ -1,62 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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
{
[Parameter] public Func<CreateNodeAllocationRequest, Task> OnSubmit { get; set; }
private CreateNodeAllocationRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
Form = new()
{
IpAddress = "0.0.0.0"
};
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,68 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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
{
[Parameter] public Func<CreateNodeAllocationRangeRequest, Task> OnSubmit { get; set; }
private CreateNodeAllocationRangeRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
Form = new()
{
IpAddress = "0.0.0.0",
Start = 2000,
End = 3000
};
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,65 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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
{
[Parameter] public Func<UpdateNodeAllocationRequest, Task> OnSubmit { get; set; }
[Parameter] public NodeAllocationResponse Allocation { get; set; }
private UpdateNodeAllocationRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
Form = new UpdateNodeAllocationRequest()
{
IpAddress = Allocation.IpAddress,
Port = Allocation.Port
};
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,10 +0,0 @@
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
</div>
@code
{
[Parameter] public UpdateNodeRequest Request { get; set; }
}

View File

@@ -1,150 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Common
@using MoonCore.Blazor.FlyonUi.Grid
@using MoonCore.Blazor.FlyonUi.Grid.Columns
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Common
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
@using MoonCore.Helpers
@using MoonlightServers.Frontend.UI.Components.Nodes.Modals
@using MoonlightServers.Shared.Http.Requests.Admin.NodeAllocations
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@inject HttpApiClient ApiClient
@inject ModalService ModalService
@inject ToastService ToastService
@inject AlertService AlertService
<div class="grid grid-cols-1 md:grid-cols-3 md:gap-x-5">
<div class="col-span-1">
<div class="card">
<div class="card-header">
<span class="card-title">Actions</span>
</div>
<div class="card-body">
<div class="flex flex-col gap-y-3">
<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">
<DataGrid @ref="Grid"
TGridItem="NodeAllocationResponse"
ItemSource="ItemSource">
<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>
@code
{
[Parameter] public NodeResponse Node { get; set; }
private DataGrid<NodeAllocationResponse> Grid;
private ItemSource<NodeAllocationResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<NodeAllocationResponse>> LoadAsync(int startIndex, int count)
{
var query = $"?startIndex={startIndex}&count={count}";
return await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
$"api/admin/servers/nodes/{Node.Id}/allocations{query}"
);
}
private async Task AddAllocationRangeAsync()
{
Func<CreateNodeAllocationRangeRequest, Task> onSubmit = async request =>
{
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations/range", request);
await ToastService.SuccessAsync("Successfully created allocations");
await Grid.RefreshAsync();
};
await ModalService.LaunchAsync<CreateMultipleAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
}
private async Task AddAllocationAsync()
{
Func<CreateNodeAllocationRequest, Task> onSubmit = async request =>
{
await ApiClient.Post($"api/admin/servers/nodes/{Node.Id}/allocations", request);
await ToastService.SuccessAsync("Successfully created allocation");
await Grid.RefreshAsync();
};
await ModalService.LaunchAsync<CreateAllocationModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
}
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.SuccessAsync("Successfully updated allocation");
await Grid.RefreshAsync();
};
await ModalService.LaunchAsync<UpdateAllocationModal>(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
parameters.Add("Allocation", allocation);
});
}
private async Task DeleteAllocationAsync(NodeAllocationResponse allocation)
{
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.SuccessAsync("Successfully deleted allocation");
await Grid.RefreshAsync();
}
);
}
private async Task DeleteAllAllocationsAsync()
{
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.SuccessAsync("Successfully deleted allocations");
await Grid.RefreshAsync();
}
);
}
}

View File

@@ -1,32 +0,0 @@
@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">Name</label>
<div class="mt-2">
<input @bind="Request.Name" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Fqdn</label>
<div class="mt-2">
<input @bind="Request.Fqdn" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Http Port</label>
<div class="mt-2">
<input @bind="Request.HttpPort" type="number" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2"><label class="block text-sm font-medium leading-6 text-base-content">Ftp Port</label>
<div class="mt-2">
<input @bind="Request.FtpPort" type="number" autocomplete="off" class="input w-full">
</div>
</div>
</div>
@code
{
[Parameter] public UpdateNodeRequest Request { get; set; }
}

View File

@@ -1,217 +0,0 @@
@using Microsoft.Extensions.Logging
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Statistics
@inject NodeService NodeService
@inject ToastService ToastService
@inject ILogger<Overview> Logger
@implements IDisposable
<LazyLoader Load="LoadAsync">
<div class="mb-3 mt-5 text-xl font-semibold">
Overview
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-5">
<div class="col-span-1 card card-body">
<div class="flex justify-between">
<p class="text-xl font-semibold text-base-content">
@(Math.Round(Statistics.Cpu.Usage, 2))%
</p>
<i class="icon-cpu text-4xl text-primary"></i>
</div>
<div class="text-base text-base-content/90">
<span class="truncate">
CPU: @Statistics.Cpu.Model
</span>
</div>
</div>
<div class="col-span-1 card card-body">
<div class="flex justify-between">
<p class="text-xl font-semibold text-base-content">
@(Formatter.FormatSize(Statistics.Memory.Total - Statistics.Memory.Available))
/
@(Formatter.FormatSize(Statistics.Memory.Total))
</p>
<i class="icon-memory-stick text-4xl text-primary"></i>
</div>
<div class="text-base text-base-content/90">
Memory
</div>
</div>
<div class="col-span-1 card card-body">
<div class="flex justify-between">
<div class="text-xl font-semibold text-base-content">
@(Formatter.FormatSize(Statistics.Memory.SwapTotal - Statistics.Memory.SwapFree))
/
@(Formatter.FormatSize(Statistics.Memory.SwapTotal))
</div>
<i class="icon-shapes text-4xl text-primary"></i>
</div>
<div class="text-base text-base-content/90">
Swap
</div>
</div>
</div>
<div class="mb-3 mt-5 text-xl font-semibold">
CPU
</div>
<div class="card card-body grid grid-cols-1 lg:grid-cols-2 gap-y-2 gap-x-5">
@{
var i = 0;
}
@foreach (var usage in Statistics.Cpu.UsagePerCore)
{
var percentRounded = Math.Round(usage, 2);
<div class="flex flex-row items-center col-span-1">
<div class="text-sm text-base-content/90 me-1.5 grow-0 flex flex-col">
<span>#@(i)</span>
</div>
<div class="grow">
<div class="progress h-2" role="progressbar">
<div class="progress-bar transition-all duration-300 ease-in-out @(GetBackgroundColorByPercent(percentRounded))" style="width: @(usage)%"></div>
</div>
</div>
</div>
i++;
}
</div>
<div class="mb-3 mt-5 text-xl font-semibold">
Disks
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-5">
@foreach (var disk in Statistics.Disks)
{
var usedPercent = Math.Round((disk.DiskTotal - disk.DiskFree) / (double)disk.DiskTotal * 100, 2);
var iNodesPercent = Math.Round((disk.InodesTotal - disk.InodesFree) / (double)disk.InodesTotal * 100, 2);
<div class="col-span-1 card card-body">
<div class="flex items-center">
<div class="grow">
<div class="progress h-2" role="progressbar">
<div class="progress-bar transition-all duration-300 ease-in-out @(GetBackgroundColorByPercent(usedPercent))" style="width: @(usedPercent)%"></div>
</div>
</div>
</div>
<div class="text-sm text-base-content/90 mt-2.5 flex flex-col">
<div>
Device: <span class="font-semibold">@disk.Device</span> - Mounted at: <span class="font-semibold truncate">@disk.MountPath</span>
</div>
<div>
Used: <span class="font-semibold">@Formatter.FormatSize(disk.DiskTotal - disk.DiskFree)</span>
Total: <span class="font-semibold">@Formatter.FormatSize(disk.DiskTotal)</span>
</div>
<div>
INodes: <span class="font-semibold">@(iNodesPercent)%</span>
</div>
</div>
</div>
}
</div>
<div class="mb-3 mt-5 text-xl font-semibold">
Docker
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-5">
<div class="col-span-1 card card-body">
<div class="flex justify-between">
<p class="text-xl font-semibold text-base-content">
@Formatter.FormatSize(DockerStatistics.ImagesUsed) (@Formatter.FormatSize(DockerStatistics.ImagesReclaimable) unused)
</p>
<i class="icon-gallery-horizontal-end text-4xl text-primary"></i>
</div>
<div class="text-base text-base-content/90">
Images
</div>
</div>
<div class="col-span-1 card card-body">
<div class="flex justify-between">
<p class="text-xl font-semibold text-base-content">
@Formatter.FormatSize(DockerStatistics.ContainersUsed) ( @Formatter.FormatSize(DockerStatistics.ContainersReclaimable) unused)
</p>
<i class="icon-container text-4xl text-primary"></i>
</div>
<div class="text-base text-base-content/90">
Containers
</div>
</div>
<div class="col-span-1 card card-body">
<div class="flex justify-between">
<p class="text-xl font-semibold text-base-content">
@Formatter.FormatSize(DockerStatistics.BuildCacheUsed) (@Formatter.FormatSize(DockerStatistics.BuildCacheReclaimable) unused)
</p>
<i class="icon-hard-hat text-4xl text-primary"></i>
</div>
<div class="text-base text-base-content/90">
Build Cache
</div>
</div>
</div>
</LazyLoader>
@code
{
[Parameter] public NodeResponse Node { get; set; }
private StatisticsResponse Statistics;
private DockerStatisticsResponse DockerStatistics;
private Timer? UpdateTimer;
private async Task LoadAsync(LazyLoader _)
{
Statistics = await NodeService.GetStatisticsAsync(Node.Id);
DockerStatistics = await NodeService.GetDockerStatisticsAsync(Node.Id);
UpdateTimer = new Timer(HandleUpdateAsync, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(3));
}
private async void HandleUpdateAsync(object? _)
{
try
{
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.ErrorAsync("Unable to fetch status update", e.Message);
}
}
private string GetBackgroundColorByPercent(double percent)
{
if (percent < 70)
return "bg-success";
else if (percent < 80)
return "bg-warning";
else
return "bg-error";
}
public void Dispose()
{
UpdateTimer?.Dispose();
}
}

View File

@@ -1,10 +0,0 @@
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
</div>
@code
{
[Parameter] public CreateServerRequest Request { get; set; }
}

View File

@@ -1,42 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@using MoonCore.Blazor.FlyonUi.Forms
@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
<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">Allocations</label>
<div class="mt-2">
<InputMultipleItem TItem="NodeAllocationResponse"
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
Value="Parent.Allocations"
ItemSource="ItemSource">
</InputMultipleItem>
</div>
</div>
</div>
@code
{
[Parameter] public CreateServerRequest Request { get; set; }
[Parameter] public Create Parent { get; set; }
private ItemSource<NodeAllocationResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<NodeAllocationResponse>> LoadAsync(int startIndex, int count)
{
// Handle unselected node
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (Parent.Node == null)
return [];
return await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
$"api/admin/servers/nodes/{Parent.Node.Id}/allocations/free?startIndex={startIndex}&count={count}"
);
}
}

View File

@@ -1,116 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using Moonlight.Shared.Http.Responses.Admin.Users
@using MoonCore.Blazor.FlyonUi.Forms
@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
<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">Name</label>
<div class="mt-2">
<input @bind="Request.Name" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Owner</label>
<div class="mt-2">
<InputItem TItem="UserResponse"
DisplayField="@(x => x.Username)"
ItemSource="UsersItemSource"
@bind-Value="Parent.Owner">
</InputItem>
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Star</label>
<div class="mt-2">
<InputItem TItem="StarResponse"
DisplayField="@(x => x.Name)"
ItemSource="StarsItemSource"
@bind-Value="Parent.Star">
</InputItem>
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Node</label>
<div class="mt-2">
<InputItem TItem="NodeResponse"
DisplayField="@(x => x.Name)"
ItemSource="NodesItemSource"
@bind-Value="Parent.Node">
</InputItem>
</div>
</div>
</div>
<div class="border-t border-base-content/20 pt-6 my-8">
<div class="mb-8">
<h2 class="text-base font-semibold leading-7 text-base-content">
Resources
</h2>
<p class="mt-1 text-sm leading-6 text-base-content/60">Define the servers resource limit</p>
</div>
<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">Cpu</label>
<div class="mt-2">
<input @bind="Request.Cpu" type="number" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Memory</label>
<div class="mt-2">
<input @bind="Request.Memory" type="number" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Disk</label>
<div class="mt-2">
<input @bind="Request.Disk" type="number" autocomplete="off" class="input w-full">
</div>
</div>
</div>
</div>
@code
{
[Parameter] public CreateServerRequest Request { get; set; }
[Parameter] public Create Parent { get; set; }
private ItemSource<StarResponse> StarsItemSource => ItemSourceFactory.From(LoadStarsAsync);
private ItemSource<NodeResponse> NodesItemSource => ItemSourceFactory.From(LoadNodesAsync);
private ItemSource<UserResponse> UsersItemSource => ItemSourceFactory.From(LoadUsersAsync);
private async Task<IEnumerable<StarResponse>> LoadStarsAsync(int startIndex, int count)
{
return await ApiClient.GetJson<CountedData<StarResponse>>(
$"api/admin/servers/stars?startIndex={startIndex}&count={count}"
);
}
private async Task<IEnumerable<NodeResponse>> LoadNodesAsync(int startIndex, int count)
{
return await ApiClient.GetJson<CountedData<NodeResponse>>(
$"api/admin/servers/nodes?startIndex={startIndex}&count={count}"
);
}
private async Task<IEnumerable<UserResponse>> LoadUsersAsync(int startIndex, int count)
{
return await ApiClient.GetJson<CountedData<UserResponse>>(
$"api/admin/users?startIndex={startIndex}&count={count}"
);
}
}

View File

@@ -1,89 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
@using MoonlightServers.Frontend.UI.Views.Admin.All
@using MoonlightServers.Shared.Http.Requests.Admin.ServerVariables
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
@inject HttpApiClient ApiClient
<LazyLoader Load="LoadAsync">
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
@foreach (var variable in StarVariables)
{
// Load value of default
var requestVar = Request.Variables.FirstOrDefault(x => x.Key == variable.Key);
var value = requestVar != null
? requestVar.Value
: variable.DefaultValue;
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">
@variable.Name
</label>
<div class="mt-2">
<input type="text"
class="input placeholder-base-content/50 w-full"
value="@value"
placeholder="@variable.DefaultValue"
@onchange="@(args => UpdateValueAsync(variable, args))"/>
</div>
<p class="mt-1 text-sm leading-6 text-base-content/60">
@variable.Description
</p>
</div>
}
</div>
</LazyLoader>
@code
{
[Parameter] public CreateServerRequest Request { get; set; }
[Parameter] public Create Parent { get; set; }
private StarVariableResponse[] StarVariables;
private async Task LoadAsync(LazyLoader _)
{
if (Parent.Star == null)
{
StarVariables = [];
return;
}
StarVariables = await CountedData.AllAsync(async (index, count) =>
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
$"api/admin/servers/stars/{Parent.Star.Id}/variables?startIndex={index}&count={count}"
)
);
}
private async Task UpdateValueAsync(StarVariableResponse starVariable, ChangeEventArgs args)
{
var value = args.Value?.ToString() ?? "";
// Remove variable from request when set to its default value
if (value == starVariable.DefaultValue && Request.Variables.Any(x => x.Key == starVariable.Key))
Request.Variables.RemoveAll(x => x.Key == starVariable.Key);
else
{
var serverVar = Request.Variables
.FirstOrDefault(x => x.Key == starVariable.Key);
if (serverVar == null)
{
serverVar = new CreateServerVariableRequest()
{
Key = starVariable.Key
};
Request.Variables.Add(serverVar);
}
serverVar.Value = value;
}
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -1,76 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Requests.Client.Servers.Shares
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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>
</div>
@code
{
[Parameter] public ServerDetailResponse Server { get; set; }
[Parameter] public string Username { get; set; }
[Parameter] public Func<CreateShareRequest, Task> OnSubmit { get; set; }
private HandleForm HandleForm;
private CreateShareRequest Request;
private Dictionary<string, ServerPermissionLevel> Permissions = new();
protected override void OnInitialized()
{
Request = new()
{
Username = Username
};
}
private async Task SetAsync(string name, ServerPermissionLevel level)
{
Permissions[name] = level;
await InvokeAsync(StateHasChanged);
}
private async Task SubmitAsync()
=> await HandleForm.SubmitAsync();
private async Task OnValidSubmit()
{
Request.Permissions = Permissions;
await OnSubmit.Invoke(Request);
await HideAsync();
}
}

View File

@@ -1,95 +0,0 @@
@using MoonlightServers.Frontend.Interfaces
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Frontend.Models
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@inject IEnumerable<IServerPermissionProvider> PermissionProviders
<LazyLoader Load="LoadAsync">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-y-3">
@foreach (var permission in AvailablePermissions)
{
var level = PermissionLevels.GetValueOrDefault(permission.Identifier, ServerPermissionLevel.None);
<div class="col-span-1 flex flex-row items-center justify-start text-base-content">
<i class="text-lg @permission.Icon me-4"></i>
<div class="flex flex-col">
<span>@permission.DisplayName</span>
<span class="text-base-content/60 text-sm">@permission.Description</span>
</div>
</div>
<div class="col-span-1 flex justify-start lg:justify-end mb-5 lg:mb-0">
<div class="join drop-shadow">
@if (level == ServerPermissionLevel.None)
{
<input class="join-item btn btn-soft" type="radio" name="share-@permission.Identifier"
aria-label="None"
checked="checked"/>
}
else
{
<input @onclick="() => SetAsync(permission.Identifier, ServerPermissionLevel.None)"
class="join-item btn btn-soft"
type="radio" name="share-@permission.Identifier" aria-label="None"/>
}
@if (level == ServerPermissionLevel.Read)
{
<input class="join-item btn btn-soft" type="radio" name="share-@permission.Identifier"
aria-label="Read"
checked="checked"/>
}
else
{
<input @onclick="() => SetAsync(permission.Identifier, ServerPermissionLevel.Read)"
class="join-item btn btn-soft"
type="radio" name="share-@permission.Identifier" aria-label="Read"/>
}
@if (level == ServerPermissionLevel.ReadWrite)
{
<input class="join-item btn btn-soft" type="radio" name="share-@permission.Identifier"
aria-label="Read & Write"
checked="checked"/>
}
else
{
<input @onclick="() => SetAsync(permission.Identifier, ServerPermissionLevel.ReadWrite)"
class="join-item btn btn-soft"
type="radio" name="share-@permission.Identifier" aria-label="Read & Write"/>
}
</div>
</div>
}
</div>
</LazyLoader>
@code
{
[Parameter] public ServerDetailResponse Server { get; set; }
[Parameter] public Dictionary<string, ServerPermissionLevel> PermissionLevels { get; set; }
private ServerPermission[] AvailablePermissions;
private async Task LoadAsync(LazyLoader _)
{
var permissions = new List<ServerPermission>();
foreach (var provider in PermissionProviders)
{
permissions.AddRange(
await provider.GetPermissionsAsync(Server)
);
}
AvailablePermissions = permissions.ToArray();
}
private async Task SetAsync(string name, ServerPermissionLevel level)
{
PermissionLevels[name] = level;
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -1,189 +0,0 @@
@using Microsoft.Extensions.Logging
@using MoonCore.Helpers
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@inject ServerService ServerService
@inject ILogger<ServerCard> Logger
@{
var gradient = "from-base-100/20";
var border = "border-base-content/80";
if (IsLoaded && !IsFailed)
{
gradient = Status.State switch
{
ServerState.Installing => "from-primary/20",
ServerState.Offline => "from-error/20",
ServerState.Starting => "from-warning/20",
ServerState.Stopping => "from-warning/20",
ServerState.Online => "from-success/20",
_ => "from-base-100"
};
border = Status.State switch
{
ServerState.Installing => "border-primary",
ServerState.Offline => "border-error",
ServerState.Starting => "border-warning",
ServerState.Stopping => "border-warning",
ServerState.Online => "border-success",
_ => "border-base-content/80"
};
}
}
<a href="/servers/@Server.Id"
class="w-full bg-gradient-to-r @gradient to-base-100/75 to-25% px-5 py-3.5 rounded-xl border-l-8 @border">
<div class="grid grid-cols-6">
<div class="flex items-center col-span-6 sm:col-span-2 2xl:col-span-1">
<div class="bg-base-content/10 bg-opacity-45 py-1 px-2 rounded-lg flex items-center">
<i class="icon-server me-3 align-middle"></i>
<div class="text-lg align-middle">
@Server.Name
</div>
</div>
</div>
<div class="hidden sm:flex items-center justify-end gap-x-3 sm:col-span-4 2xl:col-span-3">
@if (
IsLoaded &&
!IsFailed &&
Status.State is ServerState.Starting or ServerState.Stopping or ServerState.Online
)
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-cpu"></i>
</div>
<div class="ms-3">@(Stats.CpuUsage)%</div>
</div>
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-memory-stick"></i>
</div>
<div class="ms-3">@(Formatter.FormatSize(Stats.MemoryUsage)) / @(Formatter.FormatSize(ByteConverter.FromMegaBytes(Server.Memory).Bytes))</div>
</div>
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-hard-drive"></i>
</div>
<div class="ms-3">53 GB / 100GB</div>
</div>
}
else
{
if (!IsLoaded)
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row text-gray-700">
<div>
<i class="icon-loader"></i>
</div>
<div class="ms-3">Loading</div>
</div>
}
else if (IsFailed)
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row text-error">
<div>
<i class="icon-cable"></i>
</div>
<div class="ms-3">Unreachable</div>
</div>
}
else if (IsLoaded && !IsFailed && Status.State is ServerState.Offline)
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row text-error">
<div>
<i class="icon-power-off"></i>
</div>
<div class="ms-3">Offline</div>
</div>
}
else if (IsLoaded && !IsFailed && Status.State is ServerState.Installing)
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row text-primary">
<div>
<i class="icon-hammer"></i>
</div>
<div class="ms-3">Installing</div>
</div>
}
}
</div>
<div class="hidden 2xl:flex items-center justify-end gap-x-3 2xl:col-span-2">
@if (Server.Share != null)
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row col-span-2">
<div>
<i class="icon-share-2"></i>
</div>
<div class="ms-3">Shared by <span class="text-primary">@Server.Share.SharedBy</span></div>
</div>
}
else
{
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-sparkles"></i>
</div>
<div class="ms-3">@Server.StarName</div>
</div>
<div class="bg-base-200/75 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-database"></i>
</div>
<div class="ms-3">@Server.NodeName</div>
</div>
}
</div>
</div>
</a>
@code
{
[Parameter] public ServerDetailResponse Server { get; set; }
private ServerStatusResponse Status;
private ServerStatsResponse Stats;
private bool IsFailed = false;
private bool IsLoaded = false;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
try
{
Status = await ServerService.GetStatusAsync(Server.Id);
Stats = await ServerService.GetStatsAsync(Server.Id);
}
catch (Exception e)
{
IsFailed = true;
Logger.LogWarning("Unable to fetch status from server {id}: {e}", Server.Id, e);
}
IsLoaded = true;
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -1,13 +0,0 @@
@using Microsoft.AspNetCore.SignalR.Client
@using MoonlightServers.Frontend.UI.Views.Client
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@code
{
[Parameter] public ServerDetailResponse Server { get; set; }
[Parameter] public ServerState State { get; set; }
[Parameter] public string InitialConsoleMessage { get; set; }
[Parameter] public HubConnection? HubConnection { get; set; }
[Parameter] public Manage Parent { get; set; }
}

View File

@@ -1,39 +0,0 @@
@using Microsoft.AspNetCore.SignalR.Client
@using MoonlightServers.Frontend.Services
@inherits BaseServerTab
@inject ServerService ServerService
<div class="h-44">
<XtermConsole @ref="XtermConsole"
OnAfterInitialized="OnAfterConsoleInitialized"
CommandHistory="Parent.CommandHistory"
OnCommand="OnCommand"/>
</div>
@code
{
private XtermConsole? XtermConsole;
protected override Task OnInitializedAsync()
{
// We are already connected to the hub at this point
HubConnection.On<string>("ConsoleOutput", async content =>
{
if (XtermConsole != null)
await XtermConsole.WriteAsync(content);
});
return Task.CompletedTask;
}
private async Task OnAfterConsoleInitialized()
{
await XtermConsole!.WriteAsync(InitialConsoleMessage);
}
private async Task OnCommand(string command)
=> await ServerService.RunCommandAsync(Server.Id, command + "\n");
}

View File

@@ -1,22 +0,0 @@
@using MoonlightServers.Frontend.Services
@using MoonCore.Blazor.FlyonUi.Files.Manager
@using MoonlightServers.Frontend.Helpers
@inherits BaseServerTab
@inject ServerFileSystemService FileSystemService
<FileManager FsAccess="FsAccess" />
@code
{
private IFsAccess FsAccess;
protected override void OnInitialized()
{
FsAccess = new ServerFsAccess(
Server.Id,
FileSystemService
);
}
}

View File

@@ -1,40 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Enums
@inherits BaseServerTab
@inject ServerService ServerService
@inject AlertService AlertService
<div class="grid grid-cols-1 md:col-span-2 lg:grid-cols-3">
<div class="col-span-1 card card-body">
@if (State != ServerState.Offline)
{
<button class="btn btn-primary" disabled="disabled">
<i class="align-middle icon-hammer me-1"></i>
<span class="align-middle">Reinstall</span>
</button>
}
else
{
<WButton CssClasses="btn btn-primary" OnClick="ReinstallAsync">
<i class="align-middle icon-hammer"></i>
<span class="align-middle">Reinstall</span>
</WButton>
}
</div>
</div>
@code
{
private async Task ReinstallAsync(WButton _)
{
await AlertService.ConfirmDangerAsync(
"Server installation",
"Do you really want to reinstall the server? This can potentially lead to loss of data",
() => ServerService.InstallAsync(Server.Id)
);
}
}

View File

@@ -1,123 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Common
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Requests.Client.Servers.Shares
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Shares
@inherits BaseServerTab
@inject ServerShareService ShareService
@inject ModalService ModalService
@inject ToastService ToastService
@inject AlertService AlertService
<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="OpenCreateModalAsync" class="btn btn-primary">
<i class="icon-send me-1"></i>
<span>Invite</span>
</button>
</div>
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
@if (Shares.Length == 0)
{
<IconAlert Title="No shares found" Color="text-primary" Icon="icon-search">
Enter a username and press invite to share this server to another user
</IconAlert>
}
else
{
<div class="grid grid-col-1 gap-y-3">
@foreach (var share in Shares)
{
<div class="col-span-1 card card-body py-3 flex flex-row items-center justify-between">
<div class="flex justify-start font-semibold">
<i class="icon-user-round me-2"></i>
<span>@share.Username</span>
</div>
<div class="flex justify-end">
<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="_ => DeleteAsync(share)" CssClasses="btn btn-error">
<i class="icon-trash-2 me-1"></i>
<span>Delete</span>
</WButton>
</div>
</div>
}
</div>
}
</LazyLoader>
@code
{
private ServerShareResponse[] Shares;
private string UsernameInput = "";
private LazyLoader LazyLoader;
private async Task LoadAsync(LazyLoader _)
{
Shares = await CountedData.AllAsync<ServerShareResponse>(async (startIndex, count)
=> await ShareService.GetAsync(Server.Id, startIndex, count)
);
}
private async Task OpenCreateModalAsync()
{
await ModalService.LaunchAsync<CreateShareModal>(parameters =>
{
parameters["Username"] = UsernameInput;
parameters["Server"] = Server;
parameters["OnSubmit"] = SubmitCreateAsync;
}, size: "max-w-2xl");
}
private async Task SubmitCreateAsync(CreateShareRequest request)
{
await ShareService.CreateAsync(Server.Id, request);
await ToastService.SuccessAsync("Share successfully created");
await LazyLoader.ReloadAsync();
}
private async Task OpenUpdateModalAsync(ServerShareResponse share)
{
await ModalService.LaunchAsync<UpdateShareModal>(parameters =>
{
parameters["Share"] = share;
parameters["Server"] = Server;
parameters["OnSubmit"] = (UpdateShareRequest request) => SubmitUpdateAsync(share.Id, request);
}, size: "max-w-2xl");
}
private async Task SubmitUpdateAsync(int shareId, UpdateShareRequest request)
{
await ShareService.UpdateAsync(Server.Id, shareId, request);
await ToastService.SuccessAsync("Share successfully updated");
await LazyLoader.ReloadAsync();
}
private async Task DeleteAsync(ServerShareResponse share)
{
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.DeleteAsync(Server.Id, share.Id);
await ToastService.SuccessAsync("Successfully deleted share");
await LazyLoader.ReloadAsync();
}
);
}
}

View File

@@ -1,65 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Common
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Variables
@inherits BaseServerTab
@inject ServerService ServerService
@inject ToastService ToastService
<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)
{
<div class="sm:col-span-2 card card-sm">
<div class="card-header pb-1">
<h5 class="text-base font-semibold">
@variable.Name
</h5>
</div>
<div class="card-body">
<p class="mb-2.5 text-sm leading-6 text-base-content/60">
@variable.Description
</p>
<div class="mt-auto">
<input @onchange="e => UpdateVariableAsync(variable, e)"
value="@variable.Value"
type="text"
class="input w-full">
</div>
</div>
</div>
}
</div>
</LazyLoader>
@code
{
private ServerVariableDetailResponse[] Variables;
private LazyLoader LazyLoader;
private async Task LoadAsync(LazyLoader _)
{
Variables = await CountedData.AllAsync<ServerVariableDetailResponse>(async (startIndex, count)
=> await ServerService.GetVariablesAsync(Server.Id, startIndex, count)
);
}
private async Task UpdateVariableAsync(ServerVariableDetailResponse variable, ChangeEventArgs args)
{
var value = args.Value?.ToString() ?? "";
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.ReloadAsync();
await ToastService.SuccessAsync("Successfully updated variable");
}
}

View File

@@ -1,125 +0,0 @@
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@{
var gradient = Status switch
{
4 => "from-primary/20",
3 => "from-danger/20",
2 => "from-warning/20",
1 => "from-success/20",
_ => "from-gray-600/20"
};
var border = Status switch
{
4 => "border-primary",
3 => "border-danger",
2 => "border-warning",
1 => "border-success",
_ => "border-gray-600"
};
}
<a href="/servers/@Server.Id" class="w-full bg-gradient-to-r @gradient to-gray-750/65 to-25% px-5 py-3.5 rounded-xl border-l-8 @border">
<div class="grid grid-cols-6">
<div class="flex items-center col-span-6 sm:col-span-2 2xl:col-span-1">
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex items-center">
<i class="icon-server me-3 align-middle"></i>
<div class="text-lg align-middle">
@Server.Name
</div>
</div>
</div>
<div class="hidden sm:flex items-center justify-end gap-x-3 sm:col-span-4 2xl:col-span-3">
@if (Status >= 1 && Status <= 2)
{
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-cpu"></i>
</div>
<div class="ms-3">56,8%</div>
</div>
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-memory-stick"></i>
</div>
<div class="ms-3">4,2 GB / 8 GB</div>
</div>
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-hard-drive"></i>
</div>
<div class="ms-3">53 GB / 100GB</div>
</div>
}
else
{
if (Status == 0)
{
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row text-gray-700">
<div>
<i class="icon-loader"></i>
</div>
<div class="ms-3">Loading</div>
</div>
}
else if (Status == 3)
{
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row text-error">
<div>
<i class="icon-power-off"></i>
</div>
<div class="ms-3">Offline</div>
</div>
}
else if (Status == 4)
{
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row text-primary">
<div>
<i class="icon-hammer"></i>
</div>
<div class="ms-3">Installing</div>
</div>
}
}
</div>
<div class="hidden 2xl:flex items-center justify-end gap-x-3 2xl:col-span-2">
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-sparkles"></i>
</div>
<div class="ms-3">@Server.StarName</div>
</div>
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex flex-row">
<div>
<i class="icon-database"></i>
</div>
<div class="ms-3">@Server.NodeName</div>
</div>
</div>
</div>
</a>
@code
{
[Parameter]
public ServerDetailResponse Server { get; set; }
[Parameter]
public int Status { get; set; }
}

View File

@@ -1,9 +0,0 @@
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
</div>
@code
{
[Parameter] public UpdateServerRequest Request { get; set; }
}

View File

@@ -1,39 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
@using MoonCore.Blazor.FlyonUi.Forms
@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
<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">Allocations</label>
<div class="mt-2">
<InputMultipleItem TItem="NodeAllocationResponse"
Value="Parent.Allocations"
DisplayField="@(x => $"{x.IpAddress}:{x.Port}")"
ItemSource="ItemSource">
</InputMultipleItem>
</div>
</div>
</div>
@code
{
[Parameter] public UpdateServerRequest Request { get; set; }
[Parameter] public ServerResponse Server { get; set; }
[Parameter] public Update Parent { get; set; }
private ItemSource<NodeAllocationResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<NodeAllocationResponse>> LoadAsync(int startIndex, int count)
{
return await ApiClient.GetJson<CountedData<NodeAllocationResponse>>(
$"api/admin/servers/nodes/{Server.NodeId}/allocations/free?startIndex={startIndex}&count={count}&serverId={Server.Id}"
);
}
}

View File

@@ -1,75 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
@using Moonlight.Shared.Http.Responses.Admin.Users
@using MoonCore.Blazor.FlyonUi.Forms
@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Views.Admin.All
@inject HttpApiClient ApiClient
<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">Name</label>
<div class="mt-2">
<input @bind="Request.Name" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Owner</label>
<div class="mt-2">
<InputItem TItem="UserResponse"
DisplayField="@(x => x.Username)"
@bind-Value="Parent.Owner"
ItemSource="UserItemSource">
</InputItem>
</div>
</div>
</div>
<div class="border-t border-base-content/10 pt-6 my-8">
<div class="mb-8"><h2 class="text-base font-semibold leading-7 text-base-content">
Resources
</h2>
<p class="mt-1 text-sm leading-6 text-base-content/60">Define the servers resource limit</p></div>
<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">Cpu</label>
<div class="mt-2">
<input @bind="Request.Cpu" type="number" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Memory</label>
<div class="mt-2">
<input @bind="Request.Memory" type="number" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Disk</label>
<div class="mt-2">
<input @bind="Request.Disk" type="number" autocomplete="off" class="input w-full">
</div>
</div>
</div>
</div>
@code
{
[Parameter] public UpdateServerRequest Request { get; set; }
[Parameter] public Update Parent { get; set; }
private ItemSource<UserResponse> UserItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<UserResponse>> LoadAsync(int startIndex, int count)
{
return await ApiClient.GetJson<CountedData<UserResponse>>(
$"api/admin/users?startIndex={startIndex}&count={count}"
);
}
}

View File

@@ -1,93 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Common
@using MoonlightServers.Shared.Http.Requests.Admin.Servers
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Requests.Admin.ServerVariables
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
@using MoonlightServers.Shared.Http.Responses.Admin.ServerVariables
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
@inject HttpApiClient ApiClient
<LazyLoader Load="LoadAsync">
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
@foreach (var variable in ServerVariables)
{
var reqVariable = Request.Variables.FirstOrDefault(x => x.Key == variable.Key);
var starVariable = StarVariables.FirstOrDefault(x => x.Key == variable.Key);
// Ignore all variables which aren't defined in the star
if (starVariable == null)
continue;
var value = reqVariable != null
? reqVariable.Value
: variable.Value;
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">
@starVariable.Name
</label>
<div class="mt-2">
<input type="text" class="input w-full" value="@value"
@onchange="@(args => UpdateValueAsync(variable, args))"/>
</div>
<p class="mt-1 text-sm leading-6 text-base-content/60">
@starVariable.Description
</p>
</div>
}
</div>
</LazyLoader>
@code
{
[Parameter] public UpdateServerRequest Request { get; set; }
[Parameter] public ServerResponse Server { get; set; }
private StarVariableResponse[] StarVariables;
private ServerVariableResponse[] ServerVariables;
private async Task LoadAsync(LazyLoader _)
{
StarVariables = await CountedData.AllAsync<StarVariableResponse>(async (startIndex, count) =>
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
$"api/admin/servers/stars/{Server.StarId}/variables?startIndex={startIndex}&count={count}"
)
);
ServerVariables = await CountedData.AllAsync<ServerVariableResponse>(async (startIndex, count) =>
await ApiClient.GetJson<CountedData<ServerVariableResponse>>(
$"api/admin/servers/{Server.Id}/variables?startIndex={startIndex}&count={count}"
)
);
}
private async Task UpdateValueAsync(ServerVariableResponse serverVariable, ChangeEventArgs args)
{
var value = args.Value?.ToString() ?? "";
// Remove variable from request when set to its default value
if (value == serverVariable.Value && Request.Variables.Any(x => x.Key == serverVariable.Key))
Request.Variables.RemoveAll(x => x.Key == serverVariable.Key);
else
{
var serverVar = Request.Variables
.FirstOrDefault(x => x.Key == serverVariable.Key);
if (serverVar == null)
{
serverVar = new UpdateServerVariableRequest()
{
Key = serverVariable.Key
};
Request.Variables.Add(serverVar);
}
serverVar.Value = value;
}
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -1,70 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Requests.Client.Servers.Shares
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@using MoonlightServers.Shared.Http.Responses.Client.Servers.Shares
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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
{
[Parameter] public ServerDetailResponse Server { get; set; }
[Parameter] public ServerShareResponse Share { get; set; }
[Parameter] public Func<UpdateShareRequest, Task> OnSubmit { get; set; }
private HandleForm HandleForm;
private UpdateShareRequest Request;
private Dictionary<string, ServerPermissionLevel> Permissions = new();
protected override void OnInitialized()
{
Request = new();
Permissions = Share.Permissions;
}
private async Task SetAsync(string name, ServerPermissionLevel level)
{
Permissions[name] = level;
await InvokeAsync(StateHasChanged);
}
private async Task SubmitAsync()
=> await HandleForm.SubmitAsync();
private async Task OnValidSubmit()
{
Request.Permissions = Permissions;
await OnSubmit.Invoke(Request);
await HideAsync();
}
}

View File

@@ -1,68 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Frontend.UI.Components.Forms
@using MoonlightServers.Shared.Http.Requests.Admin.StarDockerImages
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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
{
[Parameter] public Func<CreateStarDockerImageRequest, Task> OnSubmit { get; set; }
private CreateStarDockerImageRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
// Set default values
Form = new()
{
AutoPulling = true
};
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,86 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Models
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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="() => RemoveEntryAsync(entry)" class="btn btn-error grow-0 rounded-l-none">
<i class="icon-x"></i>
</button>
</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
{
[Parameter] public Func<ParseConfiguration, Task> OnSubmit { get; set; }
private ParseConfiguration Form = new();
private HandleForm HandleForm;
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
private async Task AddEntryAsync()
{
Form.Entries.Add(new());
await InvokeAsync(StateHasChanged);
}
private async Task RemoveEntryAsync(ParseConfiguration.ParseConfigurationEntry entry)
{
Form.Entries.Remove(entry);
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -1,94 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
@using MoonlightServers.Frontend.UI.Components.Forms
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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="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
{
[Parameter] public Func<CreateStarVariableRequest, Task> OnSubmit { get; set; }
private CreateStarVariableRequest Form = new();
private HandleForm HandleForm;
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,71 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Frontend.UI.Components.Forms
@using MoonlightServers.Shared.Http.Requests.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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
{
[Parameter] public Func<UpdateStarDockerImageRequest, Task> OnSubmit { get; set; }
[Parameter] public StarDockerImageResponse DockerImage { get; set; }
private UpdateStarDockerImageRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
Form = new UpdateStarDockerImageRequest()
{
AutoPulling = DockerImage.AutoPulling,
DisplayName = DockerImage.DisplayName,
Identifier = DockerImage.Identifier
};
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,93 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Models
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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="() => RemoveEntryAsync(entry)" class="btn btn-error grow-0 rounded-l-none">
<i class="icon-x"></i>
</button>
</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
{
[Parameter] public Func<ParseConfiguration, Task> OnSubmit { get; set; }
[Parameter] public ParseConfiguration Configuration { get; set; }
private ParseConfiguration Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
// Manual mapping :(
Form = Configuration;
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
private async Task AddEntryAsync()
{
Form.Entries.Add(new());
await InvokeAsync(StateHasChanged);
}
private async Task RemoveEntryAsync(ParseConfiguration.ParseConfigurationEntry entry)
{
Form.Entries.Remove(entry);
await InvokeAsync(StateHasChanged);
}
}

View File

@@ -1,111 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
@using MoonlightServers.Frontend.UI.Components.Forms
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
@inherits MoonCore.Blazor.FlyonUi.Modals.BaseModal
<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="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>
<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="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
{
[Parameter] public Func<UpdateStarVariableRequest, Task> OnSubmit { get; set; }
[Parameter] public StarVariableResponse Variable { get; set; }
private UpdateStarVariableRequest Form;
private HandleForm HandleForm;
protected override void OnInitialized()
{
Form = new()
{
Name = Variable.Name,
AllowEditing = Variable.AllowEditing,
AllowViewing = Variable.AllowViewing,
DefaultValue = Variable.DefaultValue,
Description = Variable.Description,
Filter = Variable.Filter,
Key = Variable.Key,
Type = Variable.Type
};
}
private async Task OnValidSubmit()
{
await OnSubmit.Invoke(Form);
await HideAsync();
}
private Task SubmitAsync() => HandleForm.SubmitAsync();
}

View File

@@ -1,109 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Common
@using MoonCore.Helpers
@using MoonlightServers.Frontend.UI.Components.Stars.Modals
@using MoonlightServers.Shared.Http.Requests.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@inject HttpApiClient ApiClient
@inject ModalService ModalService
@inject ToastService ToastService
@inject AlertService AlertService
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
<div class="flex justify-end">
<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">
@foreach (var dockerImage in DockerImages)
{
<div class="col-span-1 card card-body p-2.5">
<div class="flex items-center justify-between">
<div class="ml-3">
<i class="icon-container text-xl align-middle mr-2"></i>
<span class="align-middle text-lg">@dockerImage.DisplayName</span>
</div>
<div class="gap-x-2">
<button type="button" @onclick="() => UpdateDockerImageAsync(dockerImage)"
class="btn btn-primary">
<i class="icon-settings text-base"></i>
</button>
<button type="button" @onclick="() => DeleteDockerImageAsync(dockerImage)"
class="btn btn-error">
<i class="icon-trash text-base"></i>
</button>
</div>
</div>
</div>
}
</div>
</LazyLoader>
@code
{
[Parameter] public StarResponse Star { get; set; }
private StarDockerImageResponse[] DockerImages;
private LazyLoader LazyLoader;
private async Task LoadAsync(LazyLoader _)
{
DockerImages = await CountedData.AllAsync<StarDockerImageResponse>(async (startIndex, count) =>
await ApiClient.GetJson<CountedData<StarDockerImageResponse>>(
$"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex={startIndex}&count={count}"
)
);
}
private async Task AddDockerImageAsync()
{
Func<CreateStarDockerImageRequest, Task> onSubmit = async request =>
{
await ApiClient.Post($"api/admin/servers/stars/{Star.Id}/dockerImages", request);
await ToastService.SuccessAsync("Successfully created docker image");
await LazyLoader.ReloadAsync();
};
await ModalService.LaunchAsync<CreateDockerImageModal>(parameters => { parameters.Add("OnSubmit", onSubmit); });
}
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.SuccessAsync("Successfully updated docker image");
await LazyLoader.ReloadAsync();
};
await ModalService.LaunchAsync<UpdateDockerImageModal>(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
parameters.Add("DockerImage", dockerImage);
});
}
private async Task DeleteDockerImageAsync(StarDockerImageResponse dockerImage)
{
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.SuccessAsync("Successfully deleted docker image");
await LazyLoader.ReloadAsync();
}
);
}
}

View File

@@ -1,41 +0,0 @@
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
<div>
<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">Name</label>
<div class="mt-2">
<input @bind="Request.Name" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Version</label>
<div class="mt-2">
<input @bind="Request.Version" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Author</label>
<div class="mt-2">
<input @bind="Request.Author" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Donate Url</label>
<div class="mt-2">
<input @bind="Request.DonateUrl" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Update Url</label>
<div class="mt-2">
<input @bind="Request.UpdateUrl" type="text" autocomplete="off" class="input w-full">
</div>
</div>
</div>
</div>
@code
{
[Parameter] public UpdateStarRequest Request { get; set; }
}

View File

@@ -1,42 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Ace
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
<div>
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
<div class="sm:col-span-3">
<label class="block text-sm font-medium leading-6 text-base-content">Docker Image</label>
<div class="mt-2">
<input @bind="Request.InstallDockerImage" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-3">
<label class="block text-sm font-medium leading-6 text-base-content">Shell</label>
<div class="mt-2">
<input @bind="Request.InstallShell" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-6">
<label class="block text-sm font-medium leading-6 text-base-content">Script</label>
<div class="mt-2" @onfocusout="OnFocusOut">
<CodeEditor @ref="CodeEditor" InitialContent="@Request.InstallScript" OnConfigure="OnConfigure" />
</div>
</div>
</div>
</div>
@code
{
[Parameter] public UpdateStarRequest Request { get; set; }
private CodeEditor CodeEditor;
private void OnConfigure(CodeEditorOptions options)
{
options.Mode = "ace/mode/sh";
}
private async Task OnFocusOut()
{
Request.InstallScript = await CodeEditor.GetValueAsync();
}
}

View File

@@ -1,69 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Common
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
@using MoonlightServers.Shared.Http.Responses.Admin.StarDockerImages
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using MoonlightServers.Frontend.UI.Components.Forms
@inject HttpApiClient ApiClient
<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">
<label class="block text-sm font-medium leading-6 text-base-content">Allow docker image change</label>
<div class="mt-2">
<Switch @bind-Value="Request.AllowDockerImageChange" />
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Default docker image</label>
<div class="mt-2">
<select @bind="Request.DefaultDockerImage" class="select w-full">
@foreach (var dockerImage in DockerImages)
{
var index = DockerImages.IndexOf(dockerImage);
if (Request.DefaultDockerImage == index)
{
<option selected="selected"
value="@index">
@dockerImage.DisplayName
</option>
}
else
{
<option value="@index">
@dockerImage.DisplayName
</option>
}
}
</select>
</div>
</div>
</div>
</div>
</LazyLoader>
@code
{
[Parameter] public UpdateStarRequest Request { get; set; }
[Parameter] public StarResponse Star { get; set; }
private List<StarDockerImageResponse> DockerImages;
private async Task LoadAsync(LazyLoader _)
{
var pagedVariables = await ApiClient.GetJson<CountedData<StarDockerImageResponse>>(
$"api/admin/servers/stars/{Star.Id}/dockerImages?startIndex=0&count=100"
);
// TODO: Fix this
DockerImages = pagedVariables
.Items
.OrderBy(x => x.Id) // Make sure its in the correct order every time
.ToList();
}
}

View File

@@ -1,134 +0,0 @@
@using System.Text.Json
@using Microsoft.Extensions.Logging
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonlightServers.Frontend.UI.Components.Stars.Modals
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
@using MoonlightServers.Shared.Models
@inject ILogger<ParseConfig> Logger
@inject ModalService ModalService
@inject AlertService AlertService
@inject ToastService ToastService
<div class="flex justify-end mb-5">
<button type="button" @onclick="AddConfigAsync" class="btn btn-primary">Add parse configuration</button>
</div>
@if (HasParseError)
{
}
else
{
<div class="grid sm:grid-cols-2 xl:grid-cols-3 gap-4">
@foreach (var configuration in Configurations)
{
<div class="col-span-1 card card-body p-2.5">
<div class="flex items-center justify-between">
<div class="ml-3">
<i class="icon-file-cog text-xl align-middle mr-2"></i>
<span class="align-middle text-lg">@configuration.File</span>
</div>
<div class="gap-x-2">
<button type="button" @onclick="() => UpdateConfigAsync(configuration)" class="btn btn-primary">
<i class="icon-settings text-base"></i>
</button>
<button type="button" @onclick="() => DeleteConfigAsync(configuration)" class="btn btn-error">
<i class="icon-trash text-base"></i>
</button>
</div>
</div>
</div>
}
</div>
}
@code
{
[Parameter] public UpdateStarRequest Request { get; set; }
private List<ParseConfiguration> Configurations;
private bool HasParseError = false;
protected override Task OnInitializedAsync()
{
ReadFromJson();
return Task.CompletedTask;
}
private async Task AddConfigAsync()
{
Func<ParseConfiguration, Task> onSubmit = async configuration =>
{
Configurations.Add(configuration);
SaveChanges();
await InvokeAsync(StateHasChanged);
await ToastService.SuccessAsync("Successfully created parse configuration");
};
await ModalService.LaunchAsync<CreateParseConfigModal>(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
}, "max-w-xl");
}
private async Task UpdateConfigAsync(ParseConfiguration configuration)
{
Func<ParseConfiguration, Task> onSubmit = async _ =>
{
SaveChanges();
await InvokeAsync(StateHasChanged);
await ToastService.SuccessAsync("Successfully updated parse configuration");
};
await ModalService.LaunchAsync<UpdateParseConfigModal>(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
parameters.Add("Configuration", configuration);
}, "max-w-xl");
}
private async Task DeleteConfigAsync(ParseConfiguration configuration)
{
await AlertService.ConfirmDangerAsync(
"Parse configuration deletion",
"Do you really want to delete the selected parse configuration",
async () =>
{
Configurations.Remove(configuration);
SaveChanges();
await InvokeAsync(StateHasChanged);
await ToastService.SuccessAsync("Successfully deleted parse configuration");
}
);
}
private void SaveChanges()
{
Request.ParseConfiguration = JsonSerializer.Serialize(Configurations);
ReadFromJson();
}
private void ReadFromJson()
{
try
{
Configurations = JsonSerializer.Deserialize<List<ParseConfiguration>>(Request.ParseConfiguration)
?? throw new ArgumentNullException();
HasParseError = false;
}
catch (Exception e)
{
Logger.LogWarning("An error occured while reading parse configuration: {e}", e);
HasParseError = true;
}
}
}

View File

@@ -1,28 +0,0 @@
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
<div>
<div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
<div class="sm:col-span-4">
<label class="block text-sm font-medium leading-6 text-base-content">Startup Command</label>
<div class="mt-2">
<input @bind="Request.StartupCommand" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Stop Command</label>
<div class="mt-2">
<input @bind="Request.StopCommand" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Online Detection</label>
<div class="mt-2">
<input @bind="Request.OnlineDetection" type="text" autocomplete="off" class="input w-full">
</div>
</div>
</div>
</div>
@code
{
[Parameter] public UpdateStarRequest Request { get; set; }
}

View File

@@ -1,107 +0,0 @@
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Common
@using MoonCore.Helpers
@using MoonlightServers.Frontend.UI.Components.Stars.Modals
@using MoonlightServers.Shared.Http.Requests.Admin.StarVariables
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using MoonlightServers.Shared.Http.Responses.Admin.StarVariables
@inject HttpApiClient ApiClient
@inject ModalService ModalService
@inject AlertService AlertService
@inject ToastService ToastService
<div class="flex justify-end mb-5">
<button type="button" @onclick="AddVariableAsync" class="btn btn-primary">Add variable</button>
</div>
<LazyLoader @ref="LazyLoader" Load="LoadAsync">
<div class="grid sm:grid-cols-2 xl:grid-cols-3 gap-4">
@foreach (var variable in CurrentVariables)
{
<div class="col-span-1 card card-body p-2.5">
<div class="flex items-center justify-between">
<div class="ml-3">
<i class="icon-variable text-xl align-middle mr-2"></i>
<span class="align-middle text-lg">@variable.Name</span>
</div>
<div class="gap-x-2">
<button type="button" @onclick="() => UpdateVariableAsync(variable)" class="btn btn-primary">
<i class="icon-settings text-base"></i>
</button>
<button type="button" @onclick="() => DeleteVariableAsync(variable)" class="btn btn-error">
<i class="icon-trash text-base"></i>
</button>
</div>
</div>
</div>
}
</div>
</LazyLoader>
@code
{
[Parameter] public StarResponse Star { get; set; }
private StarVariableResponse[] CurrentVariables;
private LazyLoader LazyLoader;
private async Task LoadAsync(LazyLoader arg)
{
CurrentVariables = await CountedData.AllAsync<StarVariableResponse>(async (startIndex, count) =>
await ApiClient.GetJson<CountedData<StarVariableResponse>>(
$"api/admin/servers/stars/{Star.Id}/variables?startIndex={startIndex}&count={count}"
)
);
}
private async Task AddVariableAsync()
{
Func<CreateStarVariableRequest, Task> onSubmit = async request =>
{
await ApiClient.Post($"api/admin/servers/stars/{Star.Id}/variables", request);
await ToastService.SuccessAsync("Successfully created variable");
await LazyLoader.ReloadAsync();
};
await ModalService.LaunchAsync<CreateVariableModal>(parameters => { parameters.Add("OnSubmit", onSubmit); }, "max-w-xl");
}
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.SuccessAsync("Successfully updated variable");
await LazyLoader.ReloadAsync();
};
await ModalService.LaunchAsync<UpdateVariableModal>(parameters =>
{
parameters.Add("OnSubmit", onSubmit);
parameters.Add("Variable", variable);
}, "max-w-xl");
}
private async Task DeleteVariableAsync(StarVariableResponse variable)
{
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.SuccessAsync("Successfully deleted variable");
await LazyLoader.ReloadAsync();
}
);
}
}

View File

@@ -1,237 +0,0 @@
@using Microsoft.Extensions.Logging
@using MoonCore.Blazor.FlyonUi.Modals
@using MoonCore.Helpers
@using XtermBlazor
@using MoonCore.Blazor.FlyonUi.Components
@inject IJSRuntime JsRuntime
@inject ModalService ModalService
@inject ILogger<XtermConsole> Logger
@implements IAsyncDisposable
<div class="bg-black rounded-lg p-2 relative">
@if (IsInitialized)
{
<Xterm @ref="Terminal"
Addons="Addons"
Options="Options"
Class="h-full w-full"
OnFirstRender="HandleFirstRenderAsync"/>
}
<div class="flex flex-row w-full mt-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>
<div class="absolute top-4 right-4">
<div class="flex flex-col gap-y-1.5">
@if (IsPaused)
{
<button @onclick="TogglePauseAsync" class="btn btn-primary btn-square">
<i class="icon-play text-lg"></i>
</button>
}
else
{
<button @onclick="TogglePauseAsync" class="btn btn-secondary btn-square">
<i class="icon-pause text-lg"></i>
</button>
}
<button @onclick="OpenFullscreenAsync" class="btn btn-secondary btn-square">
<i class="icon-maximize text-lg"></i>
</button>
</div>
</div>
</div>
@code
{
[Parameter] public Func<Task>? OnAfterInitialized { get; set; }
[Parameter] public Func<Task>? OnFirstRender { get; set; }
[Parameter] public bool ShowActions { get; set; } = true;
[Parameter] public bool ShowInput { get; set; } = false;
[Parameter] public int MaxOutputCacheSize { get; set; } = 250;
[Parameter] public Func<string, Task>? OnCommand { get; set; }
[Parameter] public IList<string> CommandHistory { get; set; } = new ConcurrentList<string>();
public event Func<string, Task>? OnWrite;
private Xterm Terminal;
public HashSet<string> Addons { get; } = ["addon-fit"];
public TerminalOptions Options { get; } = new()
{
CursorBlink = false,
CursorStyle = CursorStyle.Bar,
CursorWidth = 1,
FontFamily = "Space Mono, monospace",
DisableStdin = true,
CursorInactiveStyle = CursorInactiveStyle.None,
Theme =
{
Background = "#000000"
},
};
public ConcurrentList<string> OutputCache { get; private set; } = new();
public ConcurrentList<string> WriteQueue { get; private set; } = new();
private int CommandIndex = -1;
private bool IsReadyToWrite = false;
private bool IsPaused = false;
private bool IsInitialized = false;
private string CommandInput = "";
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
try
{
await JsRuntime.InvokeVoidAsync("moonlightServers.loadAddons");
}
catch (Exception e)
{
Logger.LogError("An error occured while initializing addons: {e}", e);
}
IsInitialized = true;
await InvokeAsync(StateHasChanged);
if (OnAfterInitialized != null)
await OnAfterInitialized.Invoke();
}
private async Task HandleFirstRenderAsync()
{
try
{
await Terminal.Addon("addon-fit").InvokeVoidAsync("fit");
}
catch (Exception e)
{
Logger.LogError("An error occured while calling addons: {e}", e);
}
IsReadyToWrite = true;
// Write queued content since initialisation started
var queueContent = string.Concat(WriteQueue);
WriteQueue.Clear();
await Terminal.Write(queueContent);
if (OnFirstRender != null)
await OnFirstRender.Invoke();
}
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 HandleWriteAsync(content);
else
WriteQueue.Add(content);
}
private async Task HandleWriteAsync(string content)
{
// Update output cache and prune it if required
if (OutputCache.Count > MaxOutputCacheSize)
{
for (var i = 0; i < 50; i++)
OutputCache.RemoveAt(i);
}
OutputCache.Add(content);
// Trigger events
if (OnWrite != null)
await OnWrite.Invoke(content);
// Write in own terminal
await Terminal.Write(content);
}
private async Task OpenFullscreenAsync()
{
await ModalService.LaunchAsync<FullScreenModal>(parameters => { parameters["Parent"] = this; }, size: "max-w-none");
}
private async Task TogglePauseAsync()
{
IsPaused = !IsPaused;
await InvokeAsync(StateHasChanged);
if (IsPaused)
return;
var queueContent = string.Concat(WriteQueue);
WriteQueue.Clear();
await HandleWriteAsync(queueContent);
}
private async Task SubmitCommandAsync()
{
CommandHistory.Add(CommandInput);
if (OnCommand != null)
await OnCommand.Invoke(CommandInput);
CommandIndex = -1;
CommandInput = "";
await InvokeAsync(StateHasChanged);
}
private async Task HandleKeyAsync(KeyboardEventArgs keyboard)
{
switch (keyboard.Code)
{
case "Enter":
await SubmitCommandAsync();
break;
case "ArrowUp" or "ArrowDown":
{
var highestIndex = CommandHistory.Count - 1;
if (CommandIndex == -1)
CommandIndex = highestIndex;
else
{
if (keyboard.Code is "ArrowUp")
CommandIndex++;
else if (keyboard.Code is "ArrowDown")
CommandIndex--;
}
if (CommandIndex > highestIndex)
CommandIndex = highestIndex;
if (CommandIndex < 0)
CommandIndex = 0;
if (CommandIndex <= highestIndex || CommandHistory.Count > 0)
CommandInput = CommandHistory[CommandIndex];
await InvokeAsync(StateHasChanged);
break;
}
}
}
public async ValueTask DisposeAsync()
{
await Terminal.DisposeAsync();
}
}

View File

@@ -1,79 +0,0 @@
@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.CreatePartials
@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"></i>
Back
</a>
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Create
</WButton>
</PageHeader>
<div class="mt-5">
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
<Tabs>
<Tab Name="General">
<General Request="Request" Parent="this" />
</Tab>
<Tab Name="Allocations">
<Allocations Request="Request" Parent="this" />
</Tab>
<Tab Name="Variables">
<Variables Request="Request" Parent="this" />
</Tab>
<Tab Name="Advanced">
<Advanced Request="Request" />
</Tab>
</Tabs>
</HandleForm>
</div>
@code
{
private HandleForm Form;
private CreateServerRequest Request;
public List<NodeAllocationResponse> Allocations = new();
public UserResponse? Owner;
public StarResponse? Star;
public 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.SuccessAsync("Successfully created Server");
Navigation.NavigateTo("/admin/servers/all");
}
}

View File

@@ -1,162 +0,0 @@
@page "/admin/servers/all"
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Common
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
@using MoonlightServers.Shared.Http.Responses.Admin.Servers
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Grid
@using MoonCore.Blazor.FlyonUi.Grid.Columns
@using MoonCore.Common
@using Moonlight.Shared.Http.Responses.Admin.Users
@inject HttpApiClient ApiClient
@inject AlertService AlertService
@inject ToastService ToastService
@attribute [Authorize(Policy = "permissions:admin.servers.get")]
<div class="mb-3">
<NavTabs Index="1" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
</div>
<div class="mb-5">
<PageHeader Title="Servers">
<a href="/admin/servers/all/create" class="btn btn-primary">
Create
</a>
</PageHeader>
</div>
<DataGrid @ref="Grid"
TGridItem="ServerResponse"
ItemSource="ItemSource">
<PropertyColumn Field="x => x.Id"/>
<TemplateColumn Title="Name">
<td>
<a class="text-primary" href="/admin/servers/all/update/@context.Id">
@context.Name
</a>
</td>
</TemplateColumn>
<TemplateColumn Title="Owner">
<td>
@{
var owner = Users.GetValueOrDefault(context.OwnerId);
}
<span>
@(owner?.Username ?? "N/A")
</span>
</td>
</TemplateColumn>
<TemplateColumn Title="Node">
<td>
@{
var node = Nodes.GetValueOrDefault(context.NodeId);
}
<span>
@(node?.Name ?? "N/A")
</span>
</td>
</TemplateColumn>
<TemplateColumn Title="Star">
<td>
@{
var star = Stars.GetValueOrDefault(context.StarId);
}
<span>
@(star?.Name ?? "N/A")
</span>
</td>
</TemplateColumn>
<TemplateColumn Title="Actions">
<td>
<div class="flex justify-end">
<a href="/admin/servers/all/update/@(context.Id)" class="text-primary mr-2 sm:mr-3">
<i class="icon-pencil text-base"></i>
</a>
<a href="#" @onclick="() => DeleteAsync(context)" @onclick:preventDefault
class="text-error">
<i class="icon-trash text-base"></i>
</a>
</div>
</td>
</TemplateColumn>
</DataGrid>
@code
{
private DataGrid<ServerResponse> Grid;
private Dictionary<int, StarResponse> Stars = new();
private Dictionary<int, NodeResponse> Nodes = new();
private Dictionary<int, UserResponse> Users = new();
private ItemSource<ServerResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<ServerResponse>> LoadAsync(int startIndex, int count)
{
var query = $"?startIndex={startIndex}&count={count}";
var countedData = await ApiClient.GetJson<CountedData<ServerResponse>>($"api/admin/servers{query}");
// Fetch relations
var nodesToFetch = countedData.Items
.Where(x => !Nodes.ContainsKey(x.Id))
.Select(x => x.Id)
.Distinct();
foreach (var id in nodesToFetch)
{
var node = await ApiClient.GetJson<NodeResponse>($"api/admin/servers/nodes/{id}");
Nodes[node.Id] = node;
}
var starsToFetch = countedData.Items
.Where(x => !Stars.ContainsKey(x.Id))
.Select(x => x.Id)
.Distinct();
foreach (var id in starsToFetch)
{
var star = await ApiClient.GetJson<StarResponse>($"api/admin/servers/stars/{id}");
Stars[star.Id] = star;
}
var usersToFetch = countedData.Items
.Where(x => !Users.ContainsKey(x.Id))
.Select(x => x.Id)
.Distinct();
foreach (var id in usersToFetch)
{
var user = await ApiClient.GetJson<UserResponse>($"api/admin/users/{id}");
Users[user.Id] = user;
}
return countedData;
}
private async Task DeleteAsync(ServerResponse response)
{
await AlertService.ConfirmDangerAsync(
"Server deletion",
$"Do you really want to delete the server '{response.Name}'",
async () =>
{
await ApiClient.Delete($"api/admin/servers/{response.Id}");
await ToastService.SuccessAsync("Successfully deleted server");
await Grid.RefreshAsync();
}
);
}
}

View File

@@ -1,101 +0,0 @@
@page "/admin/servers/all/update/{Id:int}"
@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.Shared.Http.Responses.Admin.Servers
@using MoonlightServers.Frontend.UI.Components.Servers.UpdatePartials
@using MoonlightServers.Shared.Http.Responses.Admin.NodeAllocations
@inject HttpApiClient ApiClient
@inject NavigationManager Navigation
@inject ToastService ToastService
@attribute [Authorize(Policy = "permissions:admin.servers.update")]
<LazyLoader Load="LoadAsync">
<PageHeader Title="Update Server">
<a href="/admin/servers/all" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Update
</WButton>
</PageHeader>
<div class="mt-5">
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
<Tabs>
<Tab Name="General">
<General Request="Request" Parent="this"/>
</Tab>
<Tab Name="Allocations">
<Allocations Request="Request" Server="Server" Parent="this"/>
</Tab>
<Tab Name="Variables">
<Variables Request="Request" Server="Server"/>
</Tab>
<Tab Name="Advanced">
<Advanced Request="Request"/>
</Tab>
</Tabs>
</HandleForm>
</div>
</LazyLoader>
@code
{
[Parameter] public int Id { get; set; }
private HandleForm Form;
private UpdateServerRequest Request;
private ServerResponse Server;
public List<NodeAllocationResponse> Allocations = new();
public UserResponse Owner;
private async Task LoadAsync(LazyLoader _)
{
Server = await ApiClient.GetJson<ServerResponse>($"api/admin/servers/{Id}");
Request = new()
{
Name = Server.Name,
AllocationIds = Server.AllocationIds,
OwnerId = Server.OwnerId,
Cpu = Server.Cpu,
Disk = Server.Disk,
DockerImageIndex = Server.DockerImageIndex,
Memory = Server.Memory,
StartupOverride = Server.StartupOverride
};
foreach (var allocationId in Server.AllocationIds)
{
var allocation = await ApiClient.GetJson<NodeAllocationResponse>(
$"api/admin/servers/nodes/{Server.NodeId}/allocations/{allocationId}"
);
Allocations.Add(allocation);
}
Owner = await ApiClient.GetJson<UserResponse>(
$"api/admin/users/{Server.OwnerId}"
);
}
private async Task OnSubmit()
{
Request.AllocationIds = Allocations.Select(x => x.Id).ToArray();
Request.OwnerId = Owner.Id;
await ApiClient.Patch($"api/admin/servers/{Id}", Request);
await ToastService.SuccessAsync("Successfully updated server");
Navigation.NavigateTo("/admin/servers/all");
}
}

View File

@@ -1,8 +0,0 @@
@page "/admin/servers"
@using MoonCore.Blazor.FlyonUi.Components
@attribute [Authorize(Policy = "permissions:admin.servers.overview")]
<NavTabs Index="0" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>

View File

@@ -1,77 +0,0 @@
@page "/admin/servers/nodes/create"
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Requests.Admin.Nodes
@inject HttpApiClient ApiClient
@inject NavigationManager Navigation
@inject ToastService ToastService
@attribute [Authorize(Policy = "permissions:admin.servers.nodes.create")]
<PageHeader Title="Create Node">
<a href="/admin/servers/nodes" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Create
</WButton>
</PageHeader>
<div class="mt-5">
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
<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">Name</label>
<div class="mt-2">
<input @bind="Request.Name" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Fqdn</label>
<div class="mt-2">
<input @bind="Request.Fqdn" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">HttpPort</label>
<div class="mt-2">
<input @bind="Request.HttpPort" type="number" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">FtpPort</label>
<div class="mt-2">
<input @bind="Request.FtpPort" type="number" autocomplete="off" class="input w-full">
</div>
</div>
</div>
</HandleForm>
</div>
@*
TODO: EnableTransparentMode, EnableDynamicFirewall
*@
@code
{
private HandleForm Form;
private CreateNodeRequest Request;
protected override void OnInitialized()
{
Request = new();
}
private async Task OnSubmit()
{
await ApiClient.Post("api/admin/servers/nodes", Request);
await ToastService.SuccessAsync("Successfully created node");
Navigation.NavigateTo("/admin/servers/nodes");
}
}

View File

@@ -1,245 +0,0 @@
@page "/admin/servers/nodes"
@using Microsoft.Extensions.Logging
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Common
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Statistics
@using MoonlightServers.Shared.Http.Responses.Admin.Nodes.Sys
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Grid
@using MoonCore.Blazor.FlyonUi.Grid.Columns
@using MoonCore.Common
@inject HttpApiClient ApiClient
@inject NodeService NodeService
@inject AlertService AlertService
@inject ToastService ToastService
@inject ILogger<Index> Logger
@attribute [Authorize(Policy = "permissions:admin.servers.nodes.get")]
<div class="mb-3">
<NavTabs Index="2" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
</div>
<div class="mb-5">
<PageHeader Title="Nodes">
<a href="/admin/servers/nodes/create" class="btn btn-primary">
Create
</a>
</PageHeader>
</div>
<DataGrid @ref="Grid"
TGridItem="NodeResponse"
ItemSource="ItemSource">
<PropertyColumn Field="x => x.Id"/>
<TemplateColumn Title="Name">
<td>
<a class="text-primary" href="/admin/servers/nodes/update/@(context.Id)">
@context.Name
</a>
</td>
</TemplateColumn>
<PropertyColumn Field="x => x.Fqdn"/>
<TemplateColumn Title="Status">
<td>
@{
var isFetched = StatusResponses.TryGetValue(context.Id, out var data);
}
@if (isFetched)
{
if (data == null)
{
<div class="text-error flex items-center">
<i class="icon-server-off text-base me-1"></i>
<span>
API Error
</span>
</div>
}
else
{
if (data.RoundtripSuccess)
{
<div class="text-success flex items-center">
<i class="icon-check text-base me-1"></i>
<span>Online (@(data.Version))</span>
</div>
}
else
{
<div class="text-error flex items-center">
<i class="icon-server-off text-base me-1"></i>
<span class="me-2">
Error
</span>
<a @onclick="() => ShowErrorDetailsAsync(context.Id)" @onclick:preventDefault
href="#" class="ms-1 text-base-content/40">Details</a>
</div>
}
}
}
else
{
<div class="text-gray-500">
<i class="icon-loader text-base me-1 align-middle"></i>
<span class="align-middle">Loading</span>
</div>
}
</td>
</TemplateColumn>
<TemplateColumn Title="Utilization">
<td>
@{
var isFetched = Statistics.TryGetValue(context.Id, out var data);
}
@if (isFetched)
{
if (data == null)
{
<div class="flex items-center text-error">
<i class="icon-server-off text-base me-1"></i>
<span>
API Error
</span>
</div>
}
else
{
<div class="flex flex-row">
<div class="flex items-center">
<i class="text-primary text-base me-2 icon-cpu"></i>
<span>@(Math.Round(data.Cpu.Usage))%</span>
</div>
<div class="flex items-center ms-5">
<i class="text-primary text-base me-2 icon-memory-stick"></i>
<span>
@(Math.Round((data.Memory.Total - data.Memory.Free - data.Memory.Cached) / (double)data.Memory.Total * 100))%
</span>
</div>
</div>
}
}
else
{
<div class="flex items-center text-gray-500">
<i class="icon-loader text-base me-1"></i>
<span>Loading</span>
</div>
}
</td>
</TemplateColumn>
<TemplateColumn Title="Actions">
<td>
<div class="flex justify-end">
<a href="/admin/servers/nodes/update/@(context.Id)" class="text-primary mr-2 sm:mr-3">
<i class="icon-pencil text-base"></i>
</a>
<a href="#" @onclick="() => DeleteAsync(context)" @onclick:preventDefault
class="text-error">
<i class="icon-trash text-base"></i>
</a>
</div>
</td>
</TemplateColumn>
</DataGrid>
@code
{
private DataGrid<NodeResponse> Grid;
private Dictionary<int, NodeSystemStatusResponse?> StatusResponses = new();
private Dictionary<int, StatisticsResponse?> Statistics = new();
private ItemSource<NodeResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<NodeResponse>> LoadAsync(int startIndex, int count)
{
var query = $"?startIndex={startIndex}&count={count}";
var countedData = await ApiClient.GetJson<CountedData<NodeResponse>>($"api/admin/servers/nodes{query}");
Statistics.Clear();
StatusResponses.Clear();
Task.Run(async () =>
{
foreach (var item in countedData.Items)
{
try
{
Statistics[item.Id] = await NodeService.GetStatisticsAsync(item.Id);
}
catch (Exception e)
{
Logger.LogWarning(
"An error occured while fetching statistics for node {nodeId}: {e}",
item.Id,
e
);
Statistics[item.Id] = null;
}
await InvokeAsync(StateHasChanged);
try
{
StatusResponses[item.Id] = await NodeService.GetSystemStatusAsync(item.Id);
}
catch (Exception e)
{
Logger.LogWarning(
"An error occured while fetching status for node {nodeId}: {e}",
item.Id,
e
);
StatusResponses[item.Id] = null;
}
await InvokeAsync(StateHasChanged);
}
});
return countedData;
}
private async Task DeleteAsync(NodeResponse response)
{
await AlertService.ConfirmDangerAsync(
"Node deletion",
$"Do you really want to delete the node '{response.Name}'",
async () =>
{
await ApiClient.Delete($"api/admin/servers/nodes/{response.Id}");
await ToastService.SuccessAsync("Successfully deleted node");
await Grid.RefreshAsync();
}
);
}
private async Task ShowErrorDetailsAsync(int id)
{
var data = StatusResponses.GetValueOrDefault(id);
if (data == null)
return;
var message = $"Failed after {Math.Round(data.RoundtripTime.TotalSeconds, 2)} seconds: " +
(data.RoundtripRemoteFailure ? "(Failed at node)" : "(Failed at api server)") +
$" {data.RoundtripError}";
await AlertService.ErrorAsync("Node error details", message);
}
}

View File

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

View File

@@ -1,67 +0,0 @@
@page "/admin/servers/stars/create"
@using Microsoft.AspNetCore.Components.Authorization
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
@inject HttpApiClient ApiClient
@inject NavigationManager Navigation
@inject ToastService ToastService
@attribute [Authorize(Policy = "permissions:admin.servers.stars.create")]
<PageHeader Title="Create Star">
<a href="/admin/servers/stars" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Create
</WButton>
</PageHeader>
<div class="mt-5">
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
<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">Name</label>
<div class="mt-2">
<input @bind="Request.Name" type="text" autocomplete="off" class="input w-full">
</div>
</div>
<div class="sm:col-span-2">
<label class="block text-sm font-medium leading-6 text-base-content">Author</label>
<div class="mt-2">
<input @bind="Request.Author" type="text" autocomplete="off" class="input w-full">
</div>
</div>
</div>
</HandleForm>
</div>
@code
{
[CascadingParameter] public Task<AuthenticationState> AuthState { get; set; }
private HandleForm Form;
private CreateStarRequest Request;
protected override async Task OnInitializedAsync()
{
Request = new();
var authState = await AuthState;
Request.Author = authState.User.Claims.First(x => x.Type == "email").Value;
}
private async Task OnSubmit()
{
await ApiClient.Post("api/admin/servers/stars", Request);
await ToastService.SuccessAsync("Successfully created star");
Navigation.NavigateTo("/admin/servers/stars");
}
}

View File

@@ -1,166 +0,0 @@
@page "/admin/servers/stars"
@using MoonCore.Blazor.FlyonUi.Alerts
@using MoonCore.Blazor.FlyonUi.Common
@using MoonCore.Blazor.FlyonUi.Helpers
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using MoonCore.Exceptions
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Grid
@using MoonCore.Blazor.FlyonUi.Grid.Columns
@using MoonCore.Common
@inject HttpApiClient ApiClient
@inject DownloadService DownloadService
@inject ToastService ToastService
@inject AlertService AlertService
@attribute [Authorize(Policy = "permissions:admin.servers.stars.get")]
<div class="mb-3">
<NavTabs Index="3" Names="@UiConstants.AdminNavNames" Links="@UiConstants.AdminNavLinks"/>
</div>
<div class="mb-5">
<PageHeader Title="Stars">
<InputFile id="import-file" hidden="" multiple OnChange="OnImportFiles"/>
<label for="import-file" class="btn btn-accent cursor-pointer">
<i class="icon-file-up"></i>
Import
</label>
<a href="/admin/servers/nodes/create" class="btn btn-primary">
Create
</a>
</PageHeader>
</div>
<DataGrid @ref="Grid"
TGridItem="StarResponse"
ItemSource="ItemSource">
<PropertyColumn Field="x => x.Id" />
<TemplateColumn Title="Name">
<td>
<a class="text-primary" href="/admin/servers/stars/update/@(context.Id)">
@context.Name
</a>
</td>
</TemplateColumn>
<PropertyColumn Field="x => x.Version" />
<PropertyColumn Field="x => x.Author" />
<TemplateColumn>
<td>
<div class="flex justify-end">
@if (!string.IsNullOrEmpty(context.DonateUrl))
{
<a href="@context.DonateUrl" target="_blank" class="text-accent mr-3">
<i class="icon-heart align-middle"></i>
<span class="align-middle">Donate</span>
</a>
}
@if (!string.IsNullOrEmpty(context.UpdateUrl))
{
<a href="#" @onclick:preventDefault class="text-accent mr-3">
<i class="icon-refresh-cw align-middle"></i>
<span class="align-middle">Update</span>
</a>
}
<a href="#" @onclick="() => ExportAsync(context)" @onclick:preventDefault class="text-success mr-3">
<i class="icon-download align-middle"></i>
<span class="align-middle">Export</span>
</a>
<a href="/admin/servers/stars/update/@(context.Id)" class="text-primary mr-2 sm:mr-3">
<i class="icon-pencil text-base"></i>
</a>
<a href="#" @onclick="() => DeleteAsync(context)" @onclick:preventDefault
class="text-error">
<i class="icon-trash text-base"></i>
</a>
</div>
</td>
</TemplateColumn>
</DataGrid>
@code
{
private DataGrid<StarResponse> Grid;
private ItemSource<StarResponse> ItemSource => ItemSourceFactory.From(LoadAsync);
private async Task<IEnumerable<StarResponse>> LoadAsync(int startIndex, int count)
{
var query = $"?startIndex={startIndex}&count={count}";
return await ApiClient.GetJson<CountedData<StarResponse>>($"api/admin/servers/stars{query}");
}
private async Task DeleteAsync(StarResponse response)
{
await AlertService.ConfirmDangerAsync(
"Star deletion",
$"Do you really want to delete the star '{response.Name}'",
async () =>
{
await ApiClient.Delete($"api/admin/servers/stars/{response.Id}");
await ToastService.SuccessAsync("Successfully deleted star");
await Grid.RefreshAsync();
}
);
}
private async Task ExportAsync(StarResponse star)
{
var json = await ApiClient.GetString($"api/admin/servers/stars/{star.Id}/export");
var formattedFileName = star.Name.Replace(" ", "_") + ".json";
await DownloadService.DownloadAsync(formattedFileName, json);
await ToastService.SuccessAsync($"Successfully exported '{star.Name}'");
}
private async Task OnImportFiles(InputFileChangeEventArgs eventArgs)
{
IBrowserFile[] files;
if(eventArgs.FileCount == 0)
return;
if (eventArgs.FileCount > 1)
files = eventArgs.GetMultipleFiles().ToArray();
else
files = [eventArgs.File];
foreach (var file in files)
{
try
{
if (!file.Name.EndsWith(".json"))
{
await ToastService.ErrorAsync($"Failed to import '{file.Name}': Only json files are supported");
continue;
}
await using var stream = file.OpenReadStream();
var content = new MultipartFormDataContent();
content.Add(new StreamContent(stream), "file", file.Name);
var star = await ApiClient.PostJson<StarResponse>("api/admin/servers/stars/import", content);
await ToastService.SuccessAsync($"Successfully imported '{star.Name}'");
}
catch (HttpApiException e)
{
await ToastService.ErrorAsync($"Failed to import '{file.Name}': {e.Title}");
}
}
await Grid.RefreshAsync();
}
}

View File

@@ -1,103 +0,0 @@
@page "/admin/servers/stars/update/{Id:int}"
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Blazor.FlyonUi.Toasts
@using MoonCore.Helpers
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
@using MoonlightServers.Frontend.UI.Components.Stars.UpdatePartials
@inject HttpApiClient ApiClient
@inject NavigationManager Navigation
@inject ToastService ToastService
@attribute [Authorize(Policy = "permissions:admin.servers.stars.update")]
<LazyLoader Load="LoadAsync">
<PageHeader Title="Update Star">
<a href="/admin/servers/stars" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Update
</WButton>
</PageHeader>
<div class="mt-5">
<HandleForm @ref="Form" Model="Request" OnValidSubmit="OnSubmit">
<Tabs>
<Tab Name="General">
<General Request="Request" />
</Tab>
<Tab Name="Start, Stop & Status">
<StartStopStatus Request="Request" />
</Tab>
<Tab Name="Parse Configuration">
<ParseConfig Request="Request" />
</Tab>
<Tab Name="Installation">
<Installation Request="Request" />
</Tab>
<Tab Name="Variables">
<Variables Star="Detail" />
</Tab>
<Tab Name="Docker Images">
<DockerImage Star="Detail" />
</Tab>
<Tab Name="Miscellaneous">
<Misc Star="Detail" Request="Request" />
</Tab>
</Tabs>
</HandleForm>
</div>
</LazyLoader>
@code
{
[Parameter] public int Id { get; set; }
private HandleForm Form;
private UpdateStarRequest Request;
private StarResponse Detail;
private async Task LoadAsync(LazyLoader _)
{
Detail = await ApiClient.GetJson<StarResponse>($"api/admin/servers/stars/{Id}");
Request = new()
{
Name = Detail.Name,
AllowDockerImageChange = Detail.AllowDockerImageChange,
Author = Detail.Author,
DefaultDockerImage = Detail.DefaultDockerImage,
DonateUrl = Detail.DonateUrl,
InstallDockerImage = Detail.InstallDockerImage,
InstallScript = Detail.InstallScript,
InstallShell = Detail.InstallShell,
OnlineDetection = Detail.OnlineDetection,
ParseConfiguration = Detail.ParseConfiguration,
RequiredAllocations = Detail.RequiredAllocations,
StartupCommand = Detail.StartupCommand,
StopCommand = Detail.StopCommand,
UpdateUrl = Detail.UpdateUrl,
Version = Detail.Version
};
}
private async Task OnSubmit()
{
await ApiClient.Patch($"api/admin/servers/stars/{Id}", Request);
await ToastService.SuccessAsync("Successfully updated Star");
Navigation.NavigateTo("/admin/servers/stars");
}
}

View File

@@ -1,88 +0,0 @@
@page "/servers"
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Common
@using MoonlightServers.Frontend.UI.Components.Servers
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@inject ServerService ServerService
<Tabs>
<Tab Name="Your servers">
<LazyLoader Load="LoadOwnServersAsync">
@if (OwnServers.Length == 0)
{
<IconAlert Title="No servers found" Color="text-primary" Icon="icon-search">
There are no servers linked to your account
</IconAlert>
}
else
{
<div class="flex flex-col gap-y-5">
@* Folder design idea
<div class="w-full bg-gray-800 px-5 py-3.5 rounded-xl">
<div class="flex items-center">
<div class="bg-gray-900 bg-opacity-45 py-1 px-2 rounded-lg flex items-center">
<i class="icon-folder-open me-3 align-middle"></i>
<div class="text-lg align-middle">
My Cool Folder
</div>
</div>
</div>
<div class="mt-5 flex flex-col gap-y-3">
@foreach (var server in Servers)
{
<ServerCard Server="server" />
}
</div>
</div>
*@
@foreach (var server in OwnServers)
{
<ServerCard Server="server"/>
}
</div>
}
</LazyLoader>
</Tab>
<Tab Name="Shared servers">
<LazyLoader Load="LoadSharedServersAsync">
@if (SharedServers.Length == 0)
{
<IconAlert Title="No shared servers found" Color="text-primary" Icon="icon-share-2">
There are no shared servers linked to your account
</IconAlert>
}
else
{
<div class="flex flex-col gap-y-5">
@foreach (var server in SharedServers)
{
<ServerCard Server="server"/>
}
</div>
}
</LazyLoader>
</Tab>
</Tabs>
@code
{
private ServerDetailResponse[] OwnServers;
private ServerDetailResponse[] SharedServers;
private async Task LoadOwnServersAsync(LazyLoader lazyLoader)
{
OwnServers = await CountedData.AllAsync<ServerDetailResponse>(async (startIndex, count) =>
await ServerService.GetServersAsync(startIndex, count)
);
}
private async Task LoadSharedServersAsync(LazyLoader lazyLoader)
{
SharedServers = await CountedData.AllAsync<ServerDetailResponse>(async (startIndex, count) =>
await ServerService.GetSharedServersAsync(startIndex, count)
);
}
}

View File

@@ -1,347 +0,0 @@
@page "/servers/{ServerId:int}"
@page "/servers/{ServerId:int}/{TabPath:alpha}"
@using Microsoft.AspNetCore.SignalR.Client
@using MoonCore.Blazor.FlyonUi.Components
@using MoonCore.Exceptions
@using MoonCore.Helpers
@using MoonlightServers.Frontend.Interfaces
@using MoonlightServers.Frontend.Models
@using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Enums
@using MoonlightServers.Shared.Http.Responses.Client.Servers
@inject ServerService ServerService
@inject NavigationManager Navigation
@inject IEnumerable<IServerTabProvider> TabProviders
@implements IAsyncDisposable
<LazyLoader Load="LoadAsync">
@if (NotFound)
{
<IconAlert Title="Server not found" Icon="icon-search" Color="text-primary">
The requested server could not be found
</IconAlert>
}
else
{
<div class="card card-body justify-between py-2.5 px-5 flex-row">
<div class="flex flex-row items-center">
@{
var statusClass = State switch
{
ServerState.Installing => "status-primary",
ServerState.Offline => "status-error",
ServerState.Starting => "status-warning",
ServerState.Stopping => "status-warning",
ServerState.Online => "status-success",
_ => "status-secondary"
};
}
<div class="inline-grid *:[grid-area:1/1] me-3">
@if (State != ServerState.Offline)
{
<div class="status status-xl @statusClass animate-ping"></div>
}
<div class="status status-xl @statusClass"></div>
</div>
<div class="flex flex-col">
<div class="hidden sm:flex text-lg font-semibold">@Server.Name</div>
<div class="hidden text-sm text-base-content/60 md:flex gap-x-3">
<span>
<i class="icon-sparkles me-0.5 align-middle"></i>
<span class="align-middle">@Server.StarName</span>
</span>
<span>
<i class="icon-database me-0.5 align-middle"></i>
<span class="align-middle">@Server.NodeName</span>
</span>
</div>
</div>
</div>
<div class="flex flex-row items-center">
<div class="flex gap-x-1.5">
@if (HasPermissionTo("power", ServerPermissionLevel.ReadWrite))
{
@if (State == ServerState.Offline)
{
<WButton CssClasses="btn btn-success" OnClick="_ => StartAsync()">
<i class="icon-play align-middle"></i>
<span class="align-middle">Start</span>
</WButton>
}
else
{
<button type="button" class="btn btn-success" disabled="disabled">
<i class="icon-play align-middle"></i>
<span class="align-middle">Start</span>
</button>
}
@if (State == ServerState.Online)
{
<button type="button" class="btn btn-primary">
<i class="icon-rotate-ccw align-middle"></i>
<span class="align-middle">Restart</span>
</button>
}
else
{
<button type="button" class="btn btn-primary" disabled="disabled">
<i class="icon-rotate-ccw align-middle"></i>
<span class="align-middle">Restart</span>
</button>
}
@if (State == ServerState.Starting || State == ServerState.Online || State == ServerState.Stopping)
{
if (State == ServerState.Stopping)
{
<WButton CssClasses="btn btn-error" OnClick="_ => KillAsync()">
<i class="icon-bomb align-middle"></i>
<span class="align-middle">Kill</span>
</WButton>
}
else
{
<WButton CssClasses="btn btn-error" OnClick="_ => StopAsync()">
<i class="icon-squircle align-middle"></i>
<span class="align-middle">Stop</span>
</WButton>
}
}
else
{
<button type="button" class="btn btn-error" disabled="disabled">
<i class="icon-squircle align-middle"></i>
<span class="align-middle">Stop</span>
</button>
}
}
else
{
<button type="button" class="btn btn-success" disabled="disabled">
<i class="icon-play align-middle"></i>
<span class="align-middle">Start</span>
</button>
<button type="button" class="btn btn-primary" disabled="disabled">
<i class="icon-rotate-ccw align-middle"></i>
<span class="align-middle">Restart</span>
</button>
<button type="button" class="btn btn-error" disabled="disabled">
<i class="icon-squircle align-middle"></i>
<span class="align-middle">Stop</span>
</button>
}
</div>
</div>
</div>
<div class="mt-3">
<nav class="tabs space-x-2 overflow-x-auto" aria-label="Tabs" role="tablist" aria-orientation="horizontal">
@foreach (var tab in Tabs)
{
<a href="/servers/@(ServerId)/@(tab.Path)"
class="btn btn-text active-tab:bg-primary active-tab:text-primary-content hover:text-primary hover:bg-primary/20 bg-base-150 text-sm py-0.5 px-3 rounded-xl @(tab == CurrentTab ? "active" : "")"
data-tab="na"
role="tab"
@onclick:preventDefault
@onclick="() => SwitchTabAsync(tab)">
@tab.Name
</a>
}
</nav>
<div class="mt-5">
@if (CurrentTab == null)
{
<IconAlert Title="No tabs found" Color="text-primary" Icon="icon-app-window">
Seems like you are missing access to all tabs or no tabs for this server could be found
</IconAlert>
}
else
{
var rf = ComponentHelper.FromType(CurrentTab!.ComponentType, parameters =>
{
parameters.Add("Server", Server);
parameters.Add("State", State);
parameters.Add("InitialConsoleMessage", InitialConsoleMessage);
parameters.Add("HubConnection", HubConnection!);
parameters.Add("Parent", this);
});
@rf
}
</div>
</div>
}
</LazyLoader>
@code
{
[Parameter] public int ServerId { get; set; }
[Parameter] public string? TabPath { get; set; }
private ServerTab[] Tabs;
private ServerTab? CurrentTab;
private ServerDetailResponse Server;
private bool NotFound = false;
private ServerState State;
private string InitialConsoleMessage = "";
private HubConnection? HubConnection;
public ConcurrentList<string> CommandHistory = new();
private async Task LoadAsync(LazyLoader _)
{
try
{
// Load meta data
Server = await ServerService.GetServerAsync(ServerId);
// Load server tabs
var tmpTabs = new List<ServerTab>();
foreach (var serverTabProvider in TabProviders)
tmpTabs.AddRange(await serverTabProvider.GetTabsAsync(Server));
// If we are accessing a shared server, we need to handle permissions
if (Server.Share != null)
{
// This removes all tabs where the user doesn't have the required permissions
tmpTabs.RemoveAll(tab =>
{
if (string.IsNullOrEmpty(tab.PermissionId) || tab.PermissionLevel == ServerPermissionLevel.None)
return false;
// If permission is required but not set, we don't have access to it
if (!Server.Share.Permissions.TryGetValue(tab.PermissionId, out var level))
return true;
// False if the acquired level is higher or equal than the required permission level for the tab so it won't get removed
return level < tab.PermissionLevel;
});
}
Tabs = tmpTabs.OrderBy(x => x.Priority).ToArray();
// Find current tab
if (!string.IsNullOrEmpty(TabPath))
{
CurrentTab = Tabs.FirstOrDefault(x => TabPath.Equals(x.Path, StringComparison.InvariantCultureIgnoreCase)
);
}
if (CurrentTab == null)
CurrentTab = Tabs.FirstOrDefault();
// Load initial status for first render
var status = await ServerService.GetStatusAsync(ServerId);
State = status.State;
if (!HasPermissionTo("console", ServerPermissionLevel.Read))
return; // Exit early if we don't have permissions to load the console
// Load initial messages
var initialLogs = await ServerService.GetLogsAsync(ServerId);
InitialConsoleMessage = "";
foreach (var message in initialLogs.Messages)
InitialConsoleMessage += message;
// Load websocket meta
var websocketDetails = await ServerService.GetWebSocketAsync(ServerId);
// Build signal r
HubConnection = new HubConnectionBuilder()
.WithUrl(websocketDetails.Target, options =>
{
options.AccessTokenProvider = async () =>
{
var details = await ServerService.GetWebSocketAsync(ServerId);
return details.AccessToken;
};
})
.WithAutomaticReconnect()
.Build();
// Define handlers
HubConnection.On<string>("StateChanged", async stateStr =>
{
if (!Enum.TryParse(stateStr, out ServerState receivedState))
return;
State = receivedState;
await InvokeAsync(StateHasChanged);
});
HubConnection.On<string>("ConsoleOutput", async content =>
{
// Update initial message
InitialConsoleMessage += content;
await InvokeAsync(StateHasChanged);
});
// Connect
await HubConnection.StartAsync();
}
catch (HttpApiException e)
{
if (e.Status == 404)
NotFound = true;
else
throw;
}
}
private bool HasPermissionTo(string id, ServerPermissionLevel level)
{
// All non shares have permissions
if (Server.Share == null)
return true;
if (!Server.Share.Permissions.TryGetValue(id, out var acquiredLevel))
return false;
return acquiredLevel >= level;
}
private async Task SwitchTabAsync(ServerTab tab)
{
CurrentTab = tab;
Navigation.NavigateTo($"/servers/{ServerId}/{tab.Path}");
await InvokeAsync(StateHasChanged);
}
private async Task StartAsync()
=> await ServerService.StartAsync(ServerId);
private async Task StopAsync()
=> await ServerService.StopAsync(ServerId);
private async Task KillAsync()
=> await ServerService.KillAsync(ServerId);
public async ValueTask DisposeAsync()
{
if (HubConnection != null)
{
if (HubConnection.State == HubConnectionState.Connected)
await HubConnection.StopAsync();
await HubConnection.DisposeAsync();
}
}
}

View File

@@ -0,0 +1,43 @@
@page "/demo"
@using LucideBlazor
@using MoonlightServers.Frontend.UI.Components
@using ShadcnBlazor.Buttons
@using ShadcnBlazor.Cards
@using ShadcnBlazor.Extras.Dialogs
@inject DialogService DialogService
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5">
<Card ClassName="col-span-1">
<CardHeader>
<CardTitle>Demo</CardTitle>
<CardDescription>A cool demo page</CardDescription>
</CardHeader>
<CardContent>
You successfully used the plugin template to create your moonlight plugin :)
</CardContent>
<CardFooter>
<Button>
<Slot>
<a @attributes="context" href="https://moonlightpa.nl/dev">
<ExternalLinkIcon/>
Visit documentation
</a>
</Slot>
</Button>
</CardFooter>
</Card>
<Card>
<CardContent>
<Button @onclick="LaunchFormAsync" Variant="ButtonVariant.Outline">
Open Form
</Button>
</CardContent>
</Card>
</div>
@code
{
private async Task LaunchFormAsync()
=> await DialogService.LaunchAsync<FormDialog>();
}

View File

@@ -1,6 +1,6 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using Microsoft.AspNetCore.Components.Web.Virtualization