Add view for filters.

This commit is contained in:
2025-09-11 16:59:00 +01:00
parent 4f12c50a55
commit 061968b6d6
3 changed files with 74 additions and 0 deletions

View File

@@ -17,6 +17,9 @@
<NavLink class="nav-link" href="/admin/filesystems">
Filesystems
</NavLink>
<NavLink class="nav-link" href="/admin/filters">
Filters
</NavLink>
</div>
<!-- Add more admin links here -->
</nav>

View File

@@ -0,0 +1,44 @@
@page "/admin/filters"
@attribute [Authorize]
@layout AdminLayout
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
<PageTitle>Filters</PageTitle>
@if(!_initialized)
{
<div class="stats-section">
<h1 style="color: red; align-content: center; padding: 2rem">Loading...</h1>
</div>
return;
}
<section class="stats-section">
<table class="table table-dark table-striped table-bordered mt-4 mb-4">
<thead class="thead-dark">
<tr>
<th class="fw-bold bg-secondary text-light">
@DisplayNameHelper.GetDisplayName(typeof(Filter), nameof(Filter.Name))
</th>
<th class="fw-bold bg-secondary text-light">
@DisplayNameHelper.GetDisplayName(typeof(Filter), nameof(Filter.Count))
</th>
</tr>
</thead>
<tbody>
@foreach(Filter item in _items)
{
<tr>
<td>
@item.Name
</td>
<td>
@item.Count
</td>
</tr>
}
</tbody>
</table>
</section>

View File

@@ -0,0 +1,27 @@
using Aaru.Server.Database.Models;
using Microsoft.EntityFrameworkCore;
using DbContext = Aaru.Server.Database.DbContext;
namespace Aaru.Server.Components.Admin.Pages.Filters;
public partial class View
{
bool _initialized;
List<Filter> _items;
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
StateHasChanged();
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
_items = await ctx.Filters.OrderBy(static f => f.Name).ToListAsync();
_initialized = true;
StateHasChanged();
}
}