mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 11:14:27 +00:00
Add view for commands.
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
<NavLink class="nav-link" href="/admin/block-descriptors">
|
||||
Block descriptors
|
||||
</NavLink>
|
||||
<NavLink class="nav-link" href="/admin/commands">
|
||||
Commands
|
||||
</NavLink>
|
||||
</div>
|
||||
<!-- Add more admin links here -->
|
||||
</nav>
|
||||
|
||||
@@ -15,34 +15,36 @@
|
||||
return;
|
||||
}
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.Density))
|
||||
</th>
|
||||
<th>
|
||||
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.Blocks))
|
||||
</th>
|
||||
<th>
|
||||
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.BlockLength))
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(BlockDescriptor item in _items)
|
||||
{
|
||||
<section class="stats-section">
|
||||
<table class="table table-dark table-striped table-bordered mt-4 mb-4">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<td>
|
||||
@item.Density
|
||||
</td>
|
||||
<td>
|
||||
@item.Blocks
|
||||
</td>
|
||||
<td>
|
||||
@item.BlockLength
|
||||
</td>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.Density))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.Blocks))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.BlockLength))
|
||||
</th>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(BlockDescriptor item in _items)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.Density
|
||||
</td>
|
||||
<td>
|
||||
@item.Blocks
|
||||
</td>
|
||||
<td>
|
||||
@item.BlockLength
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -18,9 +18,9 @@ public partial class View
|
||||
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.BlockDescriptor.OrderBy(b => b.BlockLength)
|
||||
.ThenBy(b => b.Blocks)
|
||||
.ThenBy(b => b.Density)
|
||||
_items = await ctx.BlockDescriptor.OrderBy(static b => b.BlockLength)
|
||||
.ThenBy(static b => b.Blocks)
|
||||
.ThenBy(static b => b.Density)
|
||||
.ToListAsync();
|
||||
|
||||
_initialized = true;
|
||||
|
||||
44
Aaru.Server/Components/Admin/Pages/Commands/View.razor
Normal file
44
Aaru.Server/Components/Admin/Pages/Commands/View.razor
Normal file
@@ -0,0 +1,44 @@
|
||||
@page "/admin/commands"
|
||||
@attribute [Authorize]
|
||||
@layout AdminLayout
|
||||
|
||||
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||
|
||||
<PageTitle>Commands</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(Command), nameof(Command.Name))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(Command), nameof(Command.Count))
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(Command item in _items)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
@item.Count
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
27
Aaru.Server/Components/Admin/Pages/Commands/View.razor.cs
Normal file
27
Aaru.Server/Components/Admin/Pages/Commands/View.razor.cs
Normal 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.Commands;
|
||||
|
||||
public partial class View
|
||||
{
|
||||
bool _initialized;
|
||||
List<Command> _items;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.Commands.OrderBy(static c => c.Name).ToListAsync();
|
||||
|
||||
_initialized = true;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user