mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 11:14:27 +00:00
Add management view for tested sequential media with delete functionality
This commit is contained in:
@@ -62,6 +62,9 @@
|
|||||||
<NavLink class="nav-link" href="/admin/supported-densities">
|
<NavLink class="nav-link" href="/admin/supported-densities">
|
||||||
Supported densities
|
Supported densities
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
<NavLink class="nav-link" href="/admin/tested-media/sequential">
|
||||||
|
Tested sequential media
|
||||||
|
</NavLink>
|
||||||
<NavLink class="nav-link" href="/admin/usb/devices">
|
<NavLink class="nav-link" href="/admin/usb/devices">
|
||||||
USB Devices
|
USB Devices
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
@page "/admin/tested-media/sequential"
|
||||||
|
@attribute [Authorize]
|
||||||
|
@layout AdminLayout
|
||||||
|
@rendermode InteractiveServer
|
||||||
|
|
||||||
|
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||||
|
|
||||||
|
<PageTitle>Tested Sequential Media</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>Tested Sequential Media</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(TestedSequentialMedia), nameof(TestedSequentialMedia.Manufacturer))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(TestedSequentialMedia), nameof(TestedSequentialMedia.Model))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(TestedSequentialMedia), nameof(TestedSequentialMedia.MediumTypeName))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(TestedSequentialMedia), nameof(TestedSequentialMedia.MediaIsRecognized))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(TestedSequentialMedia), nameof(TestedSequentialMedia.MediumType))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(TestedSequentialMedia), nameof(TestedSequentialMedia.Density))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
@DisplayNameHelper.GetDisplayName(typeof(TestedSequentialMedia), nameof(TestedSequentialMedia.CanReadMediaSerial))
|
||||||
|
</th>
|
||||||
|
<th class="fw-bold bg-secondary text-light">
|
||||||
|
Actions
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach(TestedSequentialMedia item in _items)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@item.Manufacturer
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.Model
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.MediumTypeName
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.MediaIsRecognized
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.MediumType
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.Density
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.CanReadMediaSerial
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="/admin/cd-offsets/edit/@item.Id" class="btn btn-secondary btn-sm">
|
||||||
|
<i class="bi bi-pencil"></i> Edit
|
||||||
|
</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 tested media?</div>
|
||||||
|
</BodyTemplate>
|
||||||
|
<FooterTemplate>
|
||||||
|
<button class="btn btn-secondary" @onclick="HideDeleteModal">Cancel</button>
|
||||||
|
<button class="btn btn-danger" @onclick="ConfirmDelete">Delete</button>
|
||||||
|
</FooterTemplate>
|
||||||
|
</BlazorBootstrap.Modal>
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using Aaru.CommonTypes.Metadata;
|
||||||
|
using BlazorBootstrap;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using DbContext = Aaru.Server.Database.DbContext;
|
||||||
|
|
||||||
|
namespace Aaru.Server.Components.Admin.Pages.TestedMedia.Sequential;
|
||||||
|
|
||||||
|
public partial class View
|
||||||
|
{
|
||||||
|
private int _deleteId;
|
||||||
|
private Modal? _deleteModal;
|
||||||
|
bool _initialized;
|
||||||
|
List<TestedSequentialMedia> _items;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
|
_items = await ctx.TestedSequentialMedia.OrderBy(static m => m.Manufacturer)
|
||||||
|
.ThenBy(static m => m.Model)
|
||||||
|
.ThenBy(static m => m.MediumTypeName)
|
||||||
|
.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 DeleteAsync(_deleteId);
|
||||||
|
await HideDeleteModal();
|
||||||
|
await RefreshItemsAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeleteAsync(int id)
|
||||||
|
{
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
TestedSequentialMedia? media = await ctx.TestedSequentialMedia.FindAsync(id);
|
||||||
|
|
||||||
|
if(media is not null)
|
||||||
|
{
|
||||||
|
ctx.TestedSequentialMedia.Remove(media);
|
||||||
|
await ctx.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RefreshItemsAsync()
|
||||||
|
{
|
||||||
|
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
|
_items = await ctx.TestedSequentialMedia.OrderBy(static m => m.Manufacturer)
|
||||||
|
.ThenBy(static m => m.Model)
|
||||||
|
.ThenBy(static m => m.MediumTypeName)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user