Switched to database scheme seperation from MoonCores SingleDb. Updated mooncore versions. Updating to correct Async naming

This commit is contained in:
2025-09-21 16:44:01 +00:00
parent 86bec7f2ee
commit 3e87d5c140
93 changed files with 587 additions and 1583 deletions

View File

@@ -7,7 +7,7 @@ namespace Moonlight.Client.Implementations;
public class CoreStartup : IPluginStartup
{
public Task BuildApplication(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder)
public Task BuildApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder)
{
builder.Services.AddSingleton<ISidebarItemProvider, DefaultSidebarItemProvider>();
builder.Services.AddSingleton<IOverviewElementProvider, DefaultOverviewElementProvider>();
@@ -15,6 +15,6 @@ public class CoreStartup : IPluginStartup
return Task.CompletedTask;
}
public Task ConfigureApplication(IServiceProvider serviceProvider, WebAssemblyHost app)
public Task ConfigureApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHost app)
=> Task.CompletedTask;
}

View File

@@ -11,7 +11,7 @@ public class LogErrorFilter : IGlobalErrorFilter
Logger = logger;
}
public Task<bool> HandleException(Exception ex)
public Task<bool> HandleExceptionAsync(Exception ex)
{
Logger.LogError(ex, "Global error processed");
return Task.FromResult(false);

View File

@@ -18,21 +18,21 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
ApiClient = apiClient;
}
public async Task CreateFile(string path)
public async Task CreateFileAsync(string path)
{
await ApiClient.Post(
$"{BaseApiUrl}/touch?path={path}"
);
}
public async Task CreateDirectory(string path)
public async Task CreateDirectoryAsync(string path)
{
await ApiClient.Post(
$"{BaseApiUrl}/mkdir?path={path}"
);
}
public async Task<FsEntry[]> List(string path)
public async Task<FsEntry[]> ListAsync(string path)
{
var entries = await ApiClient.GetJson<FileSystemEntryResponse[]>(
$"{BaseApiUrl}/list?path={path}"
@@ -48,14 +48,14 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
}).ToArray();
}
public async Task Move(string oldPath, string newPath)
public async Task MoveAsync(string oldPath, string newPath)
{
await ApiClient.Post(
$"{BaseApiUrl}/move?oldPath={oldPath}&newPath={newPath}"
);
}
public async Task Read(string path, Func<Stream, Task> onHandleData)
public async Task ReadAsync(string path, Func<Stream, Task> onHandleData)
{
await using var stream = await ApiClient.GetStream(
$"{BaseApiUrl}/download?path={path}"
@@ -66,7 +66,7 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
stream.Close();
}
public async Task Write(string path, Stream dataStream)
public async Task WriteAsync(string path, Stream dataStream)
{
using var multiPartForm = new MultipartFormDataContent();
@@ -78,14 +78,14 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
);
}
public async Task Delete(string path)
public async Task DeleteAsync(string path)
{
await ApiClient.Delete(
$"{BaseApiUrl}/delete?path={path}"
);
}
public async Task Combine(string destination, string[] files)
public async Task CombineAsync(string destination, string[] files)
{
await ApiClient.Post(
$"{BaseApiUrl}/combine",
@@ -103,7 +103,7 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
new("tar.gz", ["tar.gz"], "Tar.gz Archive")
];
public async Task Archive(
public async Task ArchiveAsync(
string destination,
ArchiveFormat format,
string root,
@@ -120,7 +120,7 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
});
}
public async Task Unarchive(
public async Task UnarchiveAsync(
string path,
ArchiveFormat format,
string destination,
@@ -137,13 +137,13 @@ public class SystemFsAccess : IFsAccess, ICombineAccess, IArchiveAccess, IDownlo
);
}
public async Task<string> GetFileUrl(string path)
=> await GetDownloadUrl(path);
public async Task<string> GetFileUrlAsync(string path)
=> await GetDownloadUrlAsync(path);
public async Task<string> GetFolderUrl(string path)
=> await GetDownloadUrl(path);
public async Task<string> GetFolderUrlAsync(string path)
=> await GetDownloadUrlAsync(path);
private async Task<string> GetDownloadUrl(string path)
private async Task<string> GetDownloadUrlAsync(string path)
{
var response = await ApiClient.PostJson<DownloadUrlResponse>(
$"{BaseApiUrl}/downloadUrl?path={path}"

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Components;
using MoonCore.Blazor.FlyonUi.Exceptions;
using MoonCore.Blazor.FlyonUi.Toasts;
using MoonCore.Exceptions;
namespace Moonlight.Client.Implementations;
@@ -7,18 +8,25 @@ namespace Moonlight.Client.Implementations;
public class UnauthenticatedErrorFilter : IGlobalErrorFilter
{
private readonly NavigationManager Navigation;
private readonly ToastService ToastService;
public UnauthenticatedErrorFilter(NavigationManager navigation)
public UnauthenticatedErrorFilter(
NavigationManager navigation,
ToastService toastService
)
{
Navigation = navigation;
ToastService = toastService;
}
public Task<bool> HandleException(Exception ex)
public async Task<bool> HandleExceptionAsync(Exception ex)
{
if (ex is not HttpApiException { Status: 401 })
return Task.FromResult(false);
return false;
await ToastService.InfoAsync("Session expired", "Your session has expired. Reloading..");
Navigation.NavigateTo("/api/auth/logout", true);
return Task.FromResult(true);
return true;
}
}

View File

@@ -22,11 +22,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blazor-ApexCharts" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.9" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.8" />
<PackageReference Include="MoonCore" Version="1.9.9" />
<PackageReference Include="MoonCore.Blazor" Version="1.3.1" />
<PackageReference Include="MoonCore.Blazor.FlyonUi" Version="1.2.2" />
<PackageReference Include="MoonCore" Version="2.0.0" />
<PackageReference Include="MoonCore.Blazor.FlyonUi" Version="1.2.4" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -4,6 +4,6 @@ namespace Moonlight.Client.Plugins;
public interface IPluginStartup
{
public Task BuildApplication(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder);
public Task ConfigureApplication(IServiceProvider serviceProvider, WebAssemblyHost app);
public Task BuildApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHostBuilder builder);
public Task ConfigureApplicationAsync(IServiceProvider serviceProvider, WebAssemblyHost app);
}

View File

@@ -9,9 +9,9 @@ public class WindowService
JsRuntime = jsRuntime;
}
public async Task Open(string url, string title, int height, int width)
public async Task OpenAsync(string url, string title, int height, int width)
=> await JsRuntime.InvokeVoidAsync("moonlight.window.open", url, title, height, width);
public async Task Close()
public async Task CloseAsync()
=> await JsRuntime.InvokeVoidAsync("moonlight.window.closeCurrent");
}

View File

@@ -9,7 +9,7 @@ namespace Moonlight.Client.Startup;
public partial class Startup
{
private Task RegisterAuthentication()
private Task RegisterAuthenticationAsync()
{
WebAssemblyHostBuilder.Services.AddAuthorizationCore();
WebAssemblyHostBuilder.Services.AddCascadingAuthenticationState();

View File

@@ -1,6 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using MoonCore.Blazor.FlyonUi;
using MoonCore.Blazor.Services;
using MoonCore.Extensions;
using MoonCore.Helpers;
using Moonlight.Client.Services;
@@ -10,7 +9,7 @@ namespace Moonlight.Client.Startup;
public partial class Startup
{
private Task RegisterBase()
private Task RegisterBaseAsync()
{
WebAssemblyHostBuilder.RootComponents.Add<App>("#app");
WebAssemblyHostBuilder.RootComponents.Add<HeadOutlet>("head::after");

View File

@@ -7,7 +7,7 @@ namespace Moonlight.Client.Startup;
public partial class Startup
{
private Task SetupLogging()
private Task SetupLoggingAsync()
{
var loggerFactory = new LoggerFactory();
@@ -18,7 +18,7 @@ public partial class Startup
return Task.CompletedTask;
}
private Task RegisterLogging()
private Task RegisterLoggingAsync()
{
WebAssemblyHostBuilder.Logging.ClearProviders();
WebAssemblyHostBuilder.Logging.AddAnsiConsole();

View File

@@ -6,7 +6,7 @@ namespace Moonlight.Client.Startup;
public partial class Startup
{
private Task PrintVersion()
private Task PrintVersionAsync()
{
// Fancy start console output... yes very fancy :>
Console.Write("Running ");
@@ -27,7 +27,7 @@ public partial class Startup
return Task.CompletedTask;
}
private async Task LoadConfiguration()
private async Task LoadConfigurationAsync()
{
try
{

View File

@@ -10,7 +10,7 @@ public partial class Startup
private IPluginStartup[] PluginStartups;
private IServiceProvider PluginLoadServiceProvider;
private Task InitializePlugins()
private Task InitializePluginsAsync()
{
// Define minimal service collection
var startupSc = new ServiceCollection();
@@ -38,13 +38,13 @@ public partial class Startup
return Task.CompletedTask;
}
private async Task HookPluginBuild()
private async Task HookPluginBuildAsync()
{
foreach (var pluginAppStartup in PluginStartups)
{
try
{
await pluginAppStartup.BuildApplication(PluginLoadServiceProvider, WebAssemblyHostBuilder);
await pluginAppStartup.BuildApplicationAsync(PluginLoadServiceProvider, WebAssemblyHostBuilder);
}
catch (Exception e)
{
@@ -57,13 +57,13 @@ public partial class Startup
}
}
private async Task HookPluginConfigure()
private async Task HookPluginConfigureAsync()
{
foreach (var pluginAppStartup in PluginStartups)
{
try
{
await pluginAppStartup.ConfigureApplication(PluginLoadServiceProvider, WebAssemblyHost);
await pluginAppStartup.ConfigureApplicationAsync(PluginLoadServiceProvider, WebAssemblyHost);
}
catch (Exception e)
{

View File

@@ -16,33 +16,33 @@ public partial class Startup
public FrontendConfiguration Configuration { get; private set; }
public Task Initialize(IPluginStartup[]? plugins = null)
public Task InitializeAsync(IPluginStartup[]? plugins = null)
{
PluginStartups = plugins ?? [];
return Task.CompletedTask;
}
public async Task AddMoonlight(WebAssemblyHostBuilder builder)
public async Task AddMoonlightAsync(WebAssemblyHostBuilder builder)
{
WebAssemblyHostBuilder = builder;
await PrintVersion();
await PrintVersionAsync();
await SetupLogging();
await LoadConfiguration();
await InitializePlugins();
await SetupLoggingAsync();
await LoadConfigurationAsync();
await InitializePluginsAsync();
await RegisterLogging();
await RegisterBase();
await RegisterAuthentication();
await HookPluginBuild();
await RegisterLoggingAsync();
await RegisterBaseAsync();
await RegisterAuthenticationAsync();
await HookPluginBuildAsync();
}
public async Task AddMoonlight(WebAssemblyHost assemblyHost)
public async Task AddMoonlightAsync(WebAssemblyHost assemblyHost)
{
WebAssemblyHost = assemblyHost;
await HookPluginConfigure();
await HookPluginConfigureAsync();
}
}

View File

@@ -21,6 +21,8 @@
-ml-4
-translate-x-full
-translate-y-1/2
[animation-duration:0.8s]
[animation-timing-function:ease]
absolute
accordion
accordion-bordered
@@ -42,6 +44,7 @@ align-bottom
align-middle
animate-bounce
animate-ping
animate-spin
aria-[current='page']:text-bg-soft-primary
avatar
avatar-placeholder
@@ -76,23 +79,31 @@ border
border-0
border-1
border-2
border-3
border-b
border-b-2
border-b-base-content/20
border-b-primary
border-base-content
border-base-content/20
border-base-content/25
border-base-content/40
border-base-content/5
border-dashed
border-dotted
border-error/30
border-info/30
border-l-transparent
border-r-transparent
border-solid
border-success/30
border-t
border-t-transparent
border-transparent
border-warning/30
bottom-0
bottom-full
breadcrumbs
break-words
btn
btn-accent
@@ -160,6 +171,7 @@ duration-500
ease-in-out
ease-linear
end-3
error-message
file-upload-complete:progress-success
fill-base-content
fill-black
@@ -187,6 +199,8 @@ font-inter
font-medium
font-normal
font-semibold
footer
footer-center
gap-0.5
gap-1
gap-1.5
@@ -220,10 +234,13 @@ helper-text
hidden
hover:bg-primary/5
hover:bg-transparent
hover:cursor-pointer
hover:text-base-content
hover:text-base-content/60
hover:text-primary
image-full
indicator
indicator-item
inline
inline-block
inline-flex
@@ -281,7 +298,6 @@ list-disc
list-inside
list-none
loading
loading-lg
loading-sm
loading-spinner
loading-xl
@@ -296,6 +312,7 @@ max-md:flex-wrap
max-md:justify-center
max-sm:hidden
max-w-7xl
max-w-8
max-w-80
max-w-full
max-w-lg
@@ -360,10 +377,12 @@ mt-8
mx-1
mx-auto
my-3
my-5
my-auto
object-cover
opacity-0
opacity-100
opacity-75
open
origin-top-left
outline
@@ -396,7 +415,6 @@ pt-0
pt-0.5
pt-2
pt-3
px-0.5
px-1.5
px-2
px-2.5
@@ -471,10 +489,12 @@ space-x-2.5
space-y-1
space-y-4
sr-only
stack
static
status
status-error
sticky
success-message
switch
tab
tab-active

View File

@@ -1,7 +1,7 @@
<label for="@Id" class="btn btn-square border-0 ring-0 outline-0" style="background-color: @Value">
<i class="text-lg text-base-content @Icon"></i>
</label>
<input value="@Value" @oninput="Update" id="@Id" type="color" class="h-0 w-0 opacity-0"/>
<input value="@Value" @oninput="UpdateAsync" id="@Id" type="color" class="h-0 w-0 opacity-0"/>
@code
{
@@ -37,7 +37,7 @@
Id = $"color-selector-{GetHashCode()}";
}
private async Task Update(ChangeEventArgs args)
private async Task UpdateAsync(ChangeEventArgs args)
{
Value = args.Value?.ToString() ?? "#FFFFFF";
await InvokeAsync(StateHasChanged);

View File

@@ -17,7 +17,7 @@
for all SignalR Hubs to be synced.
</p>
<div class="mt-5">
<LazyLoader Load="Load">
<LazyLoader Load="LoadAsync">
<WButton OnClick="OnClick" CssClasses="btn btn-primary">
Send broadcast
</WButton>
@@ -30,9 +30,9 @@
{
private HubConnection? Connection;
private async Task Load(LazyLoader lazyLoader)
private async Task LoadAsync(LazyLoader lazyLoader)
{
await lazyLoader.UpdateText("Connecting to SignalR endpoint");
await lazyLoader.UpdateTextAsync("Connecting to SignalR endpoint");
Connection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri("/api/admin/system/diagnose/ws"))
@@ -41,7 +41,7 @@
Connection.On(
"Pong",
async () => await ToastService.Success("Received broadcast")
async () => await ToastService.SuccessAsync("Received broadcast")
);
await Connection.StartAsync();

View File

@@ -137,7 +137,7 @@
}
else
{
<input @onclick="_ => UpdateRadiusBox(possibleValue)" type="radio" name="radius-box" class="radio hidden"/>
<input @onclick="_ => UpdateRadiusBoxAsync(possibleValue)" type="radio" name="radius-box" class="radio hidden"/>
}
<span class="label-text w-full">
<div class="pe-1.5 pt-1.5" aria-hidden="true">
@@ -164,7 +164,7 @@
}
else
{
<input @onclick="_ => UpdateRadiusField(possibleValue)" type="radio" name="radius-field" class="radio hidden"/>
<input @onclick="_ => UpdateRadiusFieldAsync(possibleValue)" type="radio" name="radius-field" class="radio hidden"/>
}
<span class="label-text w-full">
<div class="pe-1.5 pt-1.5" aria-hidden="true">
@@ -191,7 +191,7 @@
}
else
{
<input @onclick="_ => UpdateRadiusSelector(possibleValue)" type="radio" name="radius-selector" class="radio hidden"/>
<input @onclick="_ => UpdateRadiusSelectorAsync(possibleValue)" type="radio" name="radius-selector" class="radio hidden"/>
}
<span class="label-text w-full">
<div class="pe-1.5 pt-1.5" aria-hidden="true">
@@ -302,19 +302,19 @@
set => Theme.Noise = value ? 1 : 0;
}
private async Task UpdateRadiusBox(float value)
private async Task UpdateRadiusBoxAsync(float value)
{
Theme.RadiusBox = value;
await InvokeAsync(StateHasChanged);
}
private async Task UpdateRadiusField(float value)
private async Task UpdateRadiusFieldAsync(float value)
{
Theme.RadiusField = value;
await InvokeAsync(StateHasChanged);
}
private async Task UpdateRadiusSelector(float value)
private async Task UpdateRadiusSelectorAsync(float value)
{
Theme.RadiusSelector = value;
await InvokeAsync(StateHasChanged);

View File

@@ -42,7 +42,7 @@
public event Func<Task> OnStateChanged;
public bool ShowMobileNavigation { get; private set; } = false;
public async Task ToggleMobileNavigation()
public async Task ToggleMobileNavigationAsync()
{
ShowMobileNavigation = !ShowMobileNavigation;
await OnStateChanged();

View File

@@ -5,7 +5,7 @@
<header class="flex items-center px-4 lg:hidden border-b border-base-content/5">
<div class="py-2.5">
<span class="relative">
<button @onclick="Layout.ToggleMobileNavigation" aria-label="Open navigation"
<button @onclick="Layout.ToggleMobileNavigationAsync" aria-label="Open navigation"
class="relative flex min-w-0 items-center gap-3 rounded-lg p-2 text-left text-base/6 sm:text-sm/5 text-base-content"
type="button">
<i class="icon-menu text-xl"></i>

View File

@@ -95,7 +95,7 @@
</div>
</div>
</div>
<a href="#" @onclick:preventDefault @onclick="Logout" class="flex items-center">
<a href="#" @onclick:preventDefault @onclick="LogoutAsync" class="flex items-center">
<i class="icon-log-out text-lg"></i>
</a>
</div>
@@ -121,7 +121,7 @@
<div class="truncate">Moonlight v2.1</div>
</div>
<button @onclick="Layout.ToggleMobileNavigation" aria-label="Close navigation" type="button"
<button @onclick="Layout.ToggleMobileNavigationAsync" aria-label="Close navigation" type="button"
class="relative flex min-w-0 items-center gap-3 rounded-lg p-2 text-left text-base/6 text-base-content">
<i class="icon-x text-lg"></i>
</button>
@@ -180,7 +180,7 @@
<div class="flex flex-col gap-0.5">
<div class="relative">
<a class="flex w-full items-center gap-3 rounded-lg px-2 py-2.5 text-left text-base/6 sm:py-2 sm:text-sm/5 text-base-content"
href="#" @onclick:preventDefault @onclick="Logout">
href="#" @onclick:preventDefault @onclick="LogoutAsync">
<i class="icon-log-out"></i>
<span class="truncate">Logout</span>
</a>
@@ -252,13 +252,13 @@
if (!Layout.ShowMobileNavigation)
return;
await Layout.ToggleMobileNavigation();
await Layout.ToggleMobileNavigationAsync();
};
return Task.CompletedTask;
}
private Task Logout()
private Task LogoutAsync()
{
Navigation.NavigateTo("/api/auth/logout", true);
return Task.CompletedTask;

View File

@@ -7,7 +7,7 @@
<div class="flex h-screen justify-center items-center">
<div class="sm:min-w-md">
<div class="bg-base-100 shadow-base-300/20 z-1 w-full space-y-6 rounded-xl p-6 shadow-md lg:p-8">
<LazyLoader EnableDefaultSpacing="false" Load="Load">
<LazyLoader EnableDefaultSpacing="false" Load="LoadAsync">
@if (ShowSelection)
{
<div class="flex justify-center items-center gap-3">
@@ -34,7 +34,7 @@
if (config == null) // Ignore all schemes which have no ui configured
continue;
<button @onclick="() => Start(scheme)" class="btn btn-text w-full"
<button @onclick="() => StartAsync(scheme)" class="btn btn-text w-full"
style="background-color: @(config.Color)">
<img src="@config.IconUrl"
alt="scheme icon"
@@ -71,7 +71,7 @@
};
}
private async Task Load(LazyLoader arg)
private async Task LoadAsync(LazyLoader arg)
{
AuthSchemes = await ApiClient.GetJson<AuthSchemeResponse[]>(
"api/auth"
@@ -82,12 +82,12 @@
// showing the selection screen
if (AuthSchemes.Length == 1)
await Start(AuthSchemes[0]);
await StartAsync(AuthSchemes[0]);
else
ShowSelection = true;
}
private Task Start(AuthSchemeResponse scheme)
private Task StartAsync(AuthSchemeResponse scheme)
{
Navigation.NavigateTo($"/api/auth/{scheme.Identifier}", true);
return Task.CompletedTask;

View File

@@ -16,7 +16,7 @@
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Create
</WButton>
@@ -66,17 +66,17 @@
var response = await ApiClient.PostJson<CreateApiKeyResponse>("api/admin/apikeys", Request);
await DownloadService.Download(
await DownloadService.DownloadAsync(
$"moonlight-key-{response.Id}.txt",
response.Secret
);
await AlertService.Success(
await AlertService.SuccessAsync(
"API Key successfully created",
"The API Key has been downloaded. Dont lose it, you cant view it anymore"
);
await ToastService.Success("Successfully created api key");
await ToastService.SuccessAsync("Successfully created api key");
Navigation.NavigateTo("/admin/api");
}
}

View File

@@ -51,7 +51,7 @@
<DataGrid @ref="Grid"
TGridItem="ApiKeyResponse"
ItemsProvider="ItemsProvider"
ItemsProvider="ItemsProviderAsync"
EnableFiltering="true"
EnablePagination="true">
<PropertyColumn Field="x => x.Id" Sortable="true" />
@@ -92,7 +92,7 @@
{
private DataGrid<ApiKeyResponse> Grid;
private async Task<DataGridItemResult<ApiKeyResponse>> ItemsProvider(DataGridItemRequest request)
private async Task<DataGridItemResult<ApiKeyResponse>> ItemsProviderAsync(DataGridItemRequest request)
{
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
@@ -116,13 +116,13 @@
private async Task DeleteAsync(ApiKeyResponse apiKeyResponse)
{
await AlertService.ConfirmDanger(
"API Key deletion",
await AlertService.ConfirmDangerAsync(
"API Key Deletion",
$"Do you really want to delete the api key '{apiKeyResponse.Description}'",
async () =>
{
await ApiClient.Delete($"api/admin/apikeys/{apiKeyResponse.Id}");
await ToastService.Success("Successfully deleted api key");
await ToastService.SuccessAsync("Successfully deleted api key");
await Grid.RefreshAsync();
}

View File

@@ -7,13 +7,13 @@
@inject NavigationManager Navigation
@inject ToastService ToastService
<LazyLoader Load="Load">
<LazyLoader Load="LoadAsync">
<PageHeader Title="Update API Key">
<a href="/admin/api" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Update
</WButton>
@@ -40,7 +40,7 @@
private HandleForm Form;
private UpdateApiKeyRequest Request;
private async Task Load(LazyLoader _)
private async Task LoadAsync(LazyLoader _)
{
var detail = await ApiClient.GetJson<ApiKeyResponse>($"api/admin/apikeys/{Id}");
@@ -54,7 +54,7 @@
{
await ApiClient.Patch($"api/admin/apikeys/{Id}", Request);
await ToastService.Success("Successfully updated api key");
await ToastService.SuccessAsync("Successfully updated api key");
Navigation.NavigateTo("/admin/api");
}
}

View File

@@ -26,17 +26,17 @@
includes your installed theme and plugins. For more information, have a look at <a class="text-primary" href="https://help.moonlightpanel.xyz">our docs</a>
</p>
<WButton OnClick="GenerateFrontend" CssClasses="btn btn-primary mt-5">Generate frontend.zip</WButton>
<WButton OnClick="GenerateFrontendAsync" CssClasses="btn btn-primary mt-5">Generate frontend.zip</WButton>
</div>
</div>
</div>
@code
{
private async Task GenerateFrontend(WButton _)
private async Task GenerateFrontendAsync(WButton _)
{
var stream = await ApiClient.GetStream("api/admin/system/advanced/frontend");
await DownloadService.Download("frontend.zip", stream);
await DownloadService.DownloadAsync("frontend.zip", stream);
}
}

View File

@@ -30,7 +30,7 @@
<div class="my-8">
<DataGrid TGridItem="ThemeResponse"
ItemsProvider="ItemsProvider"
ItemsProvider="ItemsProviderAsync"
EnableFiltering="true"
EnablePagination="true">
@@ -105,7 +105,7 @@
{
private DataGrid<ThemeResponse> Grid;
private async Task<DataGridItemResult<ThemeResponse>> ItemsProvider(DataGridItemRequest request)
private async Task<DataGridItemResult<ThemeResponse>> ItemsProviderAsync(DataGridItemRequest request)
{
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
@@ -142,13 +142,13 @@
{
if (!file.Name.EndsWith(".json"))
{
await ToastService.Error($"Unable to import {file.Name}", "Only .json files are supported");
await ToastService.ErrorAsync($"Unable to import {file.Name}", "Only .json files are supported");
continue;
}
if (file.Size > maxFileSize)
{
await ToastService.Error($"Unable to import {file.Name}", "Exceeded the maximum file limit of 1MB");
await ToastService.ErrorAsync($"Unable to import {file.Name}", "Exceeded the maximum file limit of 1MB");
continue;
}
@@ -159,7 +159,7 @@
if (themeTransfer == null)
{
await ToastService.Error($"Unable to import {file.Name}", "Failed to deserialize the content");
await ToastService.ErrorAsync($"Unable to import {file.Name}", "Failed to deserialize the content");
continue;
}
@@ -173,7 +173,7 @@
Version = themeTransfer.Version
});
await ToastService.Success("Successfully imported theme", theme.Name);
await ToastService.SuccessAsync("Successfully imported theme", theme.Name);
await Grid.RefreshAsync();
}
@@ -203,19 +203,19 @@
var fileName = $"{transfer.Name.Replace(" ", string.Empty).Trim()}.json";
await DownloadService.Download(fileName, json);
await DownloadService.DownloadAsync(fileName, json);
}
private async Task DeleteAsync(ThemeResponse response)
{
await AlertService.ConfirmDanger(
await AlertService.ConfirmDangerAsync(
"Theme deletion",
$"Do you really want to delete the theme: {response.Name}",
async () =>
{
await ThemeService.DeleteAsync(response.Id);
await ToastService.Success("Successfully deleted theme");
await ToastService.SuccessAsync("Successfully deleted theme");
await Grid.RefreshAsync();
}
);

View File

@@ -14,7 +14,7 @@
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Create
</WButton>
@@ -59,7 +59,7 @@
private async Task OnValidSubmit()
{
await ThemeService.CreateAsync(Request);
await ToastService.Success("Successfully created theme");
await ToastService.SuccessAsync("Successfully created theme");
NavigationManager.NavigateTo("/admin/system/customisation");
}

View File

@@ -9,13 +9,13 @@
@inject ToastService ToastService
@inject NavigationManager Navigation
<LazyLoader Load="Load">
<LazyLoader Load="LoadAsync">
<PageHeader Title="@($"Update {Request.Name}")">
<a href="/admin/system/customisation" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Update
</WButton>
@@ -80,7 +80,7 @@
private HandleForm Form;
private async Task Load(LazyLoader _)
private async Task LoadAsync(LazyLoader _)
{
Response = await ThemeService.GetAsync(Id);
@@ -100,7 +100,7 @@
{
await ThemeService.UpdateAsync(Id, Request);
await ToastService.Success("Successfully updated theme");
await ToastService.SuccessAsync("Successfully updated theme");
Navigation.NavigateTo("/admin/system/customisation");
}
}

View File

@@ -28,11 +28,11 @@
If you only want to export specific parts of the diagnose report, click on "Advanced" and select the desired providers
</p>
<WButton OnClick="GenerateDiagnose" CssClasses="btn btn-primary my-5">Generate report</WButton>
<WButton OnClick="GenerateDiagnoseAsync" CssClasses="btn btn-primary my-5">Generate report</WButton>
<div class="text-sm">
<a class="text-primary cursor-pointer flex items-center" @onclick:preventDefault
@onclick="ToggleDropDown">
@onclick="ToggleDropDownAsync">
<span class="me-1.5">Advanced</span>
@if (DropdownOpen)
{
@@ -45,7 +45,7 @@
</a>
<div class="@(DropdownOpen ? "" : "hidden")">
<LazyLoader Load="Load">
<LazyLoader Load="LoadAsync">
<div class="mb-2 py-2 border-b border-base-content/70 flex items-center gap-3">
<input id="selectall_checkbox" @bind="SelectAll" type="checkbox" class="checkbox checkbox-primary checkbox-xs">
<label for="selectall_checkbox">Select all</label>
@@ -86,7 +86,7 @@
}
}
private async Task Load(LazyLoader arg)
private async Task LoadAsync(LazyLoader arg)
{
var providers = await ApiClient.GetJson<DiagnoseProvideResponse[]>(
"api/admin/system/diagnose/providers"
@@ -96,7 +96,7 @@
.ToDictionary(x => x, _ => true);
}
private async Task GenerateDiagnose(WButton button)
private async Task GenerateDiagnoseAsync(WButton button)
{
var request = new GenerateDiagnoseRequest();
@@ -111,11 +111,11 @@
var stream = await ApiClient.PostStream("api/admin/system/diagnose", request);
await DownloadService.Download("diagnose.zip", stream);
await DownloadService.DownloadAsync("diagnose.zip", stream);
}
private async Task ToggleDropDown()
private async Task ToggleDropDownAsync()
{
DropdownOpen = !DropdownOpen;
await InvokeAsync(StateHasChanged);

View File

@@ -19,7 +19,7 @@
</HelperMessage>
</div>
<LazyLoader Load="Load">
<LazyLoader Load="LoadAsync">
<div class="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4 gap-5">
<StatCard Title="Servers" Text="@Stats.Servers.ToString()" Icon="icon-server"/>
<StatCard Title="Recurring" Text="@Stats.Recurring.ToString()" Icon="icon-calendar-sync"/>
@@ -39,7 +39,7 @@
{
private HangfireStatsResponse Stats;
private async Task Load(LazyLoader _)
private async Task LoadAsync(LazyLoader _)
{
Stats = await ApiClient.GetJson<HangfireStatsResponse>(
"api/admin/system/hangfire/stats"

View File

@@ -13,7 +13,7 @@
<NavTabs Index="0" Names="UiConstants.AdminNavNames" Links="UiConstants.AdminNavLinks" />
</div>
<LazyLoader Load="LoadOverview">
<LazyLoader Load="LoadOverviewAsync">
<div class="gap-5 grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-4">
<StatCard Title="CPU Usage" Text="@(OverviewData.CpuUsage + "%")" Icon="icon-cpu"/>
<StatCard Title="Memory Usage" Text="@(Formatter.FormatSize(OverviewData.MemoryUsage))" Icon="icon-memory-stick"/>
@@ -28,7 +28,7 @@
<div class="flex">
<div class="card card-body">
<div class="flex justify-center">
<WButton OnClick="Restart" CssClasses="btn btn-error w-full">
<WButton OnClick="RestartAsync" CssClasses="btn btn-error w-full">
<i class="icon-repeat me-2"></i>
Restart/Shutdown
</WButton>
@@ -41,12 +41,12 @@
{
private SystemOverviewResponse OverviewData;
private async Task LoadOverview(LazyLoader arg)
private async Task LoadOverviewAsync(LazyLoader arg)
{
OverviewData = await ApiClient.GetJson<SystemOverviewResponse>("api/admin/system");
}
private async Task Restart(WButton _)
private async Task RestartAsync(WButton _)
{
await ApiClient.Post("api/admin/system/shutdown");
}

View File

@@ -12,7 +12,7 @@
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Create
</WButton>
@@ -67,7 +67,7 @@
await ApiClient.Post("api/admin/users", Request);
await ToastService.Success("Successfully created user");
await ToastService.SuccessAsync("Successfully created user");
Navigation.NavigateTo("/admin/users");
}
}

View File

@@ -20,7 +20,7 @@
<DataGrid @ref="Grid"
TGridItem="UserResponse"
ItemsProvider="ItemsProvider"
ItemsProvider="ItemsProviderAsync"
EnableFiltering="true"
EnablePagination="true">
<PropertyColumn Field="x => x.Id" Sortable="true" />
@@ -46,7 +46,7 @@
{
private DataGrid<UserResponse> Grid;
private async Task<DataGridItemResult<UserResponse>> ItemsProvider(DataGridItemRequest request)
private async Task<DataGridItemResult<UserResponse>> ItemsProviderAsync(DataGridItemRequest request)
{
var query = $"?startIndex={request.StartIndex}&count={request.Count}";
@@ -70,13 +70,13 @@
private async Task DeleteAsync(UserResponse response)
{
await AlertService.ConfirmDanger(
await AlertService.ConfirmDangerAsync(
"User deletion",
$"Do you really want to delete the user '{response.Username}'",
async () =>
{
await ApiClient.Delete($"api/admin/users/{response.Id}");
await ToastService.Success("Successfully deleted user");
await ToastService.SuccessAsync("Successfully deleted user");
await Grid.RefreshAsync();
}

View File

@@ -8,13 +8,13 @@
@inject NavigationManager Navigation
@inject ToastService ToastService
<LazyLoader Load="Load">
<LazyLoader Load="LoadAsync">
<PageHeader Title="Update User">
<a href="/admin/users" class="btn btn-secondary">
<i class="icon-chevron-left"></i>
Back
</a>
<WButton OnClick="_ => Form.Submit()" CssClasses="btn btn-primary">
<WButton OnClick="Form.SubmitAsync" CssClasses="btn btn-primary">
<i class="icon-check"></i>
Update
</WButton>
@@ -62,7 +62,7 @@
private List<string> Permissions = [];
private async Task Load(LazyLoader _)
private async Task LoadAsync(LazyLoader _)
{
var detail = await ApiClient.GetJson<UserResponse>($"api/admin/users/{Id}");
@@ -82,7 +82,7 @@
await ApiClient.Patch($"api/admin/users/{Id}", Request);
await ToastService.Success("Successfully updated user");
await ToastService.SuccessAsync("Successfully updated user");
Navigation.NavigateTo("/admin/users");
}
}