mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add device report view.
This commit is contained in:
@@ -88,7 +88,7 @@ public class Device : DeviceReportV2
|
|||||||
[DisplayName("Modified when")]
|
[DisplayName("Modified when")]
|
||||||
public DateTime? ModifiedWhen { get; set; }
|
public DateTime? ModifiedWhen { get; set; }
|
||||||
|
|
||||||
public virtual CompactDiscOffset CdOffset { get; set; }
|
public virtual CompactDiscOffset? CdOffset { get; set; }
|
||||||
|
|
||||||
[DefaultValue(0)]
|
[DefaultValue(0)]
|
||||||
[DisplayName("Optimal no. of sectors to be read at once")]
|
[DisplayName("Optimal no. of sectors to be read at once")]
|
||||||
|
|||||||
26
Aaru.Server.New/Components/Pages/Report/View.razor
Normal file
26
Aaru.Server.New/Components/Pages/Report/View.razor
Normal 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>
|
||||||
52
Aaru.Server.New/Components/Pages/Report/View.razor.cs
Normal file
52
Aaru.Server.New/Components/Pages/Report/View.razor.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user