mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Allow to add and remove instruction set extensions from processor details in admin view.
This commit is contained in:
@@ -1,182 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Areas.Admin.Models;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
|
||||
namespace Marechai.Areas.Admin.Controllers
|
||||
{
|
||||
[Area("Admin"), Authorize]
|
||||
public class InstructionSetExtensionsByProcessorController : Controller
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public InstructionSetExtensionsByProcessorController(MarechaiContext context) => _context = context;
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
IIncludableQueryable<InstructionSetExtensionsByProcessor, Processor> marechaiContext =
|
||||
_context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor);
|
||||
|
||||
return View(await marechaiContext.OrderBy(e => e.Processor.Name).ThenBy(e => e.Extension.Extension).
|
||||
Select(e => new InstructionSetExtensionsByProcessorViewModel
|
||||
{
|
||||
Id = e.Id, Extension = e.Extension.Extension,
|
||||
Processor = e.Processor.Name
|
||||
}).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Details/5
|
||||
public async Task<IActionResult> Details(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
return NotFound();
|
||||
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor).
|
||||
FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(instructionSetExtensionsByProcessor == null)
|
||||
return NotFound();
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension");
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: InstructionSetExtensionsByProcessor/Create
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost, ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(
|
||||
[Bind("Id,ProcessorId,ExtensionId")]
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor)
|
||||
{
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
_context.Add(instructionSetExtensionsByProcessor);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
|
||||
instructionSetExtensionsByProcessor.ExtensionId);
|
||||
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
|
||||
instructionSetExtensionsByProcessor.ProcessorId);
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Edit/5
|
||||
public async Task<IActionResult> Edit(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
return NotFound();
|
||||
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(e => e.Id == id);
|
||||
|
||||
if(instructionSetExtensionsByProcessor == null)
|
||||
return NotFound();
|
||||
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
|
||||
instructionSetExtensionsByProcessor.ExtensionId);
|
||||
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
|
||||
instructionSetExtensionsByProcessor.ProcessorId);
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// POST: InstructionSetExtensionsByProcessor/Edit/5
|
||||
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
||||
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||
[HttpPost, ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(
|
||||
int id,
|
||||
[Bind("Id,ProcessorId,ExtensionId")]
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor)
|
||||
{
|
||||
if(id != instructionSetExtensionsByProcessor.Id)
|
||||
return NotFound();
|
||||
|
||||
if(ModelState.IsValid)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Update(instructionSetExtensionsByProcessor);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch(DbUpdateConcurrencyException)
|
||||
{
|
||||
if(!InstructionSetExtensionsByProcessorExists(instructionSetExtensionsByProcessor.Id))
|
||||
return NotFound();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
ViewData["ExtensionId"] = new SelectList(_context.InstructionSetExtensions, "Id", "Extension",
|
||||
instructionSetExtensionsByProcessor.ExtensionId);
|
||||
|
||||
ViewData["ProcessorId"] = new SelectList(_context.Processors, "Id", "Name",
|
||||
instructionSetExtensionsByProcessor.ProcessorId);
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// GET: InstructionSetExtensionsByProcessor/Delete/5
|
||||
public async Task<IActionResult> Delete(int? id)
|
||||
{
|
||||
if(id == null)
|
||||
return NotFound();
|
||||
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.Include(i => i.Extension).Include(i => i.Processor).
|
||||
FirstOrDefaultAsync(m => m.Id == id);
|
||||
|
||||
if(instructionSetExtensionsByProcessor == null)
|
||||
return NotFound();
|
||||
|
||||
return View(instructionSetExtensionsByProcessor);
|
||||
}
|
||||
|
||||
// POST: InstructionSetExtensionsByProcessor/Delete/5
|
||||
[HttpPost, ActionName("Delete"), ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(int id)
|
||||
{
|
||||
InstructionSetExtensionsByProcessor instructionSetExtensionsByProcessor =
|
||||
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(e => e.Id == id);
|
||||
|
||||
_context.InstructionSetExtensionsByProcessor.Remove(instructionSetExtensionsByProcessor);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
bool InstructionSetExtensionsByProcessorExists(int id) =>
|
||||
_context.InstructionSetExtensionsByProcessor.Any(e => e.Id == id);
|
||||
|
||||
[AcceptVerbs("Get", "Post")]
|
||||
public async Task<IActionResult> VerifyUnique(int processorId, int extensionId) =>
|
||||
await _context.InstructionSetExtensionsByProcessor.FirstOrDefaultAsync(i => i.ProcessorId == processorId &&
|
||||
i.ExtensionId == extensionId) is
|
||||
null ? Json(true) : Json("The selected processor already has the selected extension.");
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
@model Marechai.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
<h1>Create</h1>
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Create">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Processor" class="control-label">
|
||||
</label>
|
||||
<select asp-for="ProcessorId" class="form-control" asp-items="ViewBag.ProcessorId">
|
||||
</select>
|
||||
<span asp-validation-for="ProcessorId" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Extension" class="control-label">
|
||||
</label>
|
||||
<select asp-for="ExtensionId" class="form-control" asp-items="ViewBag.ExtensionId">
|
||||
</select>
|
||||
<span asp-validation-for="ExtensionId" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="Create" />
|
||||
<a asp-action="Index" class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
@model Marechai.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
<h1>Delete</h1>
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Extension)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Extension.Extension)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Processor)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Processor.Name)
|
||||
</dd>
|
||||
</dl>
|
||||
<form asp-action="Delete">
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<input type="hidden" asp-for="ProcessorId" />
|
||||
<input type="hidden" asp-for="ExtensionId" />
|
||||
<input class="btn btn-danger" type="submit" value="Delete" />
|
||||
<a asp-action="Index" class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,32 +0,0 @@
|
||||
@model Marechai.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Details";
|
||||
}
|
||||
<h1>Details</h1>
|
||||
<div>
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<dl class="row">
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Extension)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Extension.Extension)
|
||||
</dd>
|
||||
<dt class="col-sm-2">
|
||||
@Html.DisplayNameFor(model => model.Processor)
|
||||
</dt>
|
||||
<dd class="col-sm-10">
|
||||
@Html.DisplayFor(model => model.Processor.Name)
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">
|
||||
Edit
|
||||
</a>
|
||||
<a asp-action="Index" class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
@@ -1,43 +0,0 @@
|
||||
@model Marechai.Database.Models.InstructionSetExtensionsByProcessor
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
<h1>Edit</h1>
|
||||
<h4>Instruction set extensions by processor</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger">
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Processor" class="control-label">
|
||||
</label>
|
||||
<select asp-for="ProcessorId" class="form-control" asp-items="ViewBag.ProcessorId">
|
||||
</select>
|
||||
<span asp-validation-for="ProcessorId" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Extension" class="control-label">
|
||||
</label>
|
||||
<select asp-for="ExtensionId" class="form-control" asp-items="ViewBag.ExtensionId">
|
||||
</select>
|
||||
<span asp-validation-for="ExtensionId" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="Save" />
|
||||
<a asp-action="Index" class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
@model IEnumerable<Marechai.Areas.Admin.Models.InstructionSetExtensionsByProcessorViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Index";
|
||||
}
|
||||
<h1>Instruction set extensions by processor</h1>
|
||||
<p>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
Create new
|
||||
</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Processor)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Extension)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Processor)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Extension)
|
||||
</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>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>3.0.99.1396</Version>
|
||||
<Version>3.0.99.1399</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
@@ -174,5 +174,10 @@
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ScreensByMachine\Details.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ScreensByMachine\Edit.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\ScreensByMachine\Index.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Create.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Delete.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Details.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Edit.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\InstructionSetExtensionsByProcessor\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -567,9 +567,9 @@
|
||||
<Select Disabled="_savingScreen" TValue="int?" @bind-SelectedValue="@_addingScreenId">
|
||||
@foreach (var screen in _screens)
|
||||
{
|
||||
if (_machineScreens.Any(s => s.ScreenId == screen.Id))
|
||||
if (_machineScreens.All(s => s.ScreenId != screen.Id))
|
||||
{
|
||||
<SelectItem TValue="int?" Value="@screen.Id">@string.Format(L["{0}\" with a native resolution of {1}",screen.Diagonal, screen.NativeResolution)</SelectItem>
|
||||
<SelectItem TValue="int?" Value="@screen.Id">@string.Format(L["{0}\" with a native resolution of {1}"],screen.Diagonal, screen.NativeResolution)</SelectItem>
|
||||
}
|
||||
}
|
||||
</Select>
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
@inject CompaniesService CompaniesService
|
||||
@inject InstructionSetsService InstructionSetsService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject InstructionSetExtensionsByProcessorService InstructionSetExtensionsByProcessorService
|
||||
@inject InstructionSetExtensionsService InstructionSetExtensionsService
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
<h3>@L["Processor details"]</h3>
|
||||
<hr />
|
||||
@@ -584,3 +586,73 @@
|
||||
}
|
||||
<a href="/admin/processors" class="btn btn-secondary">@L["Back to list"]</a>
|
||||
</div>
|
||||
@if (!_editing)
|
||||
{
|
||||
<hr />
|
||||
<h3>@L["Instruction set extensions implemented by this processor"]</h3>
|
||||
<Button Color="Color.Success" Clicked="OnAddExtensionClick" Disabled="_addingExtension">@L["Add new (instruction set extension)"]</Button>
|
||||
@if (_addingExtension)
|
||||
{
|
||||
<div>
|
||||
<Field>
|
||||
<FieldLabel>@L["Instruction set extensions"]</FieldLabel>
|
||||
<Select Disabled="_savingExtension" TValue="int?" @bind-SelectedValue="@_addingExtensionId">
|
||||
@foreach (var extension in _instructionSetExtensions)
|
||||
{
|
||||
if (_processorExtensions.All(s => s.ExtensionId != extension.Id))
|
||||
{
|
||||
<SelectItem TValue="int?" Value="@extension.Id">@extension.Extension</SelectItem>
|
||||
}
|
||||
}
|
||||
</Select>
|
||||
<Button Color="Color.Primary" Clicked="@CancelAddExtension" Disabled="@_savingExtension">@L["Cancel"]</Button>
|
||||
<Button Color="Color.Success" Clicked="@ConfirmAddExtension" Disabled="@_savingExtension">@L["Add"]</Button>
|
||||
</Field>
|
||||
</div>
|
||||
}
|
||||
@if (_processorExtensions?.Count > 0)
|
||||
{
|
||||
<div>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@L["Name"]
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in _processorExtensions)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.Extension
|
||||
</td>
|
||||
<td>
|
||||
<Button Color="Color.Danger" Clicked="() => {ShowExtensionDeleteModal(item.Id);}" Disabled="@_addingExtension">@L["Delete"]</Button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
<Modal @ref="_frmDelete" IsCentered="true" Closing="@ModalClosing">
|
||||
<ModalBackdrop />
|
||||
<ModalContent Centered="true">
|
||||
<ModalHeader>
|
||||
<ModalTitle>@_deleteTitle</ModalTitle>
|
||||
<CloseButton Clicked="@HideModal" />
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<Text>@_deleteText</Text>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button Color="Color.Primary" Clicked="@HideModal" Disabled="@_deleteInProgress">@L["Cancel"]</Button>
|
||||
<Button Color="Color.Danger" Clicked="@ConfirmDelete" Disabled="@_deleteInProgress">@L["Delete"]</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Blazorise;
|
||||
using Marechai.Shared;
|
||||
@@ -10,37 +11,49 @@ namespace Marechai.Pages.Admin.Details
|
||||
{
|
||||
public partial class Processor
|
||||
{
|
||||
List<CompanyViewModel> _companies;
|
||||
bool _creating;
|
||||
bool _editing;
|
||||
List<Database.Models.InstructionSet> _instructionSets;
|
||||
bool _loaded;
|
||||
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;
|
||||
bool _addingExtension;
|
||||
int? _addingExtensionId;
|
||||
List<CompanyViewModel> _companies;
|
||||
bool _creating;
|
||||
|
||||
InstructionSetExtensionByProcessorViewModel _currentInstructionByMachine;
|
||||
bool _deleteInProgress;
|
||||
string _deleteText;
|
||||
string _deleteTitle;
|
||||
bool _editing;
|
||||
Modal _frmDelete;
|
||||
List<Database.Models.InstructionSetExtension> _instructionSetExtensions;
|
||||
List<Database.Models.InstructionSet> _instructionSets;
|
||||
bool _loaded;
|
||||
ProcessorViewModel _model;
|
||||
|
||||
List<InstructionSetExtensionByProcessorViewModel> _processorExtensions;
|
||||
bool _prototype;
|
||||
bool _savingExtension;
|
||||
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; }
|
||||
|
||||
@@ -58,9 +71,11 @@ namespace Marechai.Pages.Admin.Details
|
||||
!_creating)
|
||||
return;
|
||||
|
||||
_companies = await CompaniesService.GetAsync();
|
||||
_instructionSets = await InstructionSetsService.GetAsync();
|
||||
_model = _creating ? new ProcessorViewModel() : await Service.GetAsync(Id);
|
||||
_companies = await CompaniesService.GetAsync();
|
||||
_instructionSets = await InstructionSetsService.GetAsync();
|
||||
_model = _creating ? new ProcessorViewModel() : await Service.GetAsync(Id);
|
||||
_instructionSetExtensions = await InstructionSetExtensionsService.GetAsync();
|
||||
_processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id);
|
||||
|
||||
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
|
||||
StartsWith("admin/processors/edit/",
|
||||
@@ -285,5 +300,91 @@ namespace Marechai.Pages.Admin.Details
|
||||
|
||||
void ValidateProcess(ValidatorEventArgs e) =>
|
||||
Validators.ValidateString(e, L["Process must be 45 characters or less."], 45);
|
||||
|
||||
void ShowExtensionDeleteModal(long itemId)
|
||||
{
|
||||
_currentInstructionByMachine = _processorExtensions.FirstOrDefault(n => n.Id == itemId);
|
||||
_deleteTitle = L["Delete instruction set extension from this processor"];
|
||||
|
||||
_deleteText =
|
||||
string.Format(L["Are you sure you want to delete the instruction set extension {0} from this processor?"],
|
||||
_currentInstructionByMachine?.Extension);
|
||||
|
||||
_frmDelete.Show();
|
||||
}
|
||||
|
||||
void HideModal() => _frmDelete.Hide();
|
||||
|
||||
async void ConfirmDelete()
|
||||
{
|
||||
if(_currentInstructionByMachine is null)
|
||||
return;
|
||||
|
||||
_deleteInProgress = true;
|
||||
|
||||
// Yield thread to let UI to update
|
||||
await Task.Yield();
|
||||
|
||||
await InstructionSetExtensionsByProcessorService.DeleteAsync(_currentInstructionByMachine.Id);
|
||||
_processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id);
|
||||
|
||||
_deleteInProgress = false;
|
||||
_frmDelete.Hide();
|
||||
|
||||
// Yield thread to let UI to update
|
||||
await Task.Yield();
|
||||
|
||||
// Tell we finished loading
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void ModalClosing(ModalClosingEventArgs obj)
|
||||
{
|
||||
_deleteInProgress = false;
|
||||
_currentInstructionByMachine = null;
|
||||
}
|
||||
|
||||
void OnAddExtensionClick()
|
||||
{
|
||||
_addingExtension = true;
|
||||
_savingExtension = false;
|
||||
_addingExtensionId = _instructionSetExtensions.First().Id;
|
||||
}
|
||||
|
||||
void CancelAddExtension()
|
||||
{
|
||||
_addingExtension = false;
|
||||
_savingExtension = false;
|
||||
_addingExtensionId = null;
|
||||
}
|
||||
|
||||
async Task ConfirmAddExtension()
|
||||
{
|
||||
if(_addingExtensionId is null ||
|
||||
_addingExtensionId <= 0)
|
||||
{
|
||||
CancelAddExtension();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_savingExtension = true;
|
||||
|
||||
// Yield thread to let UI to update
|
||||
await Task.Yield();
|
||||
|
||||
await InstructionSetExtensionsByProcessorService.CreateAsync(Id, _addingExtensionId.Value);
|
||||
_processorExtensions = await InstructionSetExtensionsByProcessorService.GetByProcessor(Id);
|
||||
|
||||
_addingExtension = false;
|
||||
_savingExtension = false;
|
||||
_addingExtensionId = null;
|
||||
|
||||
// Yield thread to let UI to update
|
||||
await Task.Yield();
|
||||
|
||||
// Tell we finished loading
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,4 +214,8 @@
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to the size of the L3 data cache</comment>
|
||||
</data>
|
||||
<data name="Add new (instruction set extension)" xml:space="preserve">
|
||||
<value>Add new</value>
|
||||
<comment>Add new, referring to an instruction set extension for a processor</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -374,10 +374,6 @@
|
||||
<value>Por favor introduce un modelo válido.</value>
|
||||
<comment>Please enter a valid model code.</comment>
|
||||
</data>
|
||||
<data name="Prototype" xml:space="preserve">
|
||||
<value>Prototipo</value>
|
||||
<comment>Prototype</comment>
|
||||
</data>
|
||||
<data name="Please enter an introduction date." xml:space="preserve">
|
||||
<value>Por favor elige una fecha válida.</value>
|
||||
<comment>Please enter an introduction date.</comment>
|
||||
@@ -470,4 +466,24 @@
|
||||
<value>Por favor introduce un tamaño válido de la caché L3 en kibibytes.</value>
|
||||
<comment>Please enter a valid L3 cache size in kibibytes.</comment>
|
||||
</data>
|
||||
<data name="Add new (instruction set extension)" xml:space="preserve">
|
||||
<value>Añadir nueva</value>
|
||||
<comment>Add new, referring to an instruction set extension for a processor</comment>
|
||||
</data>
|
||||
<data name="Delete instruction set extension from this processor" xml:space="preserve">
|
||||
<value>Eliminar extensión de arquitectura de este procesador</value>
|
||||
<comment>Delete instruction set extension from this processor</comment>
|
||||
</data>
|
||||
<data name="Are you sure you want to delete the instruction set extension {0} from this processor?" xml:space="preserve">
|
||||
<value>¿Estás seguro de eliminar la extensión de arquitecture {0} de este procesador?</value>
|
||||
<comment>Are you sure you want to delete the instruction set extension {0} from this processor?</comment>
|
||||
</data>
|
||||
<data name="Instruction set extensions implemented by this processor" xml:space="preserve">
|
||||
<value>Extensiones de arquitectura implementadas por este procesador</value>
|
||||
<comment>Instruction set extensions implemented by this processor</comment>
|
||||
</data>
|
||||
<data name="Add" xml:space="preserve">
|
||||
<value>Añadir</value>
|
||||
<comment>Add</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,49 @@
|
||||
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 InstructionSetExtensionsByProcessorService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public InstructionSetExtensionsByProcessorService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<InstructionSetExtensionByProcessorViewModel>> GetByProcessor(int processorId) =>
|
||||
await _context.InstructionSetExtensionsByProcessor.Where(e => e.ProcessorId == processorId).
|
||||
Select(e => new InstructionSetExtensionByProcessorViewModel
|
||||
{
|
||||
Id = e.Id, Extension = e.Extension.Extension, Processor = e.Processor.Name,
|
||||
ProcessorId = e.ProcessorId, ExtensionId = e.ExtensionId
|
||||
}).OrderBy(e => e.Extension).ToListAsync();
|
||||
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
InstructionSetExtensionsByProcessor item = await _context.InstructionSetExtensionsByProcessor.FindAsync(id);
|
||||
|
||||
if(item is null)
|
||||
return;
|
||||
|
||||
_context.InstructionSetExtensionsByProcessor.Remove(item);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<int> CreateAsync(int processorId, int extensionId)
|
||||
{
|
||||
var item = new InstructionSetExtensionsByProcessor
|
||||
{
|
||||
ProcessorId = processorId, ExtensionId = extensionId
|
||||
};
|
||||
|
||||
await _context.InstructionSetExtensionsByProcessor.AddAsync(item);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return item.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Marechai.ViewModels
|
||||
{
|
||||
public class InstructionSetExtensionByProcessorViewModel : BaseViewModel<int>
|
||||
{
|
||||
public string Extension { get; set; }
|
||||
public string Processor { get; set; }
|
||||
public int ProcessorId { get; set; }
|
||||
public int ExtensionId { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user