Added Basic Admin Page, will still be adding more in the future

This commit is contained in:
Moritz 2024-05-13 18:38:52 +02:00
parent 8dc37525ce
commit 160de6443b
2 changed files with 77 additions and 0 deletions

View file

@ -114,6 +114,12 @@ public class CoreFeature : MoonlightFeature
// Define permissions // Define permissions
var permissionService = app.Services.GetRequiredService<PermissionService>(); var permissionService = app.Services.GetRequiredService<PermissionService>();
await permissionService.Register(999, new()
{
Name = "See Admin Page",
Description = "Allows access to the admin page and the connected stats (server and user count)"
});
await permissionService.Register(1000, new() await permissionService.Register(1000, new()
{ {
Name = "Manage users", Name = "Manage users",

View file

@ -0,0 +1,71 @@
@page "/admin"
@using MoonCore.Abstractions
@using Moonlight.Core.Database.Entities
@using Moonlight.Features.Servers.Entities
@inject Repository<Server> ServerRepository
@inject Repository<User> UserRepository
@attribute [RequirePermission(999)]
<LazyLoader Load="Load">
<div class="row">
<div class="col-12 col-lg-6 col-xl">
<a class="mt-4 card" href="/admin/servers">
<div class="card-body">
<div class="row align-items-center gx-0">
<div class="col">
<h6 class="text-uppercase text-muted mb-2">
Users
</h6>
<span class="h2 mb-0">@Users.Count</span>
</div>
<div class="col-auto">
<span class="h2 text-muted mb-0">
<i class="text-primary bx bxs-group bx-lg"></i>
</span>
</div>
</div>
</div>
</a>
</div>
<div class="col-12 col-lg-6 col-xl">
<a class="mt-4 card" href="/admin/users">
<div class="card-body">
<div class="row align-items-center gx-0">
<div class="col">
<h6 class="text-uppercase text-muted mb-2">
Servers
</h6>
<span class="h2 mb-0">
@Servers.Count
</span>
</div>
<div class="col-auto">
<span class="h2 text-muted mb-0">
<i class="text-primary bx bx-server bx-lg"></i>
</span>
</div>
</div>
</div>
</a>
</div>
</div>
</LazyLoader>
@* This is just the start of this admin page, there will still be added more during the developement process *@
@code {
private List<Server> Servers;
private List<User> Users;
private async Task Load(LazyLoader arg)
{
await Task.Run(() =>
{
arg.SetText("Loading Information...");
Servers = ServerRepository.Get().ToList();
Users = UserRepository.Get().ToList();
});
}
}