Add GPU details in admin view.

This commit is contained in:
2020-05-25 22:57:03 +01:00
parent f3f2d30373
commit f77f03d39d
8 changed files with 190 additions and 110 deletions

View File

@@ -1,105 +0,0 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Details.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view details
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
}
@model Marechai.Database.Models.Gpu
@{
ViewData["Title"] = "Details";
}
<h2>Details</h2>
<div>
<h4>GPU</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Company)
</dt>
<dd>
@Html.DisplayFor(model => model.Company.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Name)
</dt>
<dd>
@Html.DisplayFor(model => model.Name)
</dd>
<dt>
@Html.DisplayNameFor(model => model.ModelCode)
</dt>
<dd>
@Html.DisplayFor(model => model.ModelCode)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Introduced)
</dt>
<dd>
@Html.DisplayFor(model => model.IntroducedView)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Package)
</dt>
<dd>
@Html.DisplayFor(model => model.Package)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Process)
</dt>
<dd>
@Html.DisplayFor(model => model.Process)
</dd>
<dt>
@Html.DisplayNameFor(model => model.ProcessNm)
</dt>
<dd>
@Html.DisplayFor(model => model.ProcessNm)
</dd>
<dt>
@Html.DisplayNameFor(model => model.DieSize)
</dt>
<dd>
@Html.DisplayFor(model => model.DieSize)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Transistors)
</dt>
<dd>
@Html.DisplayFor(model => model.Transistors)
</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>

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.0.99.1171</Version> <Version>3.0.99.1179</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>
@@ -91,6 +91,9 @@
<Content Update="Pages\Admin\Details\DocumentPerson.razor"> <Content Update="Pages\Admin\Details\DocumentPerson.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content> </Content>
<Content Update="Pages\Admin\Details\Gpu.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" /> <_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />

View File

@@ -0,0 +1,121 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Details.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Admin view details
//
// --[ 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 <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
}
@page "/admin/gpus/details/{Id:int}"
@inherits OwningComponentBase<GpusService>
@inject IStringLocalizer<GpusService> L
@inject CompaniesService CompaniesService
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Graphical processing unit details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
@if (_editable || _model.CompanyId != null)
{
<Field>
<FieldLabel>@L["Company"]</FieldLabel>
<Select Disabled="!_editable" TValue="int?" @bind-SelectedValue="@_model.CompanyId">
@foreach (var company in _companies)
{
<SelectItem TValue="int?" Value="@company.Id">@company.Name</SelectItem>
}
</Select>
</Field>
}
@if (_editable || _model.Name != null)
{
<Field>
<FieldLabel>@L["Name"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Name" />
</Field>
}
@if (_editable || _model.ModelCode != null)
{
<Field>
<FieldLabel>@L["Model code"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.ModelCode" />
</Field>
}
@if (_editable || _model.Introduced != null)
{
<Field>
<FieldLabel>@L["Introduced"]</FieldLabel>
<DateEdit TValue="DateTime?" ReadOnly="!_editable" @bind-Date="@_model.Introduced" />
</Field>
}
@if (_editable || _model.Package != null)
{
<Field>
<FieldLabel>@L["Package"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Package" />
</Field>
}
@if (_editable || _model.Process != null)
{
<Field>
<FieldLabel>@L["Process"]</FieldLabel>
<TextEdit ReadOnly="!_editable" @bind-Text="@_model.Process" />
</Field>
}
@if (_editable || _model.ProcessNm != null)
{
<Field>
<FieldLabel>@L["Process size in nm"]</FieldLabel>
<NumericEdit TValue="float?" Decimals="2" ReadOnly="!_editable" @bind-Text="@_model.ProcessNm" />
</Field>
}
@if (_editable || _model.DieSize != null)
{
<Field>
<FieldLabel>@L["Die size"]</FieldLabel>
<NumericEdit TValue="float?" Decimals="2" ReadOnly="!_editable" @bind-Text="@_model.DieSize" />
</Field>
}
@if (_editable || _model.Transistors != null)
{
<Field>
<FieldLabel>@L["Transistors"]</FieldLabel>
<NumericEdit TValue="long?" Decimals="0" ReadOnly="!_editable" @bind-Text="@_model.Transistors" />
</Field>
}
</div>
<div>
<span class="btn btn-primary">@L["Edit"]</span>
<a href="/admin/companies" class="btn btn-secondary">@L["Back to list"]</a>
</div>

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Marechai.ViewModels;
using Microsoft.AspNetCore.Components;
namespace Marechai.Pages.Admin.Details
{
public partial class Gpu
{
List<CompanyViewModel> _companies;
bool _editable;
bool _loaded;
Database.Models.Gpu _model;
[Parameter]
public int Id { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(_loaded)
return;
_loaded = true;
if(Id <= 0)
return;
_companies = await CompaniesService.GetAsync();
_model = await Service.GetAsync(Id);
StateHasChanged();
}
}
}

View File

@@ -81,9 +81,7 @@
@item.IntroducedView @item.IntroducedView
</td> </td>
<td> <td>
<span class="btn btn-primary"> <a class="btn btn-primary" href="/admin/gpus/details/@item.Id">@L["Details"]</a>
@L["Details"]
</span>
<span class="btn btn-secondary"> <span class="btn btn-secondary">
@L["Edit"] @L["Edit"]
</span> </span>

View File

@@ -170,4 +170,32 @@
<value>Cancelar</value> <value>Cancelar</value>
<comment>Cancel</comment> <comment>Cancel</comment>
</data> </data>
<data name="Graphical processing unit details" xml:space="preserve">
<value>Detalles de unidad de proceso gráfico</value>
<comment>Graphical processing unit details</comment>
</data>
<data name="Back to list" xml:space="preserve">
<value>Volver a la lista</value>
<comment>Back to list</comment>
</data>
<data name="Package" xml:space="preserve">
<value>Empaquetado</value>
<comment>Package</comment>
</data>
<data name="Process" xml:space="preserve">
<value>Proceso</value>
<comment>Process</comment>
</data>
<data name="Process size in nm" xml:space="preserve">
<value>Tamaño en nm del proceso</value>
<comment>Process size in nm</comment>
</data>
<data name="Die size" xml:space="preserve">
<value>Área del chip</value>
<comment>Die size</comment>
</data>
<data name="Transistors" xml:space="preserve">
<value>Transistores</value>
<comment>Transistors</comment>
</data>
</root> </root>

View File

@@ -31,6 +31,8 @@ namespace Marechai.Services
Transistors = g.Transistors Transistors = g.Transistors
}).ToListAsync(); }).ToListAsync();
public async Task<Gpu> GetAsync(int id) => await _context.Gpus.FindAsync(id);
public async Task DeleteAsync(int id) public async Task DeleteAsync(int id)
{ {
Gpu item = await _context.Gpus.FindAsync(id); Gpu item = await _context.Gpus.FindAsync(id);

View File

@@ -1 +1 @@
{"projectId":"9fc561fc-2850-4b18-8a34-33bab85e34e1","projectName":"Marechai"} {"projectId":"db06ff35-f00a-4492-a887-0e2c62d6c2ba","projectName":"Marechai"}