mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 11:14:27 +00:00
Add view for SCSI CD-ROM Capabilities list.
This commit is contained in:
@@ -44,6 +44,9 @@
|
||||
<NavLink class="nav-link" href="/admin/pcmcia">
|
||||
PCMCIA
|
||||
</NavLink>
|
||||
<NavLink class="nav-link" href="/admin/scsi/cdrom">
|
||||
SCSI CD-ROM Capabilities
|
||||
</NavLink>
|
||||
<NavLink class="nav-link" href="/admin/scsi/pages">
|
||||
SCSI MODE SENSE pages
|
||||
</NavLink>
|
||||
|
||||
80
Aaru.Server/Components/Admin/Pages/Scsi/Cdrom/List.razor
Normal file
80
Aaru.Server/Components/Admin/Pages/Scsi/Cdrom/List.razor
Normal file
@@ -0,0 +1,80 @@
|
||||
@page "/admin/scsi/cdrom"
|
||||
@attribute [Authorize]
|
||||
@layout AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||
|
||||
<PageTitle>SCSI CD-ROM Capabilities</PageTitle>
|
||||
|
||||
@if(!_initialized)
|
||||
{
|
||||
<div class="stats-section">
|
||||
<h1 style="color: red; align-content: center; padding: 2rem">Loading...</h1>
|
||||
</div>
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
<section class="stats-section">
|
||||
<h4>SCSI CD-ROM Capabilities</h4>
|
||||
<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(MmcModelForView), nameof(MmcModelForView.Id))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(MmcModelForView), nameof(MmcModelForView.FeaturesId))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(MmcModelForView), nameof(MmcModelForView.DataLength))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(MmcModelForView item in _items)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.Id
|
||||
</td>
|
||||
<td>
|
||||
@if(item.FeaturesId != null)
|
||||
{
|
||||
<a class="btn btn-primary btn-sm"
|
||||
href="/admin/mmc/features/@item.FeaturesId"
|
||||
target="_blank">@item.FeaturesId</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@item.FeaturesId
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@item.DataLength
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-sm" href="/admin/scsi/cdrom/@item.Id" target="_blank">Details</a>
|
||||
<button class="btn btn-danger btn-sm" @onclick="async () => await ShowDeleteModal(item.Id)">
|
||||
<i class="bi bi-trash"></i> Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<BlazorBootstrap.Modal @ref="_deleteModal" Title="Delete Version" Size="ModalSize.Small">
|
||||
<BodyTemplate>
|
||||
<div class="text-danger">Are you sure you want to delete this SCSI CD-ROM Capabilities?</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<button class="btn btn-secondary" @onclick="HideDeleteModal">Cancel</button>
|
||||
<button class="btn btn-danger" @onclick="ConfirmDelete">Delete</button>
|
||||
</FooterTemplate>
|
||||
</BlazorBootstrap.Modal>
|
||||
99
Aaru.Server/Components/Admin/Pages/Scsi/Cdrom/List.razor.cs
Normal file
99
Aaru.Server/Components/Admin/Pages/Scsi/Cdrom/List.razor.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using Aaru.Server.Database.Models;
|
||||
using BlazorBootstrap;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DbContext = Aaru.Server.Database.DbContext;
|
||||
|
||||
namespace Aaru.Server.Components.Admin.Pages.Scsi.Cdrom;
|
||||
|
||||
public partial class List
|
||||
{
|
||||
private int _deleteId;
|
||||
private Modal? _deleteModal;
|
||||
bool _initialized;
|
||||
List<MmcModelForView> _items;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.Mmc.Where(static m => m.ModeSense2AData != null)
|
||||
.Select(static m => new MmcModelForView
|
||||
{
|
||||
Id = m.Id,
|
||||
FeaturesId = m.FeaturesId,
|
||||
DataLength = m.ModeSense2AData.Length
|
||||
})
|
||||
.Concat(ctx.Mmc.Where(static m => m.ModeSense2AData == null)
|
||||
.Select(static m => new MmcModelForView
|
||||
{
|
||||
Id = m.Id,
|
||||
FeaturesId = m.FeaturesId,
|
||||
DataLength = 0
|
||||
}))
|
||||
.OrderBy(static m => m.Id)
|
||||
.ToListAsync();
|
||||
|
||||
_initialized = true;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task ShowDeleteModal(int id)
|
||||
{
|
||||
_deleteId = id;
|
||||
if(_deleteModal != null) await _deleteModal.ShowAsync();
|
||||
}
|
||||
|
||||
private async Task HideDeleteModal()
|
||||
{
|
||||
if(_deleteModal != null) await _deleteModal.HideAsync();
|
||||
}
|
||||
|
||||
private async Task ConfirmDelete()
|
||||
{
|
||||
await DeleteVersionAsync(_deleteId);
|
||||
await HideDeleteModal();
|
||||
await RefreshItemsAsync();
|
||||
}
|
||||
|
||||
private async Task DeleteVersionAsync(int id)
|
||||
{
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
CommonTypes.Metadata.Mmc? mmc = await ctx.Mmc.FindAsync(id);
|
||||
|
||||
if(mmc is not null)
|
||||
{
|
||||
ctx.Mmc.Remove(mmc);
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RefreshItemsAsync()
|
||||
{
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.Mmc.Where(static m => m.ModeSense2AData != null)
|
||||
.Select(static m => new MmcModelForView
|
||||
{
|
||||
Id = m.Id,
|
||||
FeaturesId = m.FeaturesId,
|
||||
DataLength = m.ModeSense2AData.Length
|
||||
})
|
||||
.Concat(ctx.Mmc.Where(static m => m.ModeSense2AData == null)
|
||||
.Select(static m => new MmcModelForView
|
||||
{
|
||||
Id = m.Id,
|
||||
FeaturesId = m.FeaturesId,
|
||||
DataLength = 0
|
||||
}))
|
||||
.OrderBy(static m => m.Id)
|
||||
.ToListAsync();
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user