Skip to content

Commit

Permalink
Add round ID to bans tables.
Browse files Browse the repository at this point in the history
Requested by CptJeanLuc on Discord.
  • Loading branch information
PJB3005 committed Mar 24, 2024
1 parent 44b2ab3 commit 6704f3d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
7 changes: 5 additions & 2 deletions SS14.Admin/Pages/Bans/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public static async Task<ISortState> LoadSortBanTableData(
sortState.AddColumn("ip", p => p.Ban.Address);
sortState.AddColumn("uid", p => p.Ban.PlayerUserId);
sortState.AddColumn("time", p => p.Ban.BanTime, SortOrder.Descending);
sortState.AddColumn("round", p => p.Ban.RoundId, SortOrder.Descending);
// sortState.AddColumn("expire_time", p => p.ban.Unban == null ? p.ban.ExpirationTime : p.ban.Unban!.UnbanTime);
sortState.AddColumn("admin", p => p.Admin!.LastSeenUserName);
sortState.AddColumn("hits", p => p.HitCount);
Expand Down Expand Up @@ -133,7 +134,8 @@ await pagination.LoadLinqAsync(bans, e => e.Select(b =>
BanHelper.IsBanActive(b.Ban),
b.Ban.BanTime,
b.Admin?.LastSeenUserName,
b.HitCount);
b.HitCount,
b.Ban.RoundId);
}));

return sortState;
Expand All @@ -151,7 +153,8 @@ public sealed record Ban(
bool Active,
DateTime BanTime,
string? Admin,
int hitCount);
int hitCount,
int? Round);

public enum ShowFilter
{
Expand Down
7 changes: 5 additions & 2 deletions SS14.Admin/Pages/RoleBans/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static async Task<ISortState> LoadSortBanTableData(
sortState.AddColumn("ip", p => p.Ban.Address);
sortState.AddColumn("uid", p => p.Ban.PlayerUserId);
sortState.AddColumn("time", p => p.Ban.BanTime, SortOrder.Descending);
sortState.AddColumn("round", p => p.Ban.RoundId, SortOrder.Descending);
// sortState.AddColumn("expire_time", p => p.ban.Unban == null ? p.ban.ExpirationTime : p.ban.Unban!.UnbanTime);
sortState.AddColumn("admin", p => p.Admin!.LastSeenUserName);
sortState.AddColumn("role", p => p.Ban.RoleId);
Expand Down Expand Up @@ -132,7 +133,8 @@ await pagination.LoadLinqAsync(bans, e => e.Select(b =>
BanHelper.IsBanActive(b.Ban),
b.Ban.BanTime,
b.Admin?.LastSeenUserName,
b.Ban.RoleId);
b.Ban.RoleId,
b.Ban.RoundId);
}));

return sortState;
Expand All @@ -150,7 +152,8 @@ public sealed record RoleBan(
bool Active,
DateTime BanTime,
string? Admin,
string Role);
string Role,
int? Round);

public enum ShowFilter
{
Expand Down
4 changes: 4 additions & 0 deletions SS14.Admin/Pages/Tables/BansTable.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<th style="min-width: 210px">
<partial name="Tables/SortTabHeaderCore" model="@(new SortTabHeaderModel(Model.SortState, "time", "Ban time"))"/>
</th>
<th>
<partial name="Tables/SortTabHeaderCore" model="@(new SortTabHeaderModel(Model.SortState, "round", "Round"))"/>
</th>
<th style="min-width: 210px">Expires</th>
<th style="min-width: 140px">
<partial name="Tables/SortTabHeaderCore" model="@(new SortTabHeaderModel(Model.SortState, "admin", "Banning admin"))"/>
Expand Down Expand Up @@ -75,6 +78,7 @@
</td>
<td>@ban.Reason</td>
<td>@ban.BanTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
<td>@ban.Round</td>
<td>
@(ban.Expires?.ToString("yyyy-MM-dd HH:mm:ss") ?? "PERMANENT")
@if (ban.Unbanned is { } unbanned)
Expand Down
4 changes: 4 additions & 0 deletions SS14.Admin/Pages/Tables/RoleBansTable.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<th style="min-width: 210px">
<partial name="Tables/SortTabHeaderCore" model="@(new SortTabHeaderModel(Model.SortState, "time", "Ban time"))"/>
</th>
<th>
<partial name="Tables/SortTabHeaderCore" model="@(new SortTabHeaderModel(Model.SortState, "round", "Round"))"/>
</th>
<th style="min-width: 210px">Expires</th>
<th style="min-width: 140px">
<partial name="Tables/SortTabHeaderCore" model="@(new SortTabHeaderModel(Model.SortState, "admin", "Banning admin"))"/>
Expand Down Expand Up @@ -77,6 +80,7 @@
<td>@ban.Reason</td>
<td>@ban.Role</td>
<td>@ban.BanTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
<td>@ban.Round</td>
<td>
@(ban.Expires?.ToString("yyyy-MM-dd HH:mm:ss") ?? "PERMANENT")
@if (ban.Unbanned is { } unbanned)
Expand Down

0 comments on commit 6704f3d

Please sign in to comment.