Added a way to sort the admin components with an index

This commit is contained in:
Moritz 2024-05-19 14:27:45 +02:00
parent e79f2199c3
commit 769c876dc5
13 changed files with 79 additions and 57 deletions

View file

@ -7,9 +7,10 @@ using MoonCoreUI.Services;
using Moonlight.Core.Configuration;
using Moonlight.Core.Database;
using Moonlight.Core.Database.Entities;
using Moonlight.Core.Implementations.AdminColumns;
using Moonlight.Core.Implementations.Diagnose;
using Moonlight.Core.Implementations.UI.Admin.AdminColumns;
using Moonlight.Core.Interfaces;
using Moonlight.Core.Interfaces.Ui.Admin;
using Moonlight.Core.Models;
using Moonlight.Core.Models.Abstractions;
using Moonlight.Core.Models.Abstractions.Feature;

View file

@ -1,16 +0,0 @@
using Microsoft.AspNetCore.Components;
using MoonCoreUI.Helpers;
using Moonlight.Core.Interfaces;
using Moonlight.Core.UI.Components.Cards;
namespace Moonlight.Core.Implementations.AdminColumns;
public class UserCount : IAdminDashboardColumn
{
public Task<RenderFragment> Get()
{
var res = ComponentHelper.FromType<AdminUserCard>();
return Task.FromResult(res);
}
}

View file

@ -0,0 +1,20 @@
using MoonCoreUI.Helpers;
using Moonlight.Core.Interfaces.Ui.Admin;
using Moonlight.Core.Models.Abstractions;
using Moonlight.Core.UI.Components.Cards;
namespace Moonlight.Core.Implementations.UI.Admin.AdminColumns;
public class UserCount : IAdminDashboardColumn
{
public Task<UiComponent> Get()
{
var res = new UiComponent()
{
Component = ComponentHelper.FromType<AdminUserCard>(),
Index = int.MinValue
};
return Task.FromResult(res);
}
}

View file

@ -1,8 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace Moonlight.Core.Interfaces;
public interface IAdminDashboardColumn
{
public Task<RenderFragment> Get();
}

View file

@ -1,8 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace Moonlight.Core.Interfaces;
public interface IAdminDashboardComponent
{
public Task<RenderFragment> Get();
}

View file

@ -0,0 +1,8 @@
using Moonlight.Core.Models.Abstractions;
namespace Moonlight.Core.Interfaces.Ui.Admin;
public interface IAdminDashboardColumn
{
public Task<UiComponent> Get();
}

View file

@ -0,0 +1,8 @@
using Moonlight.Core.Models.Abstractions;
namespace Moonlight.Core.Interfaces.Ui.Admin;
public interface IAdminDashboardComponent
{
public Task<UiComponent> Get();
}

View file

@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Components;
namespace Moonlight.Core.Models.Abstractions;
public class UiComponent
{
public required RenderFragment Component { get; set; }
public int Index { get; set; } = 0;
}

View file

@ -2,6 +2,8 @@
@using MoonCore.Abstractions
@using Moonlight.Core.Database.Entities
@using Moonlight.Core.Interfaces
@using Moonlight.Core.Interfaces.Ui.Admin
@using Moonlight.Core.Models.Abstractions
@using Moonlight.Core.Services
@using Moonlight.Features.Servers.Entities
@ -11,17 +13,17 @@
<LazyLoader Load="Load">
<div class="row mb-8">
@foreach(var column in Columns)
@foreach(var column in Columns.OrderBy(x => x.Index))
{
<div class="col-12 col-lg-6 col-xl">
@column
@column.Component
</div>
}
</div>
@foreach (var component in Components)
@foreach (var component in Components.OrderBy(x => x.Index))
{
<div class="mb-4">
@component
@component.Component
</div>
}
</LazyLoader>
@ -29,8 +31,8 @@
@code {
private List<RenderFragment> Columns = new();
private List<RenderFragment> Components = new();
private List<UiComponent> Columns = new();
private List<UiComponent> Components = new();
private async Task Load(LazyLoader arg)
{

View file

@ -1,16 +0,0 @@
using Microsoft.AspNetCore.Components;
using MoonCoreUI.Helpers;
using Moonlight.Core.Interfaces;
using Moonlight.Features.Servers.UI.Components.Cards;
namespace Moonlight.Features.Servers.Implementations.AdminColumns;
public class ServerCount : IAdminDashboardColumn
{
public Task<RenderFragment> Get()
{
var res = ComponentHelper.FromType<AdminServersCard>();
return Task.FromResult(res);
}
}

View file

@ -0,0 +1,19 @@
using MoonCoreUI.Helpers;
using Moonlight.Core.Interfaces.Ui.Admin;
using Moonlight.Core.Models.Abstractions;
using Moonlight.Features.Servers.UI.Components.Cards;
namespace Moonlight.Features.Servers.Implementations.UI.Admin.AdminColumns;
public class ServerCount : IAdminDashboardColumn
{
public Task<UiComponent> Get()
{
var res = new UiComponent()
{
Component = ComponentHelper.FromType<AdminServersCard>()
};
return Task.FromResult(res);
}
}

View file

@ -2,13 +2,14 @@ using MoonCore.Helpers;
using MoonCore.Services;
using Moonlight.Core.Configuration;
using Moonlight.Core.Interfaces;
using Moonlight.Core.Interfaces.Ui.Admin;
using Moonlight.Core.Models.Abstractions.Feature;
using Moonlight.Core.Services;
using Moonlight.Features.Servers.Actions;
using Moonlight.Features.Servers.Configuration;
using Moonlight.Features.Servers.Http.Middleware;
using Moonlight.Features.Servers.Implementations.AdminColumns;
using Moonlight.Features.Servers.Implementations.Diagnose;
using Moonlight.Features.Servers.Implementations.UI.Admin.AdminColumns;
using Moonlight.Features.Servers.Models.Enums;
using Moonlight.Features.Servers.Services;
using Moonlight.Features.Servers.UI.Components.Cards;

View file

@ -53,7 +53,7 @@
<Folder Include="Core\Database\Migrations\" />
<Folder Include="Core\Http\Requests\" />
<Folder Include="Core\Http\Resources\" />
<Folder Include="Core\Implementations\AdminComponents\" />
<Folder Include="Core\Implementations\UI\Admin\AdminComponents\" />
<Folder Include="Core\UI\Components\Forms\" />
<Folder Include="Features\Dummy\Configuration\" />
<Folder Include="Features\Dummy\Entities\" />
@ -75,6 +75,7 @@
<Folder Include="Features\FileManager\Http\Requests\" />
<Folder Include="Features\FileManager\Http\Resources\" />
<Folder Include="Features\Servers\Http\Resources\" />
<Folder Include="Features\Servers\Implementations\UI\Admin\" />
<Folder Include="storage\" />
<Folder Include="Styles\" />
<Folder Include="wwwroot\css\" />