diff --git a/Aaru.Server.New/Components/Pages/Report/View.razor b/Aaru.Server.New/Components/Pages/Report/View.razor index 0368e7f8..bf362e7d 100644 --- a/Aaru.Server.New/Components/Pages/Report/View.razor +++ b/Aaru.Server.New/Components/Pages/Report/View.razor @@ -1,5 +1,7 @@ @page "/Report/View/{Id:int}" @using Aaru.Server.Database +@using Blazorise +@rendermode InteractiveServer @inject Microsoft.EntityFrameworkCore.IDbContextFactory DbContextFactory @@ -22,5 +24,40 @@ }
-

@_pageTitle

-
\ No newline at end of file +

@_pageTitle

+ + + + @if(UsbItem is not null) + { + + + + USB characteristics + + + + + + + Manufacturer + @UsbItem.Manufacturer + + + Product + @UsbItem.Product + + + Vendor ID + @UsbItem.VendorDescription + + + Product ID + @UsbItem.ProductDescription + + +
+
+
+ } +
\ No newline at end of file diff --git a/Aaru.Server.New/Components/Pages/Report/View.razor.cs b/Aaru.Server.New/Components/Pages/Report/View.razor.cs index 391be749..a88c9ef8 100644 --- a/Aaru.Server.New/Components/Pages/Report/View.razor.cs +++ b/Aaru.Server.New/Components/Pages/Report/View.razor.cs @@ -9,12 +9,13 @@ public partial class View { bool _initialized; bool _notFound; + bool accordionItem1Visible; string _pageTitle { get; set; } = "Aaru Device Report"; [CascadingParameter] HttpContext HttpContext { get; set; } = default!; - [Parameter] - public int Id { get; set; } + public int Id { get; set; } + public Item? UsbItem { get; set; } /// protected override async Task OnInitializedAsync() @@ -33,7 +34,8 @@ public partial class View await using DbContext ctx = await DbContextFactory.CreateDbContextAsync(); - Device? report = await ctx.Devices.FirstOrDefaultAsync(d => d.Id == Id); + Device? report = await ctx.Devices.Include(static deviceReportV2 => deviceReportV2.USB) + .FirstOrDefaultAsync(d => d.Id == Id); if(report is null) { @@ -45,8 +47,51 @@ public partial class View _pageTitle = $"Aaru Device Report for {report.Manufacturer} {report.Model} {report.Revision}"; + if(report.USB != null) + { + string? usbVendorDescription = null; + string? usbProductDescription = null; + + UsbProduct? dbProduct = await ctx.UsbProducts.Include(static usbProduct => usbProduct.Vendor) + .FirstOrDefaultAsync(p => p.ProductId == report.USB.ProductID && + p.Vendor.VendorId == report.USB.VendorID); + + if(dbProduct is null) + { + UsbVendor? dbVendor = await ctx.UsbVendors.FirstOrDefaultAsync(v => v.VendorId == report.USB.VendorID); + + if(dbVendor is not null) usbVendorDescription = dbVendor.Vendor; + } + else + { + usbProductDescription = dbProduct.Product; + usbVendorDescription = dbProduct.Vendor.Vendor; + } + + UsbItem = new Item + { + Manufacturer = report.USB.Manufacturer, + Product = report.USB.Product, + VendorDescription = + usbVendorDescription != null + ? $"0x{report.USB.VendorID:x4} ({usbVendorDescription})" + : $"0x{report.USB.VendorID:x4}", + ProductDescription = usbProductDescription != null + ? $"0x{report.USB.ProductID:x4} ({usbProductDescription})" + : $"0x{report.USB.ProductID:x4}" + }; + } + _initialized = true; StateHasChanged(); } +} + +public class Item +{ + public string Manufacturer; + public string Product; + public string ProductDescription; + public string VendorDescription; } \ No newline at end of file