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