-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added infractions display to admin panel
- Also, Riok.Mapperly experiment
- Loading branch information
Showing
12 changed files
with
679 additions
and
1,137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@page | ||
@using Ogma3.Data.Infractions | ||
@model Ogma3.Areas.Admin.Pages.InfractionsModel | ||
@{ | ||
ViewData["Title"] = "Infractions"; | ||
ViewData["ActivePage"] = NavPages.Infractions; | ||
} | ||
|
||
<table class="o-table"> | ||
<tr> | ||
<th>Username</th> | ||
<th>Type</th> | ||
<th>Reason</th> | ||
<th>Duration</th> | ||
<th>Issuer</th> | ||
<th>Lifted</th> | ||
<th>Lifter</th> | ||
</tr> | ||
@foreach (var infraction in Model.Infractions) | ||
{ | ||
<tr> | ||
<td>@infraction.UserUserName</td> | ||
<td>@infraction.Type.ToStringFast()</td> | ||
<td>@infraction.Reason</td> | ||
<td>@infraction.ActiveUntil</td> | ||
<td>@infraction.IssuedByUserName</td> | ||
<td>@infraction.RemovedAt</td> | ||
<td>@infraction.RemovedByUserName</td> | ||
</tr> | ||
} | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.EntityFrameworkCore; | ||
using Ogma3.Areas.Identity.Pages.Account.Manage; | ||
using Ogma3.Data; | ||
using Ogma3.Data.Infractions; | ||
using Riok.Mapperly.Abstractions; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Utils.Extensions; | ||
|
||
namespace Ogma3.Areas.Admin.Pages; | ||
|
||
public class InfractionsModel(ApplicationDbContext context) : PageModel | ||
{ | ||
public required List<InfractionDto> Infractions { get; set; } | ||
|
||
public async Task<IActionResult> OnGetAsync() | ||
{ | ||
Infractions = await context.Infractions | ||
.OrderBy(i => i.IssueDate) | ||
.ToInfractionDtos() | ||
.ToListAsync(); | ||
|
||
return Page(); | ||
} | ||
} | ||
|
||
[Mapper(PreferParameterlessConstructors = false)] | ||
public static partial class InfractionMapper | ||
{ | ||
public static partial IQueryable<InfractionDto> ToInfractionDtos(this IQueryable<Infraction> infraction); | ||
} | ||
|
||
public record InfractionDto( | ||
string UserUserName, | ||
long UserId, | ||
DateTime IssueDate, | ||
DateTime ActiveUntil, | ||
DateTime? RemovedAt, | ||
string Reason, | ||
InfractionType Type, | ||
string IssuedByUserName, | ||
long IssuedById, | ||
string RemovedByUserName, | ||
long RemovedById | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@{ | ||
@{ | ||
Layout = "/Pages/Shared/_Layout.cshtml"; | ||
ViewData["is-admin"] = true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.