mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move processors admin index to Blazor.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>3.0.99.1062</Version>
|
||||
<Version>3.0.99.1063</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
@@ -73,6 +73,9 @@
|
||||
<Content Update="Pages\Admin\News.razor">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
<Content Update="Pages\Admin\Processors.razor">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
||||
|
||||
@@ -71,6 +71,9 @@
|
||||
<li>
|
||||
<a href="/admin/news">@L["News"]</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin/processors">@L["Processors"]</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="content">
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Index.cshtml
|
||||
// Filename : Processors.razor
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Admin view index
|
||||
// List of processors
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -29,69 +29,86 @@
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
}
|
||||
@model IEnumerable<Marechai.Areas.Admin.Models.ProcessorViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Processors (Admin)";
|
||||
@page "/admin/processors"
|
||||
@using Marechai.Database.Models
|
||||
@inherits OwningComponentBase<ProcessorsService>
|
||||
@inject IStringLocalizer<ProcessorsService> L
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
<h3>@L["Processors"]</h3>
|
||||
@if (_processors is null)
|
||||
{
|
||||
<p>@L["Loading..."]</p>
|
||||
|
||||
return;
|
||||
}
|
||||
<h2>Processors</h2>
|
||||
<p>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
Create new
|
||||
</a>
|
||||
<span class="btn btn-primary">
|
||||
@L["Create new"]
|
||||
</span>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company)
|
||||
@L["Company"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
@L["Name"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.ModelCode)
|
||||
@L["Model code"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Introduced)
|
||||
@L["Introduced"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.InstructionSet)
|
||||
@L["Instruction set"]
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
@foreach (var item in _processors)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company)
|
||||
@item.CompanyName
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ModelCode)
|
||||
@item.ModelCode
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.IntroducedView)
|
||||
@item.IntroducedView
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.InstructionSet)
|
||||
@item.InstructionSet
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">
|
||||
Details
|
||||
</a>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">
|
||||
Edit
|
||||
</a>
|
||||
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">
|
||||
Delete
|
||||
</a>
|
||||
<span class="btn btn-primary">
|
||||
@L["Details"]
|
||||
</span>
|
||||
<span class="btn btn-secondary">
|
||||
@L["Edit"]
|
||||
</span>
|
||||
<span class="btn btn-danger">
|
||||
@L["Delete"]
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
@code
|
||||
{
|
||||
List<ProcessorViewModel> _processors;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_processors = await Service.GetAsync();
|
||||
}
|
||||
}
|
||||
@@ -194,4 +194,8 @@
|
||||
<value>Noticias</value>
|
||||
<comment>News.</comment>
|
||||
</data>
|
||||
<data name="Processors" xml:space="preserve">
|
||||
<value>Procesadores</value>
|
||||
<comment>Processors.</comment>
|
||||
</data>
|
||||
</root>
|
||||
165
Marechai/Resources/Services/ProcessorsService.es.resx
Normal file
165
Marechai/Resources/Services/ProcessorsService.es.resx
Normal file
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ReSharper disable MarkupTextTypo -->
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Processors" xml:space="preserve">
|
||||
<value>Procesadores</value>
|
||||
<comment>Processors</comment>
|
||||
</data>
|
||||
<data name="Loading..." xml:space="preserve">
|
||||
<value>Cargando...</value>
|
||||
<comment>Message that appears while data is being loaded from database</comment>
|
||||
</data>
|
||||
<data name="Name" xml:space="preserve">
|
||||
<value>Nombre</value>
|
||||
<comment>Name</comment>
|
||||
</data>
|
||||
<data name="Company" xml:space="preserve">
|
||||
<value>Compañía</value>
|
||||
<comment>Company</comment>
|
||||
</data>
|
||||
<data name="Introduced" xml:space="preserve">
|
||||
<value>Introducido el</value>
|
||||
<comment>Introduced</comment>
|
||||
</data>
|
||||
<data name="Model code" xml:space="preserve">
|
||||
<value>Modelo</value>
|
||||
<comment>Model code</comment>
|
||||
</data>
|
||||
<data name="Instruction set" xml:space="preserve">
|
||||
<value>Arquitectura</value>
|
||||
<comment>Instruction set</comment>
|
||||
</data>
|
||||
<data name="Create new" xml:space="preserve">
|
||||
<value>Crear nuevo</value>
|
||||
<comment>Create new</comment>
|
||||
</data>
|
||||
<data name="Details" xml:space="preserve">
|
||||
<value>Detalles</value>
|
||||
<comment>Details</comment>
|
||||
</data>
|
||||
<data name="Edit" xml:space="preserve">
|
||||
<value>Editar</value>
|
||||
<comment>Edit</comment>
|
||||
</data>
|
||||
<data name="Delete" xml:space="preserve">
|
||||
<value>Eliminar</value>
|
||||
<comment>Delete</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -12,11 +12,14 @@ namespace Marechai.Services
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
readonly IStringLocalizer<MachinesService> _l;
|
||||
readonly ProcessorsService _processorsService;
|
||||
|
||||
public MachinesService(MarechaiContext context, IStringLocalizer<MachinesService> localizer)
|
||||
public MachinesService(MarechaiContext context, IStringLocalizer<MachinesService> localizer,
|
||||
ProcessorsService processorsService)
|
||||
{
|
||||
_context = context;
|
||||
_l = localizer;
|
||||
_context = context;
|
||||
_l = localizer;
|
||||
_processorsService = processorsService;
|
||||
}
|
||||
|
||||
public async Task<List<MachineViewModel>> GetAsync() =>
|
||||
@@ -80,28 +83,7 @@ namespace Marechai.Services
|
||||
Type = m.Type, Usage = m.Usage, Size = m.Size, Speed = m.Speed
|
||||
}).ToListAsync();
|
||||
|
||||
model.Processors = await _context.ProcessorsByMachine.Where(p => p.MachineId == machine.Id).
|
||||
Select(p => new ProcessorViewModel
|
||||
{
|
||||
Name = p.Processor.Name, CompanyName = p.Processor.Company.Name,
|
||||
CompanyId = p.Processor.Company.Id, ModelCode = p.Processor.ModelCode,
|
||||
Introduced = p.Processor.Introduced, Speed = p.Speed,
|
||||
Package = p.Processor.Package, Gprs = p.Processor.Gprs,
|
||||
GprSize = p.Processor.GprSize, Fprs = p.Processor.Fprs,
|
||||
FprSize = p.Processor.FprSize, Cores = p.Processor.Cores,
|
||||
ThreadsPerCore = p.Processor.ThreadsPerCore,
|
||||
Process = p.Processor.Process, ProcessNm = p.Processor.ProcessNm,
|
||||
DieSize = p.Processor.DieSize, Transistors = p.Processor.Transistors,
|
||||
DataBus = p.Processor.DataBus, AddrBus = p.Processor.AddrBus,
|
||||
SimdRegisters = p.Processor.SimdRegisters,
|
||||
SimdSize = p.Processor.SimdSize,
|
||||
L1Instruction = p.Processor.L1Instruction,
|
||||
L1Data = p.Processor.L1Data, L2 = p.Processor.L2, L3 = p.Processor.L3,
|
||||
InstructionSet = p.Processor.InstructionSet.Name,
|
||||
InstructionSetExtensions =
|
||||
p.Processor.InstructionSetExtensions.
|
||||
Select(e => e.Extension.Extension).ToList()
|
||||
}).ToListAsync();
|
||||
model.Processors = await _processorsService.GetByMachineAsync(machine.Id);
|
||||
|
||||
model.SoundSynthesizers =
|
||||
await _context.SoundByMachine.Where(s => s.MachineId == machine.Id).Select(s => s.SoundSynth).
|
||||
|
||||
45
Marechai/Services/ProcessorsService.cs
Normal file
45
Marechai/Services/ProcessorsService.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Database.Models;
|
||||
using Marechai.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Marechai.Services
|
||||
{
|
||||
public class ProcessorsService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public ProcessorsService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<ProcessorViewModel>> GetAsync() =>
|
||||
await _context.Processors.Select(p => new ProcessorViewModel
|
||||
{
|
||||
Name = p.Name, CompanyName = p.Company.Name, CompanyId = p.Company.Id, ModelCode = p.ModelCode,
|
||||
Introduced = p.Introduced, Speed = p.Speed, Package = p.Package, Gprs = p.Gprs,
|
||||
GprSize = p.GprSize, Fprs = p.Fprs, FprSize = p.FprSize, Cores = p.Cores,
|
||||
ThreadsPerCore = p.ThreadsPerCore, Process = p.Process, ProcessNm = p.ProcessNm, DieSize = p.DieSize,
|
||||
Transistors = p.Transistors, DataBus = p.DataBus, AddrBus = p.AddrBus, SimdRegisters = p.SimdRegisters,
|
||||
SimdSize = p.SimdSize, L1Instruction = p.L1Instruction, L1Data = p.L1Data, L2 = p.L2,
|
||||
L3 = p.L3, InstructionSet = p.InstructionSet.Name,
|
||||
InstructionSetExtensions = p.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList()
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<List<ProcessorViewModel>> GetByMachineAsync(int machineId) =>
|
||||
await _context.ProcessorsByMachine.Where(p => p.MachineId == machineId).Select(p => new ProcessorViewModel
|
||||
{
|
||||
Name = p.Processor.Name, CompanyName = p.Processor.Company.Name, CompanyId = p.Processor.Company.Id,
|
||||
ModelCode = p.Processor.ModelCode, Introduced = p.Processor.Introduced, Speed = p.Speed,
|
||||
Package = p.Processor.Package, Gprs = p.Processor.Gprs, GprSize = p.Processor.GprSize,
|
||||
Fprs = p.Processor.Fprs, FprSize = p.Processor.FprSize, Cores = p.Processor.Cores,
|
||||
ThreadsPerCore = p.Processor.ThreadsPerCore, Process = p.Processor.Process,
|
||||
ProcessNm = p.Processor.ProcessNm, DieSize = p.Processor.DieSize, Transistors = p.Processor.Transistors,
|
||||
DataBus = p.Processor.DataBus, AddrBus = p.Processor.AddrBus, SimdRegisters = p.Processor.SimdRegisters,
|
||||
SimdSize = p.Processor.SimdSize, L1Instruction = p.Processor.L1Instruction, L1Data = p.Processor.L1Data,
|
||||
L2 = p.Processor.L2, L3 = p.Processor.L3, InstructionSet = p.Processor.InstructionSet.Name,
|
||||
InstructionSetExtensions =
|
||||
p.Processor.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList()
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ namespace Marechai.Services
|
||||
services.AddScoped<LicensesService>();
|
||||
services.AddScoped<MachineFamiliesService>();
|
||||
services.AddScoped<PeopleService>();
|
||||
services.AddScoped<ProcessorsService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,7 @@ namespace Marechai.ViewModels
|
||||
public string InstructionSet { get; set; }
|
||||
public List<string> InstructionSetExtensions { get; set; }
|
||||
public int? CompanyId { get; set; }
|
||||
|
||||
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user