mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-23 13:41:31 +00:00
* Add pagination to moderation cases list and tweak case dismissal task * Clean up case partial and add extended case status indicators * Redirect back to cases list after dismissing a case * Fix typo on cases list queue counter * Fix dismissal queue counter * Convert dismiss button check into pattern * Turn down case dismissal task repeat interval to every 1 hour * Use page 0 for case searching * Implement pagination on the admin users list <3 * Fix pagination button padding and update colors to match existing role colors * Fix typo in admin search placeholder * Make cases searchable by user/slot ID instead of reason Due to the current state of the moderation case entity, I can't directly query against the affected user name, so I've added the ability to search for the affected user/slot ID instead of reason. * Actually apply the desired changes instead of just fixing the counts * Grammatical nitpick in the search box placeholder
58 lines
No EOL
2.3 KiB
C#
58 lines
No EOL
2.3 KiB
C#
#nullable enable
|
|
using LBPUnion.ProjectLighthouse.Administration.Maintenance;
|
|
using LBPUnion.ProjectLighthouse.Database;
|
|
using LBPUnion.ProjectLighthouse.Extensions;
|
|
using LBPUnion.ProjectLighthouse.Filter;
|
|
using LBPUnion.ProjectLighthouse.Helpers;
|
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
|
using LBPUnion.ProjectLighthouse.Servers.Website.Types;
|
|
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
|
using LBPUnion.ProjectLighthouse.Types.Logging;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
|
|
|
|
public class AdminPanelPage : BaseLayout
|
|
{
|
|
public AdminPanelPage(DatabaseContext database) : base(database)
|
|
{ }
|
|
|
|
public List<AdminPanelStatistic> Statistics = new();
|
|
|
|
public string? Log;
|
|
|
|
public async Task<IActionResult> OnGet([FromQuery] string? args, [FromQuery] string? command, [FromQuery] string? maintenanceJob, [FromQuery] string? log)
|
|
{
|
|
UserEntity? user = this.Database.UserFromWebRequest(this.Request);
|
|
if (user == null) return this.Redirect("~/login");
|
|
if (!user.IsAdmin) return this.NotFound();
|
|
|
|
this.Statistics.Add(new AdminPanelStatistic("Users", await StatisticsHelper.UserCount(this.Database), "/admin/users/0"));
|
|
this.Statistics.Add(new AdminPanelStatistic("Slots", await StatisticsHelper.SlotCount(this.Database, new SlotQueryBuilder())));
|
|
this.Statistics.Add(new AdminPanelStatistic("Photos", await StatisticsHelper.PhotoCount(this.Database)));
|
|
this.Statistics.Add(new AdminPanelStatistic("API Keys", await StatisticsHelper.ApiKeyCount(this.Database), "/admin/keys"));
|
|
|
|
if (!string.IsNullOrEmpty(command))
|
|
{
|
|
args ??= "";
|
|
args = command + " " + args;
|
|
string[] split = args.Split(" ");
|
|
|
|
List<LogLine> runCommand = await MaintenanceHelper.RunCommand(this.HttpContext.RequestServices, split);
|
|
return this.Redirect($"~/admin?log={CryptoHelper.ToBase64(runCommand.ToLogString())}");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(maintenanceJob))
|
|
{
|
|
await MaintenanceHelper.RunMaintenanceJob(maintenanceJob);
|
|
return this.Redirect("~/admin");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(log))
|
|
{
|
|
this.Log = CryptoHelper.FromBase64(log);
|
|
}
|
|
|
|
return this.Page();
|
|
}
|
|
} |