mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 11:14:27 +00:00
Add view for USB products.
This commit is contained in:
@@ -26,6 +26,9 @@
|
|||||||
<NavLink class="nav-link" href="/admin/partitions">
|
<NavLink class="nav-link" href="/admin/partitions">
|
||||||
Partitions
|
Partitions
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
<NavLink class="nav-link" href="/admin/usb/products">
|
||||||
|
USB Products
|
||||||
|
</NavLink>
|
||||||
<NavLink class="nav-link" href="/admin/versions">
|
<NavLink class="nav-link" href="/admin/versions">
|
||||||
Versions
|
Versions
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
|||||||
51
Aaru.Server/Components/Admin/Pages/Usb/Products/List.razor
Normal file
51
Aaru.Server/Components/Admin/Pages/Usb/Products/List.razor
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
@page "/admin/usb/products"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@layout AdminLayout
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
|
||||||
|
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||||
|
|
||||||
|
<PageTitle>USB products</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(UsbProductModel), nameof(UsbProductModel.VendorName))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(UsbProductModel), nameof(UsbProductModel.ProductName))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(UsbProductModel), nameof(UsbProductModel.ProductId))
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach(UsbProductModel item in _items)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="/admin/usb/vendors/@item.VendorId" target="_blank">@item.VendorName</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.ProductName
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.ProductId
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using Aaru.Server.Database.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using DbContext = Aaru.Server.Database.DbContext;
|
||||||
|
|
||||||
|
namespace Aaru.Server.Components.Admin.Pages.Usb.Products;
|
||||||
|
|
||||||
|
public partial class List
|
||||||
|
{
|
||||||
|
bool _initialized;
|
||||||
|
|
||||||
|
List<UsbProductModel> _items;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
|
_items = await ctx.UsbProducts.Include(static u => u.Vendor)
|
||||||
|
.OrderBy(static p => p.Vendor.Vendor)
|
||||||
|
.ThenBy(static p => p.Product)
|
||||||
|
.ThenBy(static p => p.ProductId)
|
||||||
|
.Select(static p => new UsbProductModel
|
||||||
|
{
|
||||||
|
ProductId = p.ProductId,
|
||||||
|
ProductName = p.Product,
|
||||||
|
VendorId = p.Vendor.Id,
|
||||||
|
VendorName = p.Vendor.Vendor
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user