diff --git a/Marechai/Areas/Admin/Views/Home/Index.cshtml b/Marechai/Areas/Admin/Views/Home/Index.cshtml index d95bf9bc..e19fca53 100644 --- a/Marechai/Areas/Admin/Views/Home/Index.cshtml +++ b/Marechai/Areas/Admin/Views/Home/Index.cshtml @@ -42,8 +42,6 @@
Instruction set extensions by processor
- Machines -
Machine photos
Memory by machines diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 7f7da898..ee0369cf 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 3.0.99.1059 + 3.0.99.1060 Canary Islands Computer Museum Copyright © 2003-2020 Natalia Portillo Canary Islands Computer Museum Website @@ -64,6 +64,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 ed76d96d..d2b8464c 100644 --- a/Marechai/Pages/Admin/Index.razor +++ b/Marechai/Pages/Admin/Index.razor @@ -62,6 +62,9 @@
  • @L["Machine families"]
  • +
  • + @L["Machines"] +
  • diff --git a/Marechai/Pages/Admin/Machines.razor b/Marechai/Pages/Admin/Machines.razor new file mode 100644 index 00000000..8e030369 --- /dev/null +++ b/Marechai/Pages/Admin/Machines.razor @@ -0,0 +1,119 @@ +@{ +/****************************************************************************** +// MARECHAI: Master repository of computing history artifacts information +// ---------------------------------------------------------------------------- +// +// Filename : Machines.razor +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// List of machines +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2020 Natalia Portillo +*******************************************************************************/ +} + +@page "/admin/machines" +@inherits OwningComponentBase +@inject IStringLocalizer L +@attribute [Authorize(Roles = "UberAdmin, Admin")] +

    @L["Machines"]

    +@if (_machines is null) +{ +

    @L["Loading..."]

    + + return; +} +

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

    + + + + + + + + + + + + + + @foreach (var item in _machines) + { + + + + + + + + + + } + +
    + @L["Company"] + + @L["Family"] + + @L["Name"] + + @L["Model"] + + @L["Introduced"] + + @L["Type"] +
    + @item.Company + + @item.Family + + @item.Name + + @item.Model + + @item.IntroducedView + + @item.Type + + + @L["Details"] + + + @L["Edit"] + + + @L["Delete"] + +
    + +@code +{ + List _machines; + + protected override async Task OnInitializedAsync() + { + _machines = 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 a7c157d9..2fac4361 100644 --- a/Marechai/Resources/Services/AdminService.es.resx +++ b/Marechai/Resources/Services/AdminService.es.resx @@ -182,4 +182,8 @@ Familias de máquinas Machine families. + + Máquinas + Machines. + \ No newline at end of file diff --git a/Marechai/Resources/Services/MachinesService.es.resx b/Marechai/Resources/Services/MachinesService.es.resx index bf30b5b3..ead4bf35 100644 --- a/Marechai/Resources/Services/MachinesService.es.resx +++ b/Marechai/Resources/Services/MachinesService.es.resx @@ -430,4 +430,20 @@ {0} con una capacidad norminal de {1} {0} is storage type, {1} is nominal capacity number formatted with above bytes or bps prefixes + + Tipo + Type + + + Introducida en + Introduced + + + Nombre + Name + + + Compañía + Company + \ No newline at end of file diff --git a/Marechai/Services/MachinesService.cs b/Marechai/Services/MachinesService.cs index a3153aac..814bbc47 100644 --- a/Marechai/Services/MachinesService.cs +++ b/Marechai/Services/MachinesService.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Marechai.Database.Models; using Marechai.ViewModels; @@ -18,6 +19,14 @@ namespace Marechai.Services _l = localizer; } + public async Task> GetAsync() => + await _context.Machines.OrderBy(m => m.Company.Name).ThenBy(m => m.Name).ThenBy(m => m.Family.Name). + Select(m => new MachineViewModel + { + Id = m.Id, Company = m.Company.Name, Name = m.Name, Model = m.Model, + Introduced = m.Introduced, Type = m.Type, Family = m.Family.Name + }).ToListAsync(); + public async Task GetMachine(int id) { Machine machine = await _context.Machines.FindAsync(id); diff --git a/Marechai/ViewModels/MachineViewModel.cs b/Marechai/ViewModels/MachineViewModel.cs index f8ad7103..54c6db86 100644 --- a/Marechai/ViewModels/MachineViewModel.cs +++ b/Marechai/ViewModels/MachineViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Marechai.Database; namespace Marechai.ViewModels { @@ -18,5 +19,10 @@ namespace Marechai.ViewModels public List Processors { get; set; } public List SoundSynthesizers { get; set; } public List Storage { get; set; } + public string Company { get; set; } + public MachineType Type { get; set; } + public string Family { get; set; } + public string IntroducedView => + Introduced?.Year == 1000 ? "Prototype" : Introduced?.ToShortDateString() ?? "Unknown"; } } \ No newline at end of file