From ef8aba25ae1d40ba96d0539f8ed7d1f216d083c8 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 24 May 2020 06:01:10 +0100 Subject: [PATCH] Move instruction sets admin index to Blazor. --- Marechai/Areas/Admin/Views/Home/Index.cshtml | 2 - Marechai/Marechai.csproj | 5 +- Marechai/Pages/Admin/Index.razor | 3 + .../Admin/InstructionSetExtensions.razor | 2 +- .../Admin/InstructionSets.razor} | 65 +++++--- .../Resources/Services/AdminService.es.resx | 4 + .../Services/InstructionSetsService.es.resx | 149 ++++++++++++++++++ Marechai/Services/InstructionSetsService.cs | 18 +++ Marechai/Services/Register.cs | 1 + 9 files changed, 221 insertions(+), 28 deletions(-) rename Marechai/{Areas/Admin/Views/InstructionSets/Index.cshtml => Pages/Admin/InstructionSets.razor} (57%) create mode 100644 Marechai/Resources/Services/InstructionSetsService.es.resx create mode 100644 Marechai/Services/InstructionSetsService.cs diff --git a/Marechai/Areas/Admin/Views/Home/Index.cshtml b/Marechai/Areas/Admin/Views/Home/Index.cshtml index 1d17ebfc..b34433f2 100644 --- a/Marechai/Areas/Admin/Views/Home/Index.cshtml +++ b/Marechai/Areas/Admin/Views/Home/Index.cshtml @@ -40,8 +40,6 @@
GPUs by machine
- Instruction sets -
Instruction set extensions by processor
Licenses diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 74c10cc5..3273f604 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 3.0.99.1055 + 3.0.99.1056 Canary Islands Computer Museum Copyright © 2003-2020 Natalia Portillo Canary Islands Computer Museum Website @@ -55,6 +55,9 @@ true + + true + <_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" /> diff --git a/Marechai/Pages/Admin/Index.razor b/Marechai/Pages/Admin/Index.razor index 3d56c795..8f15de12 100644 --- a/Marechai/Pages/Admin/Index.razor +++ b/Marechai/Pages/Admin/Index.razor @@ -50,6 +50,9 @@
  • @L["Graphics Processing Units"]
  • +
  • + @L["Instruction sets"] +
  • @L["Instruction set extensions"]
  • diff --git a/Marechai/Pages/Admin/InstructionSetExtensions.razor b/Marechai/Pages/Admin/InstructionSetExtensions.razor index a6a9182f..dd6f4386 100644 --- a/Marechai/Pages/Admin/InstructionSetExtensions.razor +++ b/Marechai/Pages/Admin/InstructionSetExtensions.razor @@ -51,7 +51,7 @@ - @L["Extensions"] + @L["Extension"] diff --git a/Marechai/Areas/Admin/Views/InstructionSets/Index.cshtml b/Marechai/Pages/Admin/InstructionSets.razor similarity index 57% rename from Marechai/Areas/Admin/Views/InstructionSets/Index.cshtml rename to Marechai/Pages/Admin/InstructionSets.razor index c6148d0c..e8e317e9 100644 --- a/Marechai/Areas/Admin/Views/InstructionSets/Index.cshtml +++ b/Marechai/Pages/Admin/InstructionSets.razor @@ -1,14 +1,14 @@ -@{ - /****************************************************************************** +@{ +/****************************************************************************** // MARECHAI: Master repository of computing history artifacts information // ---------------------------------------------------------------------------- // -// Filename : Index.cshtml +// Filename : InstructionSets.razor // Author(s) : Natalia Portillo // // --[ Description ] ---------------------------------------------------------- // -// Admin view index +// List of instruction sets // // --[ License ] -------------------------------------------------------------- // @@ -29,45 +29,62 @@ // Copyright © 2003-2020 Natalia Portillo *******************************************************************************/ } -@model IEnumerable -@{ - ViewData["Title"] = "Instruction sets (Admin)"; +@page "/admin/instruction_sets" +@using Marechai.Database.Models +@inherits OwningComponentBase +@inject IStringLocalizer L +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

    @L["Instruction sets"]

    +@if (_instructionSets is null) +{ +

    @L["Loading..."]

    + + return; } -

    Instruction sets

    - - Create new - + + @L["Create new"] +

    - @foreach (var item in Model) + @foreach (var item in _instructionSets) { } -
    - @Html.DisplayNameFor(model => model.Name) + @L["Name"]
    - @Html.DisplayFor(modelItem => item.Name) + @item.Name - - Details - - - Edit - - - Delete - + + @L["Details"] + + + @L["Edit"] + + + @L["Delete"] +
    \ No newline at end of file + + +@code +{ + List _instructionSets; + + protected override async Task OnInitializedAsync() + { + _instructionSets = await Service.GetAsync(); + } +} \ No newline at end of file diff --git a/Marechai/Resources/Services/AdminService.es.resx b/Marechai/Resources/Services/AdminService.es.resx index d6d6f7dd..944df9a2 100644 --- a/Marechai/Resources/Services/AdminService.es.resx +++ b/Marechai/Resources/Services/AdminService.es.resx @@ -170,4 +170,8 @@ Extensiones de arquitectura Instruction set extensions. + + Arquitecturas + Instruction sets. + \ No newline at end of file diff --git a/Marechai/Resources/Services/InstructionSetsService.es.resx b/Marechai/Resources/Services/InstructionSetsService.es.resx new file mode 100644 index 00000000..f6c17ffd --- /dev/null +++ b/Marechai/Resources/Services/InstructionSetsService.es.resx @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Arquitecturas + Instruction sets + + + Cargando... + Message that appears while data is being loaded from database + + + Nombre + Name + + + Crear nueva + Create new + + + Detalles + Details + + + Editar + Edit + + + Eliminar + Delete + + \ No newline at end of file diff --git a/Marechai/Services/InstructionSetsService.cs b/Marechai/Services/InstructionSetsService.cs new file mode 100644 index 00000000..260c78a3 --- /dev/null +++ b/Marechai/Services/InstructionSetsService.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marechai.Database.Models; +using Microsoft.EntityFrameworkCore; + +namespace Marechai.Services +{ + public class InstructionSetsService + { + readonly MarechaiContext _context; + + public InstructionSetsService(MarechaiContext context) => _context = context; + + public async Task> GetAsync() => + await _context.InstructionSets.OrderBy(s => s.Name).ToListAsync(); + } +} \ No newline at end of file diff --git a/Marechai/Services/Register.cs b/Marechai/Services/Register.cs index 0e7705af..5f413550 100644 --- a/Marechai/Services/Register.cs +++ b/Marechai/Services/Register.cs @@ -52,6 +52,7 @@ namespace Marechai.Services services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); } } } \ No newline at end of file