mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 11:14:27 +00:00
Add details view for ATA IDENTIFY DEVICE response with comparison functionality
This commit is contained in:
36
Aaru.Server/Components/Admin/Pages/Ata/Details.razor
Normal file
36
Aaru.Server/Components/Admin/Pages/Ata/Details.razor
Normal file
@@ -0,0 +1,36 @@
|
||||
@page "/admin/ata/{id:int}"
|
||||
@using Aaru.Decoders.ATA
|
||||
@attribute [Authorize]
|
||||
@layout AdminLayout
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
|
||||
|
||||
<PageTitle>ATA IDENTIFY DEVICE response</PageTitle>
|
||||
|
||||
@if(!_initialized)
|
||||
{
|
||||
<div class="stats-section">
|
||||
<h1 style="color: red; align-content: center; padding: 2rem">Loading...</h1>
|
||||
</div>
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
<section class="stats-section">
|
||||
<div>
|
||||
<h4>ATA IDENTIFY DEVICE response</h4>
|
||||
<hr />
|
||||
@((MarkupString)Identify.Prettify(_model?.Identify)?.Replace("\n", "<br />")))
|
||||
</div>
|
||||
<div class="mb-3 mt-3">
|
||||
<label for="compareId" class="form-label">Compare with ID</label>
|
||||
<input id="compareId" class="form-control d-inline-block w-auto me-2" type="number" @bind="_compareId" />
|
||||
<button class="btn btn-primary" @onclick="GoToCompare">
|
||||
<i class="bi bi-arrow-left-right"></i> Compare
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/admin/ata" class="btn btn-secondary">Back to List</a>
|
||||
</div>
|
||||
</section>
|
||||
41
Aaru.Server/Components/Admin/Pages/Ata/Details.razor.cs
Normal file
41
Aaru.Server/Components/Admin/Pages/Ata/Details.razor.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DbContext = Aaru.Server.Database.DbContext;
|
||||
|
||||
namespace Aaru.Server.Components.Admin.Pages.Ata;
|
||||
|
||||
public partial class Details
|
||||
{
|
||||
private int _compareId;
|
||||
bool _initialized;
|
||||
CommonTypes.Metadata.Ata? _model;
|
||||
|
||||
[Parameter]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavigationManager { get; set; } = default!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
|
||||
|
||||
_model = await ctx.Ata.FirstOrDefaultAsync(m => m.Id == Id);
|
||||
|
||||
_initialized = true;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void GoToCompare()
|
||||
{
|
||||
if(_compareId <= 0 || !(_model?.Id > 0)) return;
|
||||
|
||||
string url = $"/admin/ata/{_model.Id}/compare/{_compareId}";
|
||||
NavigationManager.NavigateTo(url);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user