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