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">
|
<NavLink class="nav-link" href="/admin/block-descriptors">
|
||||||
Block descriptors
|
Block descriptors
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
<NavLink class="nav-link" href="/admin/commands">
|
||||||
|
Commands
|
||||||
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
<!-- Add more admin links here -->
|
<!-- Add more admin links here -->
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -15,34 +15,36 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
<table class="table">
|
<section class="stats-section">
|
||||||
<thead>
|
<table class="table table-dark table-striped table-bordered mt-4 mb-4">
|
||||||
<tr>
|
<thead class="thead-dark">
|
||||||
<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)
|
|
||||||
{
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<th class="fw-bold bg-secondary text-light">
|
||||||
@item.Density
|
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.Density))
|
||||||
</td>
|
</th>
|
||||||
<td>
|
<th class="fw-bold bg-secondary text-light">
|
||||||
@item.Blocks
|
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.Blocks))
|
||||||
</td>
|
</th>
|
||||||
<td>
|
<th class="fw-bold bg-secondary text-light">
|
||||||
@item.BlockLength
|
@DisplayNameHelper.GetDisplayName(typeof(BlockDescriptor), nameof(BlockDescriptor.BlockLength))
|
||||||
</td>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
@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();
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
_items = await ctx.BlockDescriptor.OrderBy(b => b.BlockLength)
|
_items = await ctx.BlockDescriptor.OrderBy(static b => b.BlockLength)
|
||||||
.ThenBy(b => b.Blocks)
|
.ThenBy(static b => b.Blocks)
|
||||||
.ThenBy(b => b.Density)
|
.ThenBy(static b => b.Density)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
_initialized = true;
|
_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