diff --git a/Aaru.Server/Components/Admin/AdminNavMenu.razor b/Aaru.Server/Components/Admin/AdminNavMenu.razor index 5a98ea7d..f26a8602 100644 --- a/Aaru.Server/Components/Admin/AdminNavMenu.razor +++ b/Aaru.Server/Components/Admin/AdminNavMenu.razor @@ -35,6 +35,9 @@ Partitions + + PCMCIA + USB Products diff --git a/Aaru.Server/Components/Admin/Pages/Pcmcia/View.razor b/Aaru.Server/Components/Admin/Pages/Pcmcia/View.razor new file mode 100644 index 00000000..3b8b1b95 --- /dev/null +++ b/Aaru.Server/Components/Admin/Pages/Pcmcia/View.razor @@ -0,0 +1,88 @@ +@page "/admin/pcmcia" +@using Pcmcia = Aaru.CommonTypes.Metadata.Pcmcia +@attribute [Authorize] +@layout AdminLayout +@rendermode InteractiveServer + +@inject Microsoft.EntityFrameworkCore.IDbContextFactory DbContextFactory + +PCMCIA + +@if(!_initialized) +{ +
+

Loading...

+
+ + return; +} + +
+ + + + + + + + + + + + + + @foreach(Pcmcia item in _items) + { + + + + + + + + + + } + +
+ @DisplayNameHelper.GetDisplayName(typeof(Pcmcia), nameof(Pcmcia.CIS)) + + @DisplayNameHelper.GetDisplayName(typeof(Pcmcia), nameof(Pcmcia.Compliance)) + + @DisplayNameHelper.GetDisplayName(typeof(Media), nameof(Pcmcia.ManufacturerCode)) + + @DisplayNameHelper.GetDisplayName(typeof(Pcmcia), nameof(Pcmcia.CardCode)) + + @DisplayNameHelper.GetDisplayName(typeof(Pcmcia), nameof(Pcmcia.Manufacturer)) + + @DisplayNameHelper.GetDisplayName(typeof(Pcmcia), nameof(Pcmcia.ProductName)) + + Actions +
+ @item.CIS + + @item.Compliance + + @item.ManufacturerCode + + @item.CardCode + + @item.Manufacturer + + @item.ProductName + + +
+
+ + + +
Are you sure you want to delete this PCMCIA?
+
+ + + + +
\ No newline at end of file diff --git a/Aaru.Server/Components/Admin/Pages/Pcmcia/View.razor.cs b/Aaru.Server/Components/Admin/Pages/Pcmcia/View.razor.cs new file mode 100644 index 00000000..f6afeaf8 --- /dev/null +++ b/Aaru.Server/Components/Admin/Pages/Pcmcia/View.razor.cs @@ -0,0 +1,68 @@ +using BlazorBootstrap; +using Microsoft.EntityFrameworkCore; +using DbContext = Aaru.Server.Database.DbContext; + +namespace Aaru.Server.Components.Admin.Pages.Pcmcia; + +public partial class View +{ + private int _deleteId; + private Modal? _deleteModal; + bool _initialized; + List _items; + + /// + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + + StateHasChanged(); + + await using DbContext ctx = await DbContextFactory.CreateDbContextAsync(); + + _items = await ctx.Pcmcia.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 DeleteVersionAsync(_deleteId); + await HideDeleteModal(); + await RefreshItemsAsync(); + } + + private async Task DeleteVersionAsync(int id) + { + await using DbContext ctx = await DbContextFactory.CreateDbContextAsync(); + CommonTypes.Metadata.Pcmcia? pcmcia = await ctx.Pcmcia.FindAsync(id); + + if(pcmcia is not null) + { + ctx.Pcmcia.Remove(pcmcia); + await ctx.SaveChangesAsync(); + } + } + + private async Task RefreshItemsAsync() + { + await using DbContext ctx = await DbContextFactory.CreateDbContextAsync(); + + _items = await ctx.Pcmcia.ToListAsync(); + + StateHasChanged(); + } +} \ No newline at end of file