ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml
koko 3a2cdc9afe
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
2023-09-22 18:53:53 +00:00

138 lines
No EOL
4.4 KiB
Text

@using System.Diagnostics
@using LBPUnion.ProjectLighthouse.Database
@using LBPUnion.ProjectLighthouse.Types.Entities.Level
@using LBPUnion.ProjectLighthouse.Types.Entities.Profile
@using LBPUnion.ProjectLighthouse.Types.Moderation.Cases
@model LBPUnion.ProjectLighthouse.Types.Entities.Moderation.ModerationCaseEntity
@inject DatabaseContext Database
@{
string timeZone = (string?)ViewData["TimeZone"] ?? TimeZoneInfo.Local.Id;
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone);
string color = "red";
if (Model.Expired)
color = "yellow";
if (Model.Dismissed)
color = "green";
}
<div class="ui @color segment">
<h2>Case #@Model.CaseId: @Model.Type</h2>
@if (Model.Creator != null && Model.Creator.Username.Length != 0)
{
<span>
Case created by <a href="/user/@Model.Creator.UserId">@Model.Creator.Username</a>
on @TimeZoneInfo.ConvertTime(Model.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")
@if (Model.ExpiresAt != null)
{
<span>until @TimeZoneInfo.ConvertTime(Model.ExpiresAt!.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")</span>
}
</span><br>
}
else
{
<span>
Case created by @Model.CreatorUsername
on @TimeZoneInfo.ConvertTime(Model.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")
@if (Model.ExpiresAt != null)
{
<span>until @TimeZoneInfo.ConvertTime(Model.ExpiresAt!.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")</span>
}
</span><br>
}
@if (Model.Type.AffectsLevel())
{
SlotEntity? slot = await Model.GetSlotAsync(Database);
if (slot != null)
{
<p>
<strong>Affected level:</strong> <a href="/slot/@slot.SlotId">@slot.Name (@slot.SlotId)</a>
</p>
}
}
else if (Model.Type.AffectsUser())
{
UserEntity? user = await Model.GetUserAsync(Database);
if (user != null)
{
<p>
<strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username (@user.UserId)</a>
</p>
}
}
<h3>Case Status</h3>
@if (Model.Dismissed)
{
Debug.Assert(Model.DismissedAt != null);
@if (Model.Dismisser != null)
{
<div>
<i class="ui green icon check"></i>
<span class="ui green text">
This case was dismissed by <a href="/user/@Model.Dismisser.UserId">@Model.DismisserUsername</a> on @TimeZoneInfo.ConvertTime(Model.DismissedAt.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
</span>
</div>
}
else
{
<div>
<i class="ui green icon check"></i>
<span class="ui green text">
This case was dismissed by @Model.DismisserUsername on @TimeZoneInfo.ConvertTime(Model.DismissedAt.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
</span>
</div>
}
}
else if (Model.Expired)
{
<div>
<i class="ui orange icon clock"></i>
<span class="ui orange text">
This case expired on @TimeZoneInfo.ConvertTime(Model.ExpiresAt!.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt") and has been queued for dismissal.
</span>
</div>
}
else
{
<div>
<i class="ui red icon times"></i>
<span class="ui red text">
This case is currently active and will expire on @TimeZoneInfo.ConvertTime(Model.ExpiresAt!.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
</span>
</div>
}
<h3>Reason</h3>
@if (!string.IsNullOrWhiteSpace(Model.Reason))
{
<pre style="white-space: initial;">@Model.Reason</pre>
}
else
{
<pre><b>No reason was provided.</b></pre>
}
<h3>Moderator Notes</h3>
@if (!string.IsNullOrWhiteSpace(Model.ModeratorNotes))
{
<pre style="white-space: initial;">@Model.ModeratorNotes</pre>
}
else
{
<pre><b>No notes were provided.</b></pre>
}
@if (Model is { Dismissed: false, Expired: false, })
{
<a class="ui green small button" href="/moderation/case/@Model.CaseId/dismiss">
<i class="checkmark icon"></i>
<span>Dismiss</span>
</a>
}
</div>