Add device report view.

This commit is contained in:
2024-05-05 04:04:32 +01:00
parent 31377e4f3f
commit de134f46b9
3 changed files with 79 additions and 1 deletions

View File

@@ -88,7 +88,7 @@ public class Device : DeviceReportV2
[DisplayName("Modified when")]
public DateTime? ModifiedWhen { get; set; }
public virtual CompactDiscOffset CdOffset { get; set; }
public virtual CompactDiscOffset? CdOffset { get; set; }
[DefaultValue(0)]
[DisplayName("Optimal no. of sectors to be read at once")]

View File

@@ -0,0 +1,26 @@
@page "/Report/View/{Id:int}"
@using Aaru.Server.Database
@inject Microsoft.EntityFrameworkCore.IDbContextFactory<DbContext> DbContextFactory
<PageTitle>@_pageTitle</PageTitle>
@if(_notFound)
{
<div class="stats-section">
<h1 style="color: red; align-content: center; padding: 2rem">The requested device report has not been found...</h1>
</div>
return;
}
@if(!_initialized)
{
<div class="stats-section">
<h1 style="color: red; align-content: center; padding: 2rem">Loading...</h1>
</div>
return;
}
<div class="stats-section">
<h1 style="align-content: center; padding: 2rem">@_pageTitle</h1>
</div>

View File

@@ -0,0 +1,52 @@
using Aaru.Server.Database.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.EntityFrameworkCore;
using DbContext = Aaru.Server.Database.DbContext;
namespace Aaru.Server.New.Components.Pages.Report;
public partial class View
{
bool _initialized;
bool _notFound;
string _pageTitle { get; set; } = "Aaru Device Report";
[CascadingParameter]
HttpContext HttpContext { get; set; } = default!;
[Parameter]
public int Id { get; set; }
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if(Id <= 0)
{
_notFound = true;
HttpContext.Response.StatusCode = StatusCodes.Status404NotFound;
return;
}
StateHasChanged();
await using DbContext ctx = await DbContextFactory.CreateDbContextAsync();
Device? report = await ctx.Devices.FirstOrDefaultAsync(d => d.Id == Id);
if(report is null)
{
_notFound = true;
HttpContext.Response.StatusCode = StatusCodes.Status404NotFound;
return;
}
_pageTitle = $"Aaru Device Report for {report.Manufacturer} {report.Model} {report.Revision}";
_initialized = true;
StateHasChanged();
}
}