Adjusted file upload size. Fixed allocations tab. Implemented server tab path handling

This commit is contained in:
2025-04-09 20:47:49 +02:00
parent e274f1fdd8
commit f0948960b7
3 changed files with 66 additions and 21 deletions

View File

@@ -31,8 +31,10 @@
</div> </div>
</div> </div>
<div class="col-span-1 md:col-span-2 -mb-3"> <div class="col-span-1 md:col-span-2 -mb-3">
<DataTable @ref="Table" TItem="NodeAllocationDetailResponse" LoadItemsPaginatedAsync="LoadData"> <DataTable @ref="Table" TItem="NodeAllocationDetailResponse">
<Configuration> <Configuration>
<Pagination TItem="NodeAllocationDetailResponse" ItemSource="LoadData" />
<DataTableColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.IpAddress)" Name="IP Address"/> <DataTableColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.IpAddress)" Name="IP Address"/>
<DataTableColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.Port)" Name="Port"/> <DataTableColumn TItem="NodeAllocationDetailResponse" Field="@(x => x.Port)" Name="Port"/>
<DataTableColumn TItem="NodeAllocationDetailResponse"> <DataTableColumn TItem="NodeAllocationDetailResponse">

View File

@@ -8,7 +8,7 @@
@inject ServerFileSystemService FileSystemService @inject ServerFileSystemService FileSystemService
@inject DownloadService DownloadService @inject DownloadService DownloadService
<FileManager FileSystemProvider="Provider"/> <FileManager FileSystemProvider="Provider" MaxUploadSize="4096"/>
@code @code
{ {

View File

@@ -1,4 +1,5 @@
@page "/servers/{ServerId:int}" @page "/servers/{ServerId:int}"
@page "/servers/{ServerId:int}/{TabPath:alpha}"
@using Microsoft.AspNetCore.SignalR.Client @using Microsoft.AspNetCore.SignalR.Client
@using MoonlightServers.Shared.Http.Responses.Users.Servers @using MoonlightServers.Shared.Http.Responses.Users.Servers
@@ -9,10 +10,9 @@
@using MoonlightServers.Frontend.Models @using MoonlightServers.Frontend.Models
@using MoonlightServers.Frontend.Services @using MoonlightServers.Frontend.Services
@using MoonlightServers.Shared.Enums @using MoonlightServers.Shared.Enums
@using MoonlightServers.Frontend.UI.Components
@using MoonlightServers.Frontend.UI.Components.Servers.ServerTabs
@inject ServerService ServerService @inject ServerService ServerService
@inject NavigationManager Navigation
@inject IEnumerable<IServerTabProvider> TabProviders @inject IEnumerable<IServerTabProvider> TabProviders
@implements IAsyncDisposable @implements IAsyncDisposable
@@ -124,12 +124,31 @@
</div> </div>
<div class="mt-3"> <div class="mt-3">
<Tabs> <ul class="flex flex-wrap -m-1">
@foreach (var tab in Tabs) @foreach (var tab in Tabs)
{ {
<Tab Name="@tab.Name"> <li class="m-1">
@if (tab == CurrentTab)
{
<a href="/servers/@(ServerId)/@(tab.Path)"
class="inline-flex items-center justify-center text-sm font-medium leading-5 rounded-full px-3 py-1 border border-transparent shadow-sm bg-gray-100 text-gray-800 transition">
@tab.Name
</a>
}
else
{
<a href="/servers/@(ServerId)/@(tab.Path)" @onclick:preventDefault
@onclick="() => SwitchTab(tab)"
class="inline-flex items-center justify-center text-sm font-medium leading-5 rounded-full px-3 py-1 border border-gray-700/60 hover:border-gray-600 shadow-sm bg-gray-800 text-gray-400 transition">
@tab.Name
</a>
}
</li>
}
</ul>
@{ @{
var rf = ComponentHelper.FromType(tab.ComponentType, parameters => var rf = ComponentHelper.FromType(CurrentTab!.ComponentType, parameters =>
{ {
parameters.Add("Server", Server); parameters.Add("Server", Server);
parameters.Add("State", State); parameters.Add("State", State);
@@ -139,10 +158,9 @@
}); });
} }
<div class="mt-5">
@rf @rf
</Tab> </div>
}
</Tabs>
</div> </div>
} }
</LazyLoader> </LazyLoader>
@@ -150,8 +168,10 @@
@code @code
{ {
[Parameter] public int ServerId { get; set; } [Parameter] public int ServerId { get; set; }
[Parameter] public string? TabPath { get; set; }
private List<ServerTab> Tabs = new(); private ServerTab[] Tabs;
private ServerTab? CurrentTab;
private ServerDetailResponse Server; private ServerDetailResponse Server;
private bool NotFound = false; private bool NotFound = false;
@@ -168,8 +188,23 @@
Server = await ServerService.GetServer(ServerId); Server = await ServerService.GetServer(ServerId);
// Load server tabs // Load server tabs
var tmpTabs = new List<ServerTab>();
foreach (var serverTabProvider in TabProviders) foreach (var serverTabProvider in TabProviders)
Tabs.AddRange(await serverTabProvider.GetTabs(Server)); tmpTabs.AddRange(await serverTabProvider.GetTabs(Server));
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.First();
// Load initial status for first render // Load initial status for first render
var status = await ServerService.GetStatus(ServerId); var status = await ServerService.GetStatus(ServerId);
@@ -224,6 +259,14 @@
} }
} }
private async Task SwitchTab(ServerTab tab)
{
CurrentTab = tab;
Navigation.NavigateTo($"/servers/{ServerId}/{tab.Path}");
await InvokeAsync(StateHasChanged);
}
private async Task Start() private async Task Start()
=> await ServerService.Start(ServerId); => await ServerService.Start(ServerId);