mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-23 21:51:29 +00:00
Add banned users and hidden levels page to mod panel
This commit is contained in:
parent
4be8efc244
commit
67bad4fd1e
8 changed files with 178 additions and 3 deletions
|
@ -24,4 +24,10 @@
|
||||||
<data name="greeting" xml:space="preserve">
|
<data name="greeting" xml:space="preserve">
|
||||||
<value>Welcome to the moderation panel, {0}!</value>
|
<value>Welcome to the moderation panel, {0}!</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="banned_users" xml:space="preserve">
|
||||||
|
<value>Banned Users</value>
|
||||||
|
</data>
|
||||||
|
<data name="hidden_levels" xml:space="preserve">
|
||||||
|
<value>Hidden Levels</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -4,6 +4,8 @@ public static class ModPanelStrings
|
||||||
{
|
{
|
||||||
public static readonly TranslatableString ModPanelTitle = create("mod_panel_title");
|
public static readonly TranslatableString ModPanelTitle = create("mod_panel_title");
|
||||||
public static readonly TranslatableString Greeting = create("greeting");
|
public static readonly TranslatableString Greeting = create("greeting");
|
||||||
|
public static readonly TranslatableString BannedUsers = create("banned_users");
|
||||||
|
public static readonly TranslatableString HiddenLevels = create("hidden_levels");
|
||||||
|
|
||||||
private static TranslatableString create(string key) => new(TranslationAreas.ModPanel, key);
|
private static TranslatableString create(string key) => new(TranslationAreas.ModPanel, key);
|
||||||
}
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
@page "/moderation/bannedUsers/{pageNumber:int}"
|
||||||
|
@using LBPUnion.ProjectLighthouse.Extensions
|
||||||
|
@using LBPUnion.ProjectLighthouse.Localization.StringLists
|
||||||
|
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
|
||||||
|
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation.BannedUsersPage
|
||||||
|
|
||||||
|
@{
|
||||||
|
Layout = "Layouts/BaseLayout";
|
||||||
|
Model.Title = Model.Translate(ModPanelStrings.BannedUsers);
|
||||||
|
bool isMobile = Model.Request.IsMobile();
|
||||||
|
}
|
||||||
|
|
||||||
|
<p>There are @Model.UserCount banned users.</p>
|
||||||
|
|
||||||
|
@foreach (User user in Model.Users)
|
||||||
|
{
|
||||||
|
<div class="ui segment">
|
||||||
|
@await Html.PartialAsync("Partials/UserCardPartial", user, new ViewDataDictionary(ViewData)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"ShowLink", true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"IsMobile", isMobile
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Language", Model.GetLanguage()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (Model.PageNumber != 0)
|
||||||
|
{
|
||||||
|
<a href="/moderation/bannedUsers/@(Model.PageNumber - 1)">Previous Page</a>
|
||||||
|
}
|
||||||
|
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||||
|
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||||
|
{
|
||||||
|
<a href="/moderation/bannedUsers/@(Model.PageNumber + 1)">Next Page</a>
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
|
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||||
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||||
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
||||||
|
|
||||||
|
public class BannedUsersPage : BaseLayout
|
||||||
|
{
|
||||||
|
public BannedUsersPage(Database database) : base(database)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public List<User> Users = new();
|
||||||
|
|
||||||
|
public int PageAmount;
|
||||||
|
|
||||||
|
public int PageNumber;
|
||||||
|
|
||||||
|
public int UserCount;
|
||||||
|
|
||||||
|
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||||
|
{
|
||||||
|
WebToken? token = this.Database.WebTokenFromRequest(this.Request);
|
||||||
|
if (token == null) return this.Redirect("/login");
|
||||||
|
|
||||||
|
this.Users = await this.Database.Users
|
||||||
|
.Where(u => u.PermissionLevel < 0)
|
||||||
|
.Skip(pageNumber * ServerStatics.PageSize)
|
||||||
|
.Take(ServerStatics.PageSize)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
this.UserCount = await this.Database.Users.CountAsync(u => u.PermissionLevel < 0);
|
||||||
|
|
||||||
|
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.UserCount / ServerStatics.PageSize));
|
||||||
|
|
||||||
|
return this.Page();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
@page "/moderation/hiddenLevels/{pageNumber:int}"
|
||||||
|
@using LBPUnion.ProjectLighthouse.Extensions
|
||||||
|
@using LBPUnion.ProjectLighthouse.Levels
|
||||||
|
@using LBPUnion.ProjectLighthouse.Localization.StringLists
|
||||||
|
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation.HiddenLevelsPage
|
||||||
|
|
||||||
|
@{
|
||||||
|
Layout = "Layouts/BaseLayout";
|
||||||
|
Model.Title = Model.Translate(ModPanelStrings.HiddenLevels);
|
||||||
|
bool isMobile = Model.Request.IsMobile();
|
||||||
|
}
|
||||||
|
|
||||||
|
<p>There are @Model.SlotCount hidden levels.</p>
|
||||||
|
|
||||||
|
@foreach (Slot slot in Model.Slots)
|
||||||
|
{
|
||||||
|
<div class="ui segment">
|
||||||
|
@await Html.PartialAsync("Partials/SlotCardPartial", slot, new ViewDataDictionary(ViewData)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"User", Model.User
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"CallbackUrl", $"~/moderation/hiddenLevels/{Model.PageNumber}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ShowLink", true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"IsMobile", isMobile
|
||||||
|
},
|
||||||
|
})
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (Model.PageNumber != 0)
|
||||||
|
{
|
||||||
|
<a href="/moderation/hiddenLevels/@(Model.PageNumber - 1)">Previous Page</a>
|
||||||
|
}
|
||||||
|
@(Model.PageNumber + 1) / @(Model.PageAmount)
|
||||||
|
@if (Model.PageNumber < Model.PageAmount - 1)
|
||||||
|
{
|
||||||
|
<a href="/moderation/hiddenLevels/@(Model.PageNumber + 1)">Next Page</a>
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
|
using LBPUnion.ProjectLighthouse.Levels;
|
||||||
|
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||||
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
||||||
|
|
||||||
|
public class HiddenLevelsPage : BaseLayout
|
||||||
|
{
|
||||||
|
public HiddenLevelsPage(Database database) : base(database)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public int PageAmount;
|
||||||
|
|
||||||
|
public int PageNumber;
|
||||||
|
|
||||||
|
public int SlotCount;
|
||||||
|
|
||||||
|
public List<Slot> Slots = new();
|
||||||
|
|
||||||
|
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||||
|
{
|
||||||
|
WebToken? token = this.Database.WebTokenFromRequest(this.Request);
|
||||||
|
if (token == null) return this.Redirect("/login");
|
||||||
|
|
||||||
|
this.Slots = await this.Database.Slots
|
||||||
|
.Where(s => s.Hidden)
|
||||||
|
.Skip(pageNumber * ServerStatics.PageSize)
|
||||||
|
.Take(ServerStatics.PageSize)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
this.SlotCount = await this.Database.Slots.CountAsync(s => s.Hidden);
|
||||||
|
|
||||||
|
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.SlotCount / ServerStatics.PageSize));
|
||||||
|
|
||||||
|
return this.Page();
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,12 +42,12 @@ else
|
||||||
|
|
||||||
<h2>Actions</h2>
|
<h2>Actions</h2>
|
||||||
|
|
||||||
<a href="/moderation/bannedUsers" class="ui red button">
|
<a href="/moderation/bannedUsers/0" class="ui red button">
|
||||||
<i class="users icon"></i>
|
<i class="users icon"></i>
|
||||||
<span>View banned users</span>
|
<span>View banned users</span>
|
||||||
</a><br/><br/>
|
</a><br/><br/>
|
||||||
|
|
||||||
<a href="/moderation/hiddenSlots" class="ui yellow button">
|
<a href="/moderation/hiddenLevels/0" class="ui yellow button">
|
||||||
<i class="certificate icon"></i>
|
<i class="certificate icon"></i>
|
||||||
<span>View hidden levels</span>
|
<span>View hidden levels</span>
|
||||||
</a>
|
</a>
|
|
@ -8,6 +8,7 @@
|
||||||
@{
|
@{
|
||||||
Layout = "Layouts/BaseLayout";
|
Layout = "Layouts/BaseLayout";
|
||||||
Model.Title = Model.Translate(BaseLayoutStrings.HeaderUsers);
|
Model.Title = Model.Translate(BaseLayoutStrings.HeaderUsers);
|
||||||
|
bool isMobile = Model.Request.IsMobile();
|
||||||
}
|
}
|
||||||
|
|
||||||
<p>There are @Model.UserCount total users.</p>
|
<p>There are @Model.UserCount total users.</p>
|
||||||
|
@ -22,7 +23,6 @@
|
||||||
|
|
||||||
@foreach (User user in Model.Users)
|
@foreach (User user in Model.Users)
|
||||||
{
|
{
|
||||||
bool isMobile = Model.Request.IsMobile();
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
@await Html.PartialAsync("Partials/UserCardPartial", user, new ViewDataDictionary(ViewData)
|
@await Html.PartialAsync("Partials/UserCardPartial", user, new ViewDataDictionary(ViewData)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue