diff --git a/Marechai.sln.DotSettings b/Marechai.sln.DotSettings index 0a9008d3..c57070a6 100644 --- a/Marechai.sln.DotSettings +++ b/Marechai.sln.DotSettings @@ -1,5 +1,6 @@  True + True True True True diff --git a/Marechai/Areas/Admin/Views/Processors/Edit.cshtml b/Marechai/Areas/Admin/Views/Processors/Edit.cshtml deleted file mode 100644 index 06f05ff0..00000000 --- a/Marechai/Areas/Admin/Views/Processors/Edit.cshtml +++ /dev/null @@ -1,231 +0,0 @@ -@{ - /****************************************************************************** -// MARECHAI: Master repository of computing history artifacts information -// ---------------------------------------------------------------------------- -// -// Filename : Edit.cshtml -// Author(s) : Natalia Portillo -// -// --[ Description ] ---------------------------------------------------------- -// -// Admin view edit -// -// --[ 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 -*******************************************************************************/ -} -@model Marechai.Database.Models.Processor - -@{ - ViewData["Title"] = "Edit"; -} -

Edit

-

Processor

-
-
-
-
-
-
- -
- - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- - - - -
- -
-
-
- -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } -} \ No newline at end of file diff --git a/Marechai/Marechai.csproj b/Marechai/Marechai.csproj index 87b8622a..5b6d8b47 100644 --- a/Marechai/Marechai.csproj +++ b/Marechai/Marechai.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 3.0.99.1219 + 3.0.99.1223 Canary Islands Computer Museum Copyright © 2003-2020 Natalia Portillo Canary Islands Computer Museum Website diff --git a/Marechai/Pages/Admin/Details/Processor.razor b/Marechai/Pages/Admin/Details/Processor.razor index 4e0bf779..0c4cb09d 100644 --- a/Marechai/Pages/Admin/Details/Processor.razor +++ b/Marechai/Pages/Admin/Details/Processor.razor @@ -31,10 +31,12 @@ } @page "/admin/processors/details/{Id:int}" +@page "/admin/processors/edit/{Id:int}" @inherits OwningComponentBase @inject IStringLocalizer L @inject CompaniesService CompaniesService @inject InstructionSetsService InstructionSetsService +@inject NavigationManager NavigationManager @attribute [Authorize(Roles = "UberAdmin, Admin")]

@L["Processor details"]


@@ -47,197 +49,537 @@ }
- - @L["Name"] - - - @if (_editable || _model.CompanyId != null) + @if (_editing || _model.CompanyId != null) { @L["Company"] - + @if (_editing) + { + @L["Unknown (company)"] + } + @if (!_editing || + !_unknownCompany) + { + + } } - @if (_editable || _model.ModelCode != null) + + @L["Name"] + + + + @L["Please enter a valid name."] + + + + + @if (_editing || _model.ModelCode != null) { @L["Model code"] - + @if (_editing) + { + @L["Unknown (model code)"] + } + @if (!_editing || + !_unknownModelCode) + { + + + + @L["Please enter a valid model code."] + + + + } } - @if(_editable || _model.Introduced.HasValue) + @if (_editing || _model.Introduced.HasValue) { @L["Introduced"] - @if(_model.Introduced?.Year == 1000) + @if (_editing) { - @L["PROTOTYPE"] + @L["Unknown (introduction date)"] + @L["Prototype"] } - else + @if (!_editing || + (!_prototype && !_unknownIntroduced)) { - + + + + @L["Please enter an introduction date."] + + + } - + } - @if (_editable || _model.InstructionSetId.HasValue) + @if (_editing || _model.InstructionSetId != null) { @L["Instruction set"] - + @if (_editing) + { + @L["Unknown (instruction set)"] + } + @if (!_editing || + !_unknownInstructionSet) + { + + } } - @if (_editable || _model.Speed.HasValue) + @if (_editing || _model.Speed.HasValue) { @L["Nominal speed (MHz)"] - + @if (_editing) + { + @L["Unknown (nominal speed)"] + } + @if (!_editing || + !_unknownSpeed) + { + + + + @L["Please enter a valid nominal speed."] + + + + } } - @if (_editable || _model.Package != null) + @if (_editing || _model.Package != null) { @L["Package"] - + @if (_editing) + { + @L["Unknown (package)"] + } + @if (!_editing || + !_unknownPackage) + { + + + + @L["Please enter a valid package."] + + + + } } - @if (_editable || _model.Gprs.HasValue) + @if (_editing || _model.Gprs.HasValue) { @L["General Purpose Registers"] - + @if (_editing) + { + @L["Unknown (general purpose registers)"] + } + @if (!_editing || + !_unknownGprs) + { + + + + @L["Please enter a valid number of general purpose registers."] + + + + } } - @if (_editable || _model.GprSize.HasValue) + @if (_editing || _model.GprSize.HasValue) { @L["General Purpose Register size"] - + @if (_editing) + { + @L["Unknown (general purpose register size)"] + } + @if (!_editing || + !_unknownGprSize) + { + + + + @L["Please enter a valid general purpose register size."] + + + + } } - @if (_editable || _model.Fprs.HasValue) + @if (_editing || _model.Fprs.HasValue) { @L["Floating Point Registers"] - + @if (_editing) + { + @L["Unknown (floating point registers)"] + } + @if (!_editing || + !_unknownFprs) + { + + + + @L["Please enter a valid number of floating point registers."] + + + + } + @if (_editing) + { + @L["If set to zero, but with a size, indicates floating point instructions use the general purpose registers."] + } } - @if (_editable || _model.FprSize.HasValue) + @if (_editing || _model.FprSize.HasValue) { @L["Floating Point Register size"] - + @if (_editing) + { + @L["Unknown (floating point register size)"] + } + @if (!_editing || + !_unknownFprSize) + { + + + + @L["Please enter a valid floating point register size."] + + + + } } - @if (_editable || _model.SimdRegisters.HasValue) + @if (_editing || _model.SimdRegisters.HasValue) { @L["SIMD Registers"] - + @if (_editing) + { + @L["Unknown (simd registers)"] + } + @if (!_editing || + !_unknownSimdRegisters) + { + + + + @L["Please enter a valid number of SIMD registers."] + + + + } + @if (_editing) + { + @L["If set to zero, but with a size, indicates SIMD instructions use the floating point registers. If they are also set to zero with a size, it means SIMD instructions use the general purpose registers."] + } } - @if (_editable || _model.SimdSize.HasValue) + @if (_editing || _model.SimdSize.HasValue) { @L["SIMD Register size"] - + @if (_editing) + { + @L["Unknown (simd register size)"] + } + @if (!_editing || + !_unknownSimdSize) + { + + + + @L["Please enter a valid SIMD register size."] + + + + } } - @if (_editable || _model.Cores.HasValue) + @if (_editing || _model.Cores.HasValue) { @L["Cores"] - + @if (_editing) + { + @L["Unknown (cores)"] + } + @if (!_editing || + !_unknownCores) + { + + + + @L["Please enter a valid number of cores."] + + + + } } - @if (_editable || _model.ThreadsPerCore.HasValue) + @if (_editing || _model.ThreadsPerCore.HasValue) { @L["Threads per core"] - + @if (_editing) + { + @L["Unknown (threads per core)"] + } + @if (!_editing || + !_unknownThreadsPerCore) + { + + + + @L["Please enter a valid number of threads per core."] + + + + } } - @if (_editable || _model.Process != null) + @if (_editing || _model.Process != null) { @L["Process"] - + @if (_editing) + { + @L["Unknown (process)"] + } + @if (!_editing || + !_unknownProcess) + { + + + + @L["Please enter a valid process."] + + + + } } - @if (_editable || _model.ProcessNm.HasValue) + @if (_editing || _model.ProcessNm.HasValue) { @L["Process (nm)"] - + @if (_editing) + { + @L["Unknown (process size)"] + } + @if (!_editing || + !_unknownProcessNm) + { + + + + @L["Please enter a valid process size in nanometers."] + + + + } } - @if (_editable || _model.DieSize.HasValue) + @if (_editing || _model.DieSize.HasValue) { @L["Die size (mm²)"] - + @if (_editing) + { + @L["Unknown (die size)"] + } + @if (!_editing || + !_unknownDieSize) + { + + + + @L["Please enter a valid die size in square millimeters."] + + + + } } - @if (_editable || _model.Transistors.HasValue) + @if (_editing || _model.Transistors.HasValue) { @L["Transistors"] - + @if (_editing) + { + @L["Unknown (transistors)"] + } + @if (!_editing || + !_unknownTransistors) + { + + + + @L["Please enter a valid number of transistors."] + + + + } } - @if (_editable || _model.DataBus.HasValue) + @if (_editing || _model.DataBus.HasValue) { @L["Data bus size"] - + @if (_editing) + { + @L["Unknown (data bus size)"] + } + @if (!_editing || + !_unknownDataBus) + { + + + + @L["Please enter a valid data bus size in bits."] + + + + } } - @if (_editable || _model.AddrBus.HasValue) + @if (_editing || _model.AddrBus.HasValue) { @L["Address bus size"] - + @if (_editing) + { + @L["Unknown (address bus size)"] + } + @if (!_editing || + !_unknownAddressBus) + { + + + + @L["Please enter a valid address bus size in bits."] + + + + } } - @if (_editable || _model.L1Instruction.HasValue) + @if (_editing || _model.L1Instruction.HasValue) { @L["L1 instruction cache (KiB)"] - + @if (_editing) + { + @L["Unknown (L1 instruction cache)"] + } + @if (!_editing || + !_unknownL1Instruction) + { + + + + @L["Please enter a valid L1 instruction cache size in kibibytes."] + + + + } } - @if (_editable || _model.L1Data.HasValue) + @if (_editing || _model.L1Data.HasValue) { @L["L1 data cache (KiB)"] - + @if (_editing) + { + @L["Unknown (L1 data cache)"] + } + @if (!_editing || + !_unknownL1Data) + { + + + + @L["Please enter a valid L1 data cache size in kibibytes."] + + + + } } - @if (_editable || _model.L2.HasValue) + @if (_editing || _model.L2.HasValue) { @L["L2 cache (KiB)"] - + @if (_editing) + { + @L["Unknown (L2 cache)"] + } + @if (!_editing || + !_unknownL2) + { + + + + @L["Please enter a valid L2 cache size in kibibytes."] + + + + } } - @if (_editable || _model.L3.HasValue) + @if (_editing || _model.L3.HasValue) { @L["L3 cache (KiB)"] - + @if (_editing) + { + @L["Unknown (L3 cache)"] + } + @if (!_editing || + !_unknownL3) + { + + + + @L["Please enter a valid L3 cache size in kibibytes."] + + + + } }
- @L["Edit"] + @if (!_editing) + { + + } + else + { + + + } @L["Back to list"]
\ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Processor.razor.cs b/Marechai/Pages/Admin/Details/Processor.razor.cs index 1f667e4d..12e38e34 100644 --- a/Marechai/Pages/Admin/Details/Processor.razor.cs +++ b/Marechai/Pages/Admin/Details/Processor.razor.cs @@ -1,5 +1,8 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; +using Blazorise; +using Marechai.Shared; using Marechai.ViewModels; using Microsoft.AspNetCore.Components; @@ -8,10 +11,35 @@ namespace Marechai.Pages.Admin.Details public partial class Processor { List _companies; - bool _editable; + bool _editing; List _instructionSets; bool _loaded; - Database.Models.Processor _model; + ProcessorViewModel _model; + bool _prototype; + bool _unknownAddressBus; + bool _unknownCompany; + bool _unknownCores; + bool _unknownDataBus; + bool _unknownDieSize; + bool _unknownFprs; + bool _unknownFprSize; + bool _unknownGprs; + bool _unknownGprSize; + bool _unknownInstructionSet; + bool _unknownIntroduced; + bool _unknownL1Data; + bool _unknownL1Instruction; + bool _unknownL2; + bool _unknownL3; + bool _unknownModelCode; + bool _unknownPackage; + bool _unknownProcess; + bool _unknownProcessNm; + bool _unknownSimdRegisters; + bool _unknownSimdSize; + bool _unknownSpeed; + bool _unknownThreadsPerCore; + bool _unknownTransistors; [Parameter] public int Id { get; set; } @@ -29,7 +57,213 @@ namespace Marechai.Pages.Admin.Details _instructionSets = await InstructionSetsService.GetAsync(); _model = await Service.GetAsync(Id); + _editing = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant(). + StartsWith("admin/processors/edit/", StringComparison.InvariantCulture); + + if(_editing) + SetCheckboxes(); + StateHasChanged(); } + + void SetCheckboxes() + { + _unknownAddressBus = !_model.AddrBus.HasValue; + _unknownCompany = !_model.CompanyId.HasValue; + _unknownCores = !_model.Cores.HasValue; + _unknownDataBus = !_model.DataBus.HasValue; + _unknownDieSize = !_model.DieSize.HasValue; + _unknownFprs = !_model.Fprs.HasValue; + _unknownFprSize = !_model.FprSize.HasValue; + _unknownGprs = !_model.Gprs.HasValue; + _unknownGprSize = !_model.GprSize.HasValue; + _unknownInstructionSet = !_model.InstructionSetId.HasValue; + _unknownIntroduced = !_model.Introduced.HasValue; + _unknownL1Data = !_model.L1Data.HasValue; + _unknownL1Instruction = !_model.L1Instruction.HasValue; + _unknownL2 = !_model.L2.HasValue; + _unknownL3 = !_model.L3.HasValue; + _unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode); + _unknownPackage = string.IsNullOrWhiteSpace(_model.Package); + _unknownProcess = string.IsNullOrWhiteSpace(_model.Process); + _unknownProcessNm = !_model.ProcessNm.HasValue; + _unknownSimdRegisters = !_model.SimdRegisters.HasValue; + _unknownSimdSize = !_model.SimdSize.HasValue; + _unknownSpeed = !_model.Speed.HasValue; + _unknownThreadsPerCore = !_model.ThreadsPerCore.HasValue; + _unknownTransistors = !_model.Transistors.HasValue; + } + + void OnEditClicked() + { + _editing = true; + SetCheckboxes(); + StateHasChanged(); + } + + async void OnCancelClicked() + { + _editing = false; + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + async void OnSaveClicked() + { + if(_unknownCompany) + _model.CompanyId = null; + else if(_model.CompanyId < 0) + return; + + if(_unknownModelCode) + _model.ModelCode = null; + else if(string.IsNullOrWhiteSpace(_model.ModelCode)) + return; + + if(_unknownIntroduced) + _model.Introduced = null; + else if(_prototype) + _model.Introduced = new DateTime(1000, 1, 1); + else if(_model.Introduced >= DateTime.UtcNow.Date) + return; + + if(_unknownInstructionSet) + _model.InstructionSetId = null; + else if(_model.InstructionSetId < 0) + return; + + if(_unknownSpeed) + _model.Speed = null; + else if(_model.Speed < 0) + return; + + if(_unknownPackage) + _model.Package = null; + else if(string.IsNullOrWhiteSpace(_model.Package)) + return; + + if(_unknownGprs) + _model.Gprs = null; + else if(_model.Gprs < 0) + return; + + if(_unknownGprSize) + _model.GprSize = null; + else if(_model.GprSize < 0) + return; + + if(_unknownFprs) + _model.Fprs = null; + else if(_model.Fprs < 0) + return; + + if(_unknownFprSize) + _model.FprSize = null; + else if(_model.FprSize < 0) + return; + + if(_unknownSimdRegisters) + _model.SimdRegisters = null; + else if(_model.SimdRegisters < 0) + return; + + if(_unknownSimdSize) + _model.SimdSize = null; + else if(_model.SimdSize < 0) + return; + + if(_unknownCores) + _model.Cores = null; + else if(_model.Cores < 1) + return; + + if(_unknownThreadsPerCore) + _model.ThreadsPerCore = null; + else if(_model.ThreadsPerCore < 1) + return; + + if(_unknownProcess) + _model.Process = null; + else if(string.IsNullOrWhiteSpace(_model.Process)) + return; + + if(_unknownProcessNm) + _model.ProcessNm = null; + else if(_model.ProcessNm < 1) + return; + + if(_unknownDieSize) + _model.DieSize = null; + else if(_model.DieSize < 1) + return; + + if(_unknownTransistors) + _model.Transistors = null; + else if(_model.Transistors < 0) + return; + + if(_unknownDataBus) + _model.DataBus = null; + else if(_model.DataBus < 1) + return; + + if(_unknownAddressBus) + _model.AddrBus = null; + else if(_model.AddrBus < 1) + return; + + if(_unknownL1Instruction) + _model.L1Instruction = null; + else if(_model.L1Instruction < 0) + return; + + if(_unknownL1Data) + _model.L1Data = null; + else if(_model.L1Data < 0) + return; + + if(_unknownL2) + _model.L2 = null; + else if(_model.L2 < 0) + return; + + if(_unknownL3) + _model.FprSize = null; + else if(_model.L3 < 0) + return; + + _editing = false; + await Service.UpdateAsync(_model); + _model = await Service.GetAsync(Id); + SetCheckboxes(); + StateHasChanged(); + } + + void ValidateName(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); + + void ValidateModelCode(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); + + void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); + + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e); + + void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e); + + void ValidatePackage(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Package must be 45 characters or less."], 45); + + void ValidateFloatBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateFloat(e); + + void ValidateIntegerBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateInteger(e, 1); + + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e); + + void ValidateFloatBiggerThanOne(ValidatorEventArgs e) => Validators.ValidateFloat(e, 1); + + void ValidateProcess(ValidatorEventArgs e) => + Validators.ValidateString(e, L["Process must be 45 characters or less."], 45); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/Screen.razor.cs b/Marechai/Pages/Admin/Details/Screen.razor.cs index 04f6d5c6..72c1a357 100644 --- a/Marechai/Pages/Admin/Details/Screen.razor.cs +++ b/Marechai/Pages/Admin/Details/Screen.razor.cs @@ -95,12 +95,11 @@ namespace Marechai.Pages.Admin.Details StateHasChanged(); } - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => - Validators.ValidateDoubleBiggerThanZero(e, 1, 131072); + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e, 1, 131072); - void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLongBiggerThanZero(e, 2); + void ValidateLongBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateLong(e, 2); void ValidateType(ValidatorEventArgs e) => - Validators.ValidateStringWithMaxLength(e, L["Screen type cannot be bigger than 256 characters."], 256); + Validators.ValidateString(e, L["Screen type cannot be bigger than 256 characters."], 256); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Details/SoundSynth.razor.cs b/Marechai/Pages/Admin/Details/SoundSynth.razor.cs index 364308f2..6feab9fc 100644 --- a/Marechai/Pages/Admin/Details/SoundSynth.razor.cs +++ b/Marechai/Pages/Admin/Details/SoundSynth.razor.cs @@ -135,15 +135,15 @@ namespace Marechai.Pages.Admin.Details } void ValidateModelCode(ValidatorEventArgs e) => - Validators.ValidateStringWithMaxLength(e, L["Model code must be 45 characters or less."], 45); + Validators.ValidateString(e, L["Model code must be 45 characters or less."], 45); void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e); - void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateIntegerBiggerThanZero(e); + void ValidateIntegerBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateInteger(e); - void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDoubleBiggerThanZero(e); + void ValidateDoubleBiggerThanZero(ValidatorEventArgs e) => Validators.ValidateDouble(e); void ValidateName(ValidatorEventArgs e) => - Validators.ValidateStringWithMaxLength(e, L["Name must be 50 characters or less."], 50); + Validators.ValidateString(e, L["Name must be 50 characters or less."], 50); } } \ No newline at end of file diff --git a/Marechai/Pages/Admin/Processors.razor b/Marechai/Pages/Admin/Processors.razor index 6383234b..dc45800e 100644 --- a/Marechai/Pages/Admin/Processors.razor +++ b/Marechai/Pages/Admin/Processors.razor @@ -88,9 +88,7 @@ @L["Details"] - - @L["Edit"] - + @L["Edit"] diff --git a/Marechai/Resources/Services/ProcessorsService.en.resx b/Marechai/Resources/Services/ProcessorsService.en.resx new file mode 100644 index 00000000..308cf69d --- /dev/null +++ b/Marechai/Resources/Services/ProcessorsService.en.resx @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Unknown + Unknown, referring to a company + + + Unknown + Unknown, referring to a model code + + + Unknown + Unknown, referring to an introduction date + + + Unknown + Unknown, referring to an instruction set + + + Unknown + Unknown, referring to a nominal speed + + + Unknown + Unknown, referring to a chip package + + + Unknown + Unknown, referring to the number of general purpose registers + + + Unknown + Unknown, referring to the size of a general purpose register + + + Unknown + Unknown, referring to the number of floating point registers + + + Unknown + Unknown, referring to the size of a floating point register + + + Unknown + Unknown, referring to the number of SIMD registers + + + Unknown + Unknown, referring to the size of a SIMD register + + + Unknown + Unknown, referring to the number of cores + + + Unknown + Unknown, referring to the number of threads per core + + + Unknown + Unknown, referring to the chip process + + + Unknown + Unknown, referring to the chip process size in nanometers + + + Unknown + Unknown, referring to the die size in square millimeters + + + Unknown + Unknown, referring to the number of transistors + + + Unknown + Unknown, referring to the size of the data bus + + + Unknown + Unknown, referring to the size of the address bus + + + Unknown + Unknown, referring to the size of the L1 instruction cache + + + Unknown + Unknown, referring to the size of the L1 data cache + + + Unknown + Unknown, referring to the size of the L2 data cache + + + Unknown + Unknown, referring to the size of the L3 data cache + + \ No newline at end of file diff --git a/Marechai/Resources/Services/ProcessorsService.es.resx b/Marechai/Resources/Services/ProcessorsService.es.resx index 7cf40264..ea27ad57 100644 --- a/Marechai/Resources/Services/ProcessorsService.es.resx +++ b/Marechai/Resources/Services/ProcessorsService.es.resx @@ -266,4 +266,208 @@ Caché L3 (KiB) L3 cache (KiB) + + Guardar + Save + + + Desconocida + Unknown, referring to a company + + + Desconocido + Unknown, referring to a model code + + + Desconocida + Unknown, referring to an introduction date + + + Desconocida + Unknown, referring to an instruction set + + + Desconocida + Unknown, referring to a nominal speed + + + Desconocido + Unknown, referring to a chip package + + + Desconocidos + Unknown, referring to the number of general purpose registers + + + Desconocido + Unknown, referring to the size of a general purpose register + + + Desconocidos + Unknown, referring to the number of floating point registers + + + Desconocido + Unknown, referring to the size of a floating point register + + + Desconocidos + Unknown, referring to the number of SIMD registers + + + Desconocido + Unknown, referring to the size of a SIMD register + + + Desconocidos + Unknown, referring to the number of cores + + + Desconocidos + Unknown, referring to the number of threads per core + + + Desconocido + Unknown, referring to the chip process + + + Desconocido + Unknown, referring to the chip process size in nanometers + + + Desconocida + Unknown, referring to the die size in square millimeters + + + Desconocidos + Unknown, referring to the number of transistors + + + Desconocido + Unknown, referring to the size of the data bus + + + Desconocido + Unknown, referring to the size of the address bus + + + Desconocido + Unknown, referring to the size of the L1 instruction cache + + + Desconocido + Unknown, referring to the size of the L1 data cache + + + Desconocido + Unknown, referring to the size of the L2 data cache + + + Desconocido + Unknown, referring to the size of the L3 data cache + + + Por favor introduce un nombre válido. + Please enter a valid name. + + + Por favor introduce un modelo válido. + Please enter a valid model code. + + + Prototipo + Prototype + + + Por favor elige una fecha válida. + Please enter an introduction date. + + + Por favor introduce una velocidad nominal válida. + Please enter a valid nominal speed. + + + Por favor introduce un empaquetado válido. + Please enter a valid package. + + + Por favor introduce un número válido de registros de propósito general. + Please enter a valid number of general purpose registers. + + + Por favor introduce un tamaño de registro de propósito general válido. + Please enter a valid general purpose register size. + + + Por favor introduce un número válido de registros de coma flotante. + Please enter a valid number of floating point registers. + + + Si introduces cero, con un tamaño válido, indica que las instrucciones de coma flotante utilizan los registros de propósito general. + If set to zero, but with a size, indicates floating point instructions use the general purpose registers. + + + Por favor introduce un tamaño de registro de coma flotante válido. + Please enter a valid floating point register size. + + + Por favor introduce un número válido de registros SIMD. + Please enter a valid number of SIMD registers. + + + Si introduces cero, con un tamaño válido, indica que las instrucciones SIMD utilizan los registros de coma flotante. Si su número también es cero, indica que las instrucciones SIMD utilizan los registros de propósito general. + If set to zero, but with a size, indicates SIMD instructions use the floating point registers. If they are also set to zero with a size, it means SIMD instructions use the general purpose registers. + + + Por favor intrudoce un tamaño de registro SIMD válido. + Please enter a valid SIMD register size. + + + Por favor introduce un número válido de núcleos. + Please enter a valid number of cores. + + + Por favor introduce un número válido de hilos por núcleo. + Please enter a valid number of threads per core. + + + Por favor introduce un proceso válido. + Please enter a valid process. + + + Por favor introduce un tamaño de proceso en nanómetros válido. + Please enter a valid process size in nanometers. + + + Por favor introduce un área del chip en milímetros cuadrados válida. + Please enter a valid die size in square millimeters. + + + Por favor introduce un número válido de transistores. + Please enter a valid number of transistors. + + + Por favor introduce un tamaño válido del bus de datos en bits. + Please enter a valid data bus size in bits. + + + Por favor introduce un tamaño válido del bus de direcciones en bits. + Please enter a valid address bus size in bits. + + + Por favor introduce un tamaño válido de la caché L1 de instrucciones en kibibytes. + Please enter a valid L1 instruction cache size in kibibytes. + + + Por favor introduce un tamaño válido de la caché L1 de datos en kibibytes. + Please enter a valid L1 data cache size in kibibytes. + + + Por favor introduce un tamaño válido de la caché L2 en kibibytes. + Please enter a valid L2 cache size in kibibytes. + + + Por favor introduce un tamaño válido de la caché L3 en kibibytes. + Please enter a valid L3 cache size in kibibytes. + \ No newline at end of file diff --git a/Marechai/Services/ProcessorsService.cs b/Marechai/Services/ProcessorsService.cs index 1c8409e2..0157ce78 100644 --- a/Marechai/Services/ProcessorsService.cs +++ b/Marechai/Services/ProcessorsService.cs @@ -42,7 +42,53 @@ namespace Marechai.Services p.Processor.InstructionSetExtensions.Select(e => e.Extension.Extension).ToList() }).ToListAsync(); - public async Task GetAsync(int id) => await _context.Processors.FindAsync(id); + public async Task GetAsync(int id) => + await _context.Processors.Where(p => p.Id == id).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, InstructionSetId = p.InstructionSetId + }).FirstOrDefaultAsync(); + + public async Task UpdateAsync(ProcessorViewModel viewModel) + { + Processor model = await _context.Processors.FindAsync(viewModel.Id); + + if(model is null) + return; + + model.AddrBus = viewModel.AddrBus; + model.CompanyId = viewModel.CompanyId; + model.Cores = viewModel.Cores; + model.DataBus = viewModel.DataBus; + model.DieSize = viewModel.DieSize; + model.Fprs = viewModel.Fprs; + model.FprSize = viewModel.FprSize; + model.Gprs = viewModel.Gprs; + model.GprSize = viewModel.GprSize; + model.InstructionSetId = viewModel.InstructionSetId; + model.Introduced = viewModel.Introduced; + model.L1Data = viewModel.L1Data; + model.L1Instruction = viewModel.L1Instruction; + model.L2 = viewModel.L2; + model.L3 = viewModel.L3; + model.ModelCode = viewModel.ModelCode; + model.Name = viewModel.Name; + model.Package = viewModel.Package; + model.Process = viewModel.Process; + model.ProcessNm = viewModel.ProcessNm; + model.SimdRegisters = viewModel.SimdRegisters; + model.SimdSize = viewModel.SimdSize; + model.Speed = viewModel.Speed; + model.ThreadsPerCore = viewModel.ThreadsPerCore; + model.Transistors = viewModel.Transistors; + + await _context.SaveChangesAsync(); + } public async Task DeleteAsync(int id) { diff --git a/Marechai/Shared/Validators.cs b/Marechai/Shared/Validators.cs index d736d548..5be11bd4 100644 --- a/Marechai/Shared/Validators.cs +++ b/Marechai/Shared/Validators.cs @@ -5,7 +5,7 @@ namespace Marechai.Shared { public static class Validators { - public static void ValidateStringWithMaxLength(ValidatorEventArgs e, string message, int maxLength) + public static void ValidateString(ValidatorEventArgs e, string message, int maxLength) { string item = e.Value as string; @@ -28,7 +28,7 @@ namespace Marechai.Shared e.Status = ValidationStatus.Success; } - public static void ValidateDoubleBiggerThanZero(ValidatorEventArgs e, double minValue = 0, double maxValue = double.MaxValue) + public static void ValidateDouble(ValidatorEventArgs e, double minValue = 0, double maxValue = double.MaxValue) { if(!(e.Value is double item) || item < minValue || item > maxValue) @@ -37,7 +37,7 @@ namespace Marechai.Shared e.Status = ValidationStatus.Success; } - public static void ValidateIntegerBiggerThanZero(ValidatorEventArgs e, int minValue = 0, int maxValue = int.MaxValue) + public static void ValidateInteger(ValidatorEventArgs e, int minValue = 0, int maxValue = int.MaxValue) { if(!(e.Value is int item) || item < minValue || item > maxValue) @@ -46,7 +46,7 @@ namespace Marechai.Shared e.Status = ValidationStatus.Success; } - public static void ValidateLongBiggerThanZero(ValidatorEventArgs e, long minValue = 0, long maxValue = long.MaxValue) + public static void ValidateLong(ValidatorEventArgs e, long minValue = 0, long maxValue = long.MaxValue) { if(!(e.Value is long item) || item < minValue || item > maxValue) @@ -54,5 +54,14 @@ namespace Marechai.Shared else e.Status = ValidationStatus.Success; } + + public static void ValidateFloat(ValidatorEventArgs e, float minValue = 0, float maxValue = float.MaxValue) + { + if(!(e.Value is float item) || + item < minValue || item > maxValue) + e.Status = ValidationStatus.Error; + else + e.Status = ValidationStatus.Success; + } } } \ No newline at end of file diff --git a/Marechai/ViewModels/ProcessorViewModel.cs b/Marechai/ViewModels/ProcessorViewModel.cs index a82e95d8..981988b5 100644 --- a/Marechai/ViewModels/ProcessorViewModel.cs +++ b/Marechai/ViewModels/ProcessorViewModel.cs @@ -32,6 +32,7 @@ namespace Marechai.ViewModels public string InstructionSet { get; set; } public List InstructionSetExtensions { get; set; } public int? CompanyId { get; set; } + public int? InstructionSetId { get; set; } public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown"; }