Merge pull request #406 from Moonlight-Panel/v2_AddAdminPage

Added Basic Admin Page, will still be adding more in the future
This commit is contained in:
Masu Baumgartner 2024-05-14 00:46:27 +02:00 committed by GitHub
commit 45e81c98bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 79 additions and 0 deletions

View file

@ -114,6 +114,12 @@ public class CoreFeature : MoonlightFeature
// Define permissions
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()
{
Name = "Manage users",

View file

@ -0,0 +1,73 @@
@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">
@UserCount
</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">
@ServerCount
</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 int ServerCount;
private int UserCount;
private async Task Load(LazyLoader arg)
{
await Task.Run(() =>
{
arg.SetText("Loading Information...");
ServerCount = ServerRepository.Get().Count();
UserCount = UserRepository.Get().Count();
});
}
}