mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add view for SCSI MODE SENSE responses.
This commit is contained in:
@@ -38,6 +38,9 @@
|
||||
<NavLink class="nav-link" href="/admin/pcmcia">
|
||||
PCMCIA
|
||||
</NavLink>
|
||||
<NavLink class="nav-link" href="/admin/scsi/modes">
|
||||
SCSI MODE SENSE responses
|
||||
</NavLink>
|
||||
<NavLink class="nav-link" href="/admin/usb/products">
|
||||
USB Products
|
||||
</NavLink>
|
||||
|
||||
88
Aaru.Server/Components/Admin/Pages/ScsiModes/View.razor
Normal file
88
Aaru.Server/Components/Admin/Pages/ScsiModes/View.razor
Normal file
@@ -0,0 +1,88 @@
|
||||
@page "/admin/scsi/modes"
|
||||
@attribute [Authorize]
|
||||
@layout AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||
|
||||
<PageTitle>SCSI MODE SENSE responses</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 MODE SENSE responses</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(ScsiMode), nameof(ScsiMode.MediumType))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(ScsiMode), nameof(ScsiMode.WriteProtected))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(ScsiMode), nameof(ScsiMode.Speed))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(ScsiMode), nameof(ScsiMode.BufferedMode))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(ScsiMode), nameof(ScsiMode.BlankCheckEnabled))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
@DisplayNameHelper.GetDisplayName(typeof(ScsiMode), nameof(ScsiMode.DPOandFUA))
|
||||
</th>
|
||||
<th class="fw-bold bg-secondary text-light">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(ScsiMode item in _items)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.MediumType
|
||||
</td>
|
||||
<td>
|
||||
@item.WriteProtected
|
||||
</td>
|
||||
<td>
|
||||
@item.Speed
|
||||
</td>
|
||||
<td>
|
||||
@item.BufferedMode
|
||||
</td>
|
||||
<td>
|
||||
@item.BlankCheckEnabled
|
||||
</td>
|
||||
<td>
|
||||
@item.DPOandFUA
|
||||
</td>
|
||||
<td>
|
||||
<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 MODE SENSE response?</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<button class="btn btn-secondary" @onclick="HideDeleteModal">Cancel</button>
|
||||
<button class="btn btn-danger" @onclick="ConfirmDelete">Delete</button>
|
||||
</FooterTemplate>
|
||||
</BlazorBootstrap.Modal>
|
||||
69
Aaru.Server/Components/Admin/Pages/ScsiModes/View.razor.cs
Normal file
69
Aaru.Server/Components/Admin/Pages/ScsiModes/View.razor.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using BlazorBootstrap;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DbContext = Aaru.Server.Database.DbContext;
|
||||
|
||||
namespace Aaru.Server.Components.Admin.Pages.ScsiModes;
|
||||
|
||||
public partial class View
|
||||
{
|
||||
private int _deleteId;
|
||||
private Modal? _deleteModal;
|
||||
bool _initialized;
|
||||
List<ScsiMode> _items;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.ScsiMode.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();
|
||||
ScsiMode? mode = await ctx.ScsiMode.FindAsync(id);
|
||||
|
||||
if(mode is not null)
|
||||
{
|
||||
ctx.ScsiMode.Remove(mode);
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RefreshItemsAsync()
|
||||
{
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_items = await ctx.ScsiMode.ToListAsync();
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user