mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Improve moderation case page and case partial (#900)
* 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
This commit is contained in:
parent
1ddedae1fb
commit
3a2cdc9afe
9 changed files with 147 additions and 61 deletions
|
@ -11,10 +11,11 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
public class CasePage : BaseLayout
|
||||
{
|
||||
public CasePage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
{ }
|
||||
|
||||
public List<ModerationCaseEntity> Cases = new();
|
||||
public int CaseCount;
|
||||
public int ExpiredCaseCount;
|
||||
public int DismissedCaseCount;
|
||||
|
||||
public int PageAmount;
|
||||
|
@ -31,18 +32,30 @@ public class CasePage : BaseLayout
|
|||
|
||||
this.SearchValue = name.Replace(" ", string.Empty);
|
||||
|
||||
this.Cases = await this.Database.Cases
|
||||
.Include(c => c.Creator)
|
||||
.Include(c => c.Dismisser)
|
||||
.OrderByDescending(c => c.CaseId)
|
||||
.ToListAsync();
|
||||
|
||||
this.CaseCount = await this.Database.Cases.CountAsync(c => c.Reason.Contains(this.SearchValue));
|
||||
this.DismissedCaseCount = await this.Database.Cases.CountAsync(c => c.Reason.Contains(this.SearchValue) && c.DismissedAt != null);
|
||||
this.CaseCount =
|
||||
await this.Database.Cases.CountAsync(c =>
|
||||
c.AffectedId.ToString().Contains(this.SearchValue));
|
||||
this.ExpiredCaseCount =
|
||||
await this.Database.Cases.CountAsync(c =>
|
||||
c.AffectedId.ToString().Contains(this.SearchValue) && c.DismissedAt == null && c.ExpiresAt < DateTime.UtcNow);
|
||||
this.DismissedCaseCount =
|
||||
await this.Database.Cases.CountAsync(c =>
|
||||
c.AffectedId.ToString().Contains(this.SearchValue)&& c.DismissedAt != null);
|
||||
|
||||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.CaseCount / ServerStatics.PageSize));
|
||||
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
|
||||
return this.Redirect($"/moderation/cases/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
|
||||
this.Cases = await this.Database.Cases.Include(c => c.Creator)
|
||||
.Include(c => c.Dismisser)
|
||||
.Where(c => c.AffectedId.ToString().Contains(this.SearchValue))
|
||||
.OrderByDescending(c => c.CaseId)
|
||||
.Skip(pageNumber * ServerStatics.PageSize)
|
||||
.Take(ServerStatics.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue