Refactored frontend to work with the latest mooncore changes
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Blazor.Tailwind.Components
|
||||
@using MoonCore.Blazor.Tailwind.Toasts
|
||||
@using MoonCore.Helpers
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
||||
|
||||
@@ -29,15 +27,15 @@
|
||||
<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-white">Name</label>
|
||||
<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="form-input w-full">
|
||||
<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-white">Author</label>
|
||||
<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="form-input w-full">
|
||||
<input @bind="Request.Author" type="text" autocomplete="off" class="input w-full">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,15 +4,11 @@
|
||||
@using MoonCore.Blazor.FlyonUi.DataTables
|
||||
@using MoonCore.Blazor.FlyonUi.Helpers
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Blazor.Tailwind.Alerts
|
||||
@using MoonCore.Helpers
|
||||
@using MoonCore.Models
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||
@using MoonCore.Blazor.Tailwind.Components
|
||||
@using MoonCore.Blazor.Tailwind.Dt
|
||||
@using MoonCore.Blazor.Tailwind.Services
|
||||
@using MoonCore.Blazor.Tailwind.Toasts
|
||||
@using MoonCore.Exceptions
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
|
||||
@inject HttpApiClient ApiClient
|
||||
@inject DownloadService DownloadService
|
||||
@@ -28,7 +24,7 @@
|
||||
<div class="mb-5">
|
||||
<PageHeader Title="Stars">
|
||||
<InputFile id="import-file" hidden="" multiple OnChange="OnImportFiles"/>
|
||||
<label for="import-file" class="btn btn-tertiary cursor-pointer">
|
||||
<label for="import-file" class="btn btn-accent cursor-pointer">
|
||||
<i class="icon-file-up mr-2"></i>
|
||||
Import
|
||||
</label>
|
||||
@@ -58,7 +54,7 @@
|
||||
<div class="flex justify-end">
|
||||
@if (!string.IsNullOrEmpty(context.DonateUrl))
|
||||
{
|
||||
<a href="@context.DonateUrl" target="_blank" class="text-red-500 mr-3">
|
||||
<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>
|
||||
@@ -66,7 +62,7 @@
|
||||
|
||||
@if (!string.IsNullOrEmpty(context.UpdateUrl))
|
||||
{
|
||||
<a href="#" @onclick:preventDefault class="text-tertiary mr-3">
|
||||
<a href="#" @onclick:preventDefault class="text-accent mr-3">
|
||||
<i class="icon-refresh-cw align-middle"></i>
|
||||
<span class="align-middle">Update</span>
|
||||
</a>
|
||||
@@ -82,7 +78,7 @@
|
||||
</a>
|
||||
|
||||
<a href="#" @onclick="() => Delete(context)" @onclick:preventDefault
|
||||
class="text-danger">
|
||||
class="text-error">
|
||||
<i class="icon-trash text-base"></i>
|
||||
</a>
|
||||
</div>
|
||||
@@ -119,7 +115,7 @@
|
||||
|
||||
var formattedFileName = star.Name.Replace(" ", "_") + ".json";
|
||||
|
||||
await DownloadService.DownloadString(formattedFileName, json);
|
||||
await DownloadService.Download(formattedFileName, json);
|
||||
await ToastService.Success($"Successfully exported '{star.Name}'");
|
||||
}
|
||||
|
||||
@@ -141,7 +137,7 @@
|
||||
{
|
||||
if (!file.Name.EndsWith(".json"))
|
||||
{
|
||||
await ToastService.Danger($"Failed to import '{file.Name}': Only json files are supported");
|
||||
await ToastService.Error($"Failed to import '{file.Name}': Only json files are supported");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -155,7 +151,7 @@
|
||||
}
|
||||
catch (HttpApiException e)
|
||||
{
|
||||
await ToastService.Danger($"Failed to import '{file.Name}': {e.Title}");
|
||||
await ToastService.Error($"Failed to import '{file.Name}': {e.Title}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
@using MoonCore.Blazor.FlyonUi.Components
|
||||
@using MoonCore.Blazor.FlyonUi.Toasts
|
||||
@using MoonCore.Blazor.Tailwind.Components
|
||||
@using MoonCore.Blazor.Tailwind.Toasts
|
||||
@using MoonCore.Helpers
|
||||
@using MoonlightServers.Shared.Http.Requests.Admin.Stars
|
||||
@using MoonlightServers.Shared.Http.Responses.Admin.Stars
|
||||
@@ -75,7 +73,24 @@
|
||||
private async Task Load(LazyLoader _)
|
||||
{
|
||||
Detail = await ApiClient.GetJson<StarDetailResponse>($"api/admin/servers/stars/{Id}");
|
||||
Request = Mapper.Map<UpdateStarRequest>(Detail);
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user