From 160de6443b6414ec68ad414e6ba744d5d1f998a2 Mon Sep 17 00:00:00 2001 From: Moritz <101179677+Moritz-Deiaco@users.noreply.github.com> Date: Mon, 13 May 2024 18:38:52 +0200 Subject: [PATCH] Added Basic Admin Page, will still be adding more in the future --- Moonlight/Core/CoreFeature.cs | 6 ++ Moonlight/Core/UI/Views/Admin/Index.razor | 71 +++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Moonlight/Core/UI/Views/Admin/Index.razor diff --git a/Moonlight/Core/CoreFeature.cs b/Moonlight/Core/CoreFeature.cs index f8513fa..df698bf 100644 --- a/Moonlight/Core/CoreFeature.cs +++ b/Moonlight/Core/CoreFeature.cs @@ -114,6 +114,12 @@ public class CoreFeature : MoonlightFeature // Define permissions var permissionService = app.Services.GetRequiredService(); + 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", diff --git a/Moonlight/Core/UI/Views/Admin/Index.razor b/Moonlight/Core/UI/Views/Admin/Index.razor new file mode 100644 index 0000000..45de84b --- /dev/null +++ b/Moonlight/Core/UI/Views/Admin/Index.razor @@ -0,0 +1,71 @@ +@page "/admin" +@using MoonCore.Abstractions +@using Moonlight.Core.Database.Entities +@using Moonlight.Features.Servers.Entities + +@inject Repository ServerRepository +@inject Repository UserRepository + +@attribute [RequirePermission(999)] + + + + + +@* This is just the start of this admin page, there will still be added more during the developement process *@ + +@code { + private List Servers; + private List Users; + + private async Task Load(LazyLoader arg) + { + await Task.Run(() => + { + arg.SetText("Loading Information..."); + Servers = ServerRepository.Get().ToList(); + Users = UserRepository.Get().ToList(); + }); + } +} \ No newline at end of file