mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add view for versions.
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
<NavLink class="nav-link" href="/admin/partitions">
|
||||
Partitions
|
||||
</NavLink>
|
||||
<NavLink class="nav-link" href="/admin/versions">
|
||||
Versions
|
||||
</NavLink>
|
||||
</div>
|
||||
<!-- Add more admin links here -->
|
||||
</nav>
|
||||
|
||||
45
Aaru.Server/Components/Admin/Pages/Versions/View.razor
Normal file
45
Aaru.Server/Components/Admin/Pages/Versions/View.razor
Normal file
@@ -0,0 +1,45 @@
|
||||
@page "/admin/versions"
|
||||
@using Version = Aaru.Server.Database.Models.Version
|
||||
@attribute [Authorize]
|
||||
@layout AdminLayout
|
||||
|
||||
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||
|
||||
<PageTitle>Versions</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(Version), nameof(Version.Name))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(Version), nameof(Version.Count))
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(Version item in _items)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
@item.Count
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
27
Aaru.Server/Components/Admin/Pages/Versions/View.razor.cs
Normal file
27
Aaru.Server/Components/Admin/Pages/Versions/View.razor.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DbContext = Aaru.Server.Database.DbContext;
|
||||
using Version = Aaru.Server.Database.Models.Version;
|
||||
|
||||
namespace Aaru.Server.Components.Admin.Pages.Versions;
|
||||
|
||||
public partial class View
|
||||
{
|
||||
bool _initialized;
|
||||
List<Version> _items;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.Versions.OrderBy(static v => v.Name).ToListAsync();
|
||||
|
||||
_initialized = true;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user