added some informations

This commit is contained in:
Moritz 2024-05-14 14:52:27 +02:00
parent 3270039a6a
commit 7225db0bf1
3 changed files with 9 additions and 1 deletions

View file

@ -208,8 +208,13 @@ public class CoreFeature : MoonlightFeature
context.AddSidebarItem("Users", "bxs-group", "/admin/users", needsExactMatch: false, isAdmin: true);
context.AddSidebarItem("System", "bxs-component", "/admin/sys", needsExactMatch: false, isAdmin: true);
// With this function, you can add an Admin Card to the Admin Page
// It references the Admin Card, which is a Razor component.
context.AddAdminCard<AdminUserCard>(index: int.MinValue);
// Same Thing could be used with the context.AddAdminComponent Function, which then renders the component
// under the cards, for fast informations
return Task.CompletedTask;
}

View file

@ -24,6 +24,7 @@ public class UiInitContext
public void AddAdminComponent<T>(int index = 0, int requiredPermissionLevel = 0) where T : IComponent
{
// Loads the Component into a List of AdminComponents, with lots of more information for the Admin Page to render
AdminPageComponents.Add(
new AdminComponent()
{
@ -40,6 +41,7 @@ public class UiInitContext
public void AddAdminCard<T>(int index = 0, int requiredPermissionLevel = 0) where T : IComponent
{
// Loads the Card into a List of AdminComponents, with lots of more information for the Admin Page to render
AdminPageCards.Add(
new AdminComponent()
{

View file

@ -15,6 +15,8 @@
<div class="row mb-4">
@foreach (var adminCard in FeatureService.UiContext.AdminPageCards.OrderBy(x => x.Index).ToArray())
{
// basically renders the component if the permissions of the viewed item is lower or equal
// to the users permission, -> better developer experience for feature devs
if (IdentityService.CurrentUser.Permissions >= adminCard.RequiredPermissionLevel)
{
<div class="col-12 col-lg-6 col-xl">
@ -41,6 +43,5 @@
private async Task Load(LazyLoader arg)
{
await arg.SetText("Loading Information...");
}
}