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

339 lines
12 KiB
Plaintext
Raw Normal View History

2020-05-25 22:57:03 +01:00
@{
2020-12-20 21:34:13 +00: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
2020-12-20 21:34:13 +00:00
@inject 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 />
2020-12-20 21:34:13 +00:00
@if(!_loaded)
2020-05-25 22:57:03 +01:00
{
2020-12-20 21:34:13 +00:00
<p align="center">@L["Loading..."]</p>
2020-05-25 22:57:03 +01:00
return;
}
<div>
2020-12-20 21:34:13 +00:00
@if(_editing || _model.CompanyId != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Company"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownCompany" @TValue="bool">@L["Unknown (company)"]</Check>
}
@if(!_editing ||
!_unknownCompany)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Select @bind-SelectedValue="@_model.CompanyId" Disabled="!_editing" @TValue="int?">
@foreach(var company in _companies)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<SelectItem @TValue="int?" Value="@company.Id">@company.Name</SelectItem>
}
2020-05-27 19:01:11 +01:00
</Select>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
2020-05-27 19:01:11 +01:00
<Field>
<FieldLabel>@L["Name"]</FieldLabel>
<Validation Validator="@ValidateName">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Name" Disabled="!_editing">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
</Field>
2020-12-20 21:34:13 +00:00
@if(_editing || _model.ModelCode != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Model code"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownModelCode" @TValue="bool">@L["Unknown (model code)"]</Check>
}
@if(!_editing ||
!_unknownModelCode)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidateModelCode">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.ModelCode" Disabled="!_editing">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid model code."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Introduced.HasValue)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Introduced"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownIntroduced" Disabled="_prototype" @TValue="bool">@L["Unknown (introduction date)"]</Check>
<Check @bind-Checked="@_prototype" Disabled="_unknownIntroduced" @TValue="bool">@L["Prototype"]</Check>
}
@if(!_editing ||
!_prototype && !_unknownIntroduced)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidateIntroduced">
2020-12-20 21:34:13 +00:00
<DateEdit @bind-Date="@_model.Introduced" Disabled="!_editing" @TValue="DateTime?">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter an introduction date."]</ValidationError>
</Feedback>
</DateEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
</Field>
}
@if(_editing || _model.Package != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Package"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownPackage" @TValue="bool">@L["Unknown (package)"]</Check>
}
@if(!_editing ||
!_unknownPackage)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidatePackage">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Package" ReadOnly="!_editing">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid package."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Process != null)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Process"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownProcess" @TValue="bool">@L["Unknown (process)"]</Check>
}
@if(!_editing ||
!_unknownProcess)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidateProcess">
2020-12-20 21:34:13 +00:00
<TextEdit @bind-Text="@_model.Process" ReadOnly="!_editing">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid process."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00: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-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownProcessNm" @TValue="bool">@L["Unknown (process size)"]</Check>
}
@if(!_editing ||
!_unknownProcessNm)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidateFloatBiggerThanOne">
2020-12-20 21:34:13 +00:00
<NumericEdit @bind-Value="@_model.ProcessNm" Decimals="2" Disabled="!_editing" @TValue="float?">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid process size in nanometers."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00: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-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownDieSize" @TValue="bool">@L["Unknown (die size)"]</Check>
}
@if(!_editing ||
!_unknownDieSize)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidateFloatBiggerThanOne">
2020-12-20 21:34:13 +00:00
<NumericEdit @bind-Value="@_model.DieSize" Decimals="2" Disabled="!_editing" @TValue="float?">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid die size in square millimeters."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
@if(_editing || _model.Transistors.HasValue)
2020-05-25 22:57:03 +01:00
{
<Field>
<FieldLabel>@L["Transistors"]</FieldLabel>
2020-12-20 21:34:13 +00:00
@if(_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Check @bind-Checked="@_unknownTransistors" @TValue="bool">@L["Unknown (transistors)"]</Check>
}
@if(!_editing ||
!_unknownTransistors)
2020-05-27 19:01:11 +01:00
{
<Validation Validator="@ValidateLongBiggerThanZero">
2020-12-20 21:34:13 +00:00
<NumericEdit @bind-Value="@_model.Transistors" Decimals="0" Disabled="!_editing" @TValue="long?">
2020-05-27 19:01:11 +01:00
<Feedback>
<ValidationError>@L["Please enter a valid number of transistors."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</Field>
2020-12-20 21:34:13 +00:00
}
2020-05-25 22:57:03 +01:00
</div>
<div>
2020-12-20 21:34:13 +00:00
@if(!_editing)
2020-05-27 19:01:11 +01:00
{
2020-12-20 21:34:13 +00:00
<Button Clicked="@OnEditClicked" Color="Color.Primary">@L["Edit"]</Button>
}
2020-05-27 19:01:11 +01:00
else
{
2020-12-20 21:34:13 +00:00
<Button Clicked="@OnSaveClicked" Color="Color.Success">@L["Save"]</Button>
<Button Clicked="@OnCancelClicked" Color="Color.Danger">@L["Cancel"]</Button>
}
<a class="btn btn-secondary" href="/admin/gpus">@L["Back to list"]</a>
2020-05-30 04:36:31 +01:00
</div>
2020-12-20 21:34:13 +00:00
@if(!_editing)
2020-05-30 04:36:31 +01:00
{
<hr />
<h3>@L["Resolutions supported by this graphical processing unit"]</h3>
2020-12-20 21:34:13 +00:00
<Button Clicked="OnAddResolutionClick" Color="Color.Success" Disabled="_addingResolution">@L["Add new (resolution by gpu)"]</Button>
@if(_addingResolution)
2020-05-30 04:36:31 +01:00
{
<div>
<Field>
<FieldLabel>@L["Resolutions"]</FieldLabel>
2020-12-20 21:34:13 +00:00
<Select @bind-SelectedValue="@_addingResolutionId" Disabled="_savingResolution" @TValue="int?">
@foreach(var resolution in _resolutions)
2020-05-30 04:36:31 +01:00
{
2020-12-20 21:34:13 +00:00
@if(_gpuResolutions.All(r => r.ResolutionId != resolution.Id))
2020-05-30 04:36:31 +01:00
{
2020-12-20 21:34:13 +00:00
<SelectItem @TValue="int?" Value="@resolution.Id">@resolution</SelectItem>
}
2020-05-30 04:36:31 +01:00
}
</Select>
2020-12-20 21:34:13 +00:00
<Button Clicked="@CancelAddResolution" Color="Color.Primary" Disabled="@_savingResolution">@L["Cancel"]</Button>
<Button Clicked="@ConfirmAddResolution" Color="Color.Success" Disabled="@_savingResolution">@L["Add"]</Button>
2020-05-30 04:36:31 +01:00
</Field>
</div>
}
2020-12-20 21:34:13 +00:00
@if(_gpuResolutions?.Count > 0)
2020-05-30 04:36:31 +01:00
{
<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>
2020-12-20 21:34:13 +00:00
@foreach(var item in _gpuResolutions)
2020-05-30 04:36:31 +01:00
{
<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>
2020-12-20 21:34:13 +00:00
<Button Clicked="() => {ShowResolutionDeleteModal(item.Id);}" Color="Color.Danger" Disabled="@_addingResolution">@L["Delete"]</Button>
2020-05-30 04:36:31 +01:00
</td>
</tr>
}
</tbody>
</table>
</div>
}
2020-12-20 21:34:13 +00:00
<Modal Closing="@ModalClosing" IsCentered="true" ref="_frmDelete">
2020-05-30 04:36:31 +01:00
<ModalBackdrop />
<ModalContent Centered="true">
<ModalHeader>
<ModalTitle>@_deleteTitle</ModalTitle>
<CloseButton Clicked="@HideModal" />
</ModalHeader>
<ModalBody>
<Text>@_deleteText</Text>
</ModalBody>
<ModalFooter>
2020-12-20 21:34:13 +00:00
<Button Clicked="@HideModal" Color="Color.Primary" Disabled="@_deleteInProgress">@L["Cancel"]</Button>
<Button Clicked="@ConfirmDelete" Color="Color.Danger" Disabled="@_deleteInProgress">@L["Delete"]</Button>
2020-05-30 04:36:31 +01:00
</ModalFooter>
</ModalContent>
2020-12-20 21:34:13 +00:00
</Modal>}