Files
marechai/Marechai/Pages/Admin/Details/Gpu.razor

342 lines
13 KiB
Plaintext
Raw Normal View History

2020-05-25 22:57:03 +01:00
@{
2020-06-01 02:12:50 +01:00
/******************************************************************************
2020-05-25 22:57:03 +01:00
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ 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}"
2020-05-27 19:01:11 +01:00
@page "/admin/gpus/edit/{Id:int}"
2020-05-27 22:59:03 +01:00
@page "/admin/gpus/create"
@using Marechai.Database.Models
2020-05-25 22:57:03 +01:00
@inherits OwningComponentBase<GpusService>
@inject IStringLocalizer<GpusService> L
@inject CompaniesService CompaniesService
2020-05-27 19:01:11 +01:00
@inject NavigationManager NavigationManager
2020-05-30 04:36:31 +01:00
@inject ResolutionsService ResolutionsService
@inject ResolutionsByGpuService ResolutionsByGpuService
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
2020-05-25 22:57:03 +01:00
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Graphical processing unit details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
2020-05-27 19:01:11 +01:00
@if (_editing || _model.CompanyId != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Company"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownCompany">@L["Unknown (company)"]</Check>
}
@if (!_editing ||
!_unknownCompany)
{
<Select Disabled="!_editing" TValue="int?" @bind-SelectedValue="@_model.CompanyId">
@foreach (var company in _companies)
{
<SelectItem TValue="int?" Value="@company.Id">@company.Name</SelectItem>
}
</Select>
}
2020-05-25 22:57:03 +01:00
</Field>
}
2020-05-27 19:01:11 +01:00
<Field>
<FieldLabel>@L["Name"]</FieldLabel>
<Validation Validator="@ValidateName">
<TextEdit Disabled="!_editing" @bind-Text="@_model.Name">
<Feedback>
<ValidationError>@L["Please enter a valid name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
</Field>
@if (_editing || _model.ModelCode != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Model code"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownModelCode">@L["Unknown (model code)"]</Check>
}
@if (!_editing ||
!_unknownModelCode)
{
<Validation Validator="@ValidateModelCode">
<TextEdit Disabled="!_editing" @bind-Text="@_model.ModelCode">
<Feedback>
<ValidationError>@L["Please enter a valid model code."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
2020-05-25 22:57:03 +01:00
</Field>
}
2020-05-27 19:01:11 +01:00
@if (_editing || _model.Introduced.HasValue)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Introduced"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" Disabled="_prototype" @bind-Checked="@_unknownIntroduced">@L["Unknown (introduction date)"]</Check>
<Check TValue="bool" Disabled="_unknownIntroduced" @bind-Checked="@_prototype">@L["Prototype"]</Check>
}
@if (!_editing ||
(!_prototype && !_unknownIntroduced))
{
<Validation Validator="@ValidateIntroduced">
<DateEdit Disabled="!_editing" TValue="DateTime?" @bind-Date="@_model.Introduced">
<Feedback>
<ValidationError>@L["Please enter an introduction date."]</ValidationError>
</Feedback>
</DateEdit>
</Validation>
}
</Field>
2020-05-25 22:57:03 +01:00
}
2020-05-27 19:01:11 +01:00
@if (_editing || _model.Package != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Package"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownPackage">@L["Unknown (package)"]</Check>
}
@if (!_editing ||
!_unknownPackage)
{
<Validation Validator="@ValidatePackage">
<TextEdit ReadOnly="!_editing" @bind-Text="@_model.Package">
<Feedback>
<ValidationError>@L["Please enter a valid package."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
2020-05-25 22:57:03 +01:00
</Field>
}
2020-05-27 19:01:11 +01:00
@if (_editing || _model.Process != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Process"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownProcess">@L["Unknown (process)"]</Check>
}
@if (!_editing ||
!_unknownProcess)
{
<Validation Validator="@ValidateProcess">
<TextEdit ReadOnly="!_editing" @bind-Text="@_model.Process">
<Feedback>
<ValidationError>@L["Please enter a valid process."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
2020-05-25 22:57:03 +01:00
</Field>
}
2020-05-27 19:01:11 +01:00
@if (_editing || _model.ProcessNm.HasValue)
2020-05-25 22:57:03 +01:00
{
<Field>
2020-05-26 04:03:53 +01:00
<FieldLabel>@L["Process (nm)"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownProcessNm">@L["Unknown (process size)"]</Check>
}
@if (!_editing ||
!_unknownProcessNm)
{
<Validation Validator="@ValidateFloatBiggerThanOne">
<NumericEdit Disabled="!_editing" TValue="float?" Decimals="2" @bind-Value="@_model.ProcessNm">
<Feedback>
<ValidationError>@L["Please enter a valid process size in nanometers."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
2020-05-25 22:57:03 +01:00
</Field>
}
2020-05-27 19:01:11 +01:00
@if (_editing || _model.DieSize.HasValue)
2020-05-25 22:57:03 +01:00
{
<Field>
2020-05-26 04:03:53 +01:00
<FieldLabel>@L["Die size (mm²)"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownDieSize">@L["Unknown (die size)"]</Check>
}
@if (!_editing ||
!_unknownDieSize)
{
<Validation Validator="@ValidateFloatBiggerThanOne">
<NumericEdit Disabled="!_editing" TValue="float?" Decimals="2" @bind-Value="@_model.DieSize">
<Feedback>
<ValidationError>@L["Please enter a valid die size in square millimeters."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
2020-05-25 22:57:03 +01:00
</Field>
}
2020-05-27 19:01:11 +01:00
@if (_editing || _model.Transistors.HasValue)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Transistors"]</FieldLabel>
2020-05-27 19:01:11 +01:00
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownTransistors">@L["Unknown (transistors)"]</Check>
}
@if (!_editing ||
!_unknownTransistors)
{
<Validation Validator="@ValidateLongBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="long?" Decimals="0" @bind-Value="@_model.Transistors">
<Feedback>
<ValidationError>@L["Please enter a valid number of transistors."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
2020-05-25 22:57:03 +01:00
</Field>
}
</div>
<div>
2020-05-27 19:01:11 +01:00
@if (!_editing)
{
<Button Color="Color.Primary" Clicked="@OnEditClicked">@L["Edit"]</Button>
}
else
{
<Button Color="Color.Success" Clicked="@OnSaveClicked">@L["Save"]</Button>
<Button Color="Color.Danger" Clicked="@OnCancelClicked">@L["Cancel"]</Button>
}
<a href="/admin/gpus" class="btn btn-secondary">@L["Back to list"]</a>
2020-05-30 04:36:31 +01:00
</div>
@if (!_editing)
{
<hr />
<h3>@L["Resolutions supported by this graphical processing unit"]</h3>
<Button Color="Color.Success" Clicked="OnAddResolutionClick" Disabled="_addingResolution">@L["Add new (resolution by gpu)"]</Button>
@if (_addingResolution)
{
<div>
<Field>
<FieldLabel>@L["Resolutions"]</FieldLabel>
<Select Disabled="_savingResolution" TValue="int?" @bind-SelectedValue="@_addingResolutionId">
@foreach (var resolution in _resolutions)
{
@if (_gpuResolutions.All(r => r.ResolutionId != resolution.Id))
{
<SelectItem TValue="int?" Value="@resolution.Id">@resolution</SelectItem>
}
}
</Select>
<Button Color="Color.Primary" Clicked="@CancelAddResolution" Disabled="@_savingResolution">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddResolution" Disabled="@_savingResolution">@L["Add"]</Button>
</Field>
</div>
}
@if (_gpuResolutions?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Width"]
</th>
<th>
@L["Height"]
</th>
<th>
@L["Colors"]
</th>
<th>
@L["Palette"]
</th>
<th>
@L["Chars"]
</th>
<th>
@L["Grayscale"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _gpuResolutions)
{
<tr>
<td>
@item.Resolution.Width
</td>
<td>
@item.Resolution.Height
</td>
<td>
@item.Resolution.Colors
</td>
<td>
@item.Resolution.Palette
</td>
<td>
@item.Resolution.Chars
</td>
<td>
@item.Resolution.Grayscale
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowResolutionDeleteModal(item.Id);}" Disabled="@_addingResolution">@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>
}