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

672 lines
27 KiB
Plaintext

@{
/******************************************************************************
// 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/machines/details/{Id:int}"
@page "/admin/machines/edit/{Id:int}"
@page "/admin/machines/create"
@using Marechai.Database
@inherits OwningComponentBase<MachinesService>
@inject IStringLocalizer<MachinesService> L
@inject CompaniesService CompaniesService
@inject MachineFamiliesService MachineFamiliesService
@inject NavigationManager NavigationManager
@inject GpusByMachineService GpusByMachineService
@inject GpusService GpusService
@inject SoundSynthsByMachineService SoundSynthsByMachineService
@inject SoundSynthsService SoundSynthsService
@inject ProcessorsByMachineService ProcessorsByMachineService
@inject ProcessorsService ProcessorsService
@inject MemoriesByMachineService MemoriesByMachineService
@inject StorageByMachineService StorageByMachineService
@inject ScreensByMachineService ScreensByMachineService
@inject ScreensService ScreensService
@inject MachinePhotosService MachinePhotosService
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Machine details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
<Field>
<FieldLabel>@L["Company"]</FieldLabel>
<Select Disabled="!_editing" TValue="int" @bind-SelectedValue="@_model.CompanyId">
@foreach (var company in _companies)
{
<SelectItem TValue="int" Value="@company.Id">@company.Name</SelectItem>
}
</Select>
</Field>
<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>
<Field>
<FieldLabel>@L["Type"]</FieldLabel>
<Select Disabled="!_editing" TValue="int" @bind-SelectedValue="@Type">
@foreach (int type in Enum.GetValues(typeof(MachineType)))
{
<SelectItem TValue="int" Value="@type">@(((MachineType)type).ToString())</SelectItem>
}
</Select>
</Field>
@if (_editing || _model.Model != null)
{
<Field>
<FieldLabel>@L["Model code"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownModel">@L["Unknown (model)"]</Check>
}
@if (!_editing ||
!_unknownModel)
{
<Validation Validator="@ValidateModel">
<TextEdit Disabled="!_editing" @bind-Text="@_model.Model">
<Feedback>
<ValidationError>@L["Please enter a valid model."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Introduced.HasValue)
{
<Field>
<FieldLabel>@L["Introduced"]</FieldLabel>
@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>
}
@if (_editing || _model.FamilyId != null)
{
<Field>
<FieldLabel>@L["Family"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_noFamily">@L["No family"]</Check>
}
@if (!_editing ||
!_noFamily)
{
<Select Disabled="!_editing" TValue="int?" @bind-SelectedValue="@_model.FamilyId">
@foreach (MachineFamilyViewModel family in _families)
{
<SelectItem TValue="int?" Value="@family.Id">@family.Name</SelectItem>
}
</Select>
}
</Field>
}
</div>
<div>
@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/machines" class="btn btn-secondary">@L["Back to list"]</a>
</div>
@if (!_editing)
{
<hr />
<h3>@L["Graphical processing units belonging to this machine"]</h3>
<Button Color="Color.Success" Clicked="OnAddGpuClick" Disabled="_addingGpu">@L["Add new (gpu by machine)"]</Button>
@if (_addingGpu)
{
<div>
<Field>
<FieldLabel>@L["Graphical processing units"]</FieldLabel>
<Select Disabled="_savingGpu" TValue="int?" @bind-SelectedValue="@_addingGpuId">
@foreach (var gpu in _gpus)
{
<SelectItem TValue="int?" Value="@gpu.Id">@gpu.Company - @gpu.Name</SelectItem>
}
</Select>
<Button Color="Color.Primary" Clicked="@CancelAddGpu" Disabled="@_savingGpu">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddGpu" Disabled="@_savingGpu">@L["Add"]</Button>
</Field>
</div>
}
@if (_machineGpus?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Company"]
</th>
<th>
@L["Name"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _machineGpus)
{
<tr>
<td>
@item.CompanyName
</td>
<td>
@item.Name
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowGpuDeleteModal(item.Id);}" Disabled="@_addingGpu">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<hr />
<h3>@L["Sound synthesizers belonging to this machine"]</h3>
<Button Color="Color.Success" Clicked="OnAddSoundClick" Disabled="_addingSound">@L["Add new (sound by machine)"]</Button>
@if (_addingSound)
{
<div>
<Field>
<FieldLabel>@L["Sound synthesizers"]</FieldLabel>
<Select Disabled="_savingSound" TValue="int?" @bind-SelectedValue="@_addingSoundId">
@foreach (var soundSynth in _soundSynths)
{
<SelectItem TValue="int?" Value="@soundSynth.Id">@soundSynth.CompanyName - @soundSynth.Name</SelectItem>
}
</Select>
<Button Color="Color.Primary" Clicked="@CancelAddSound" Disabled="@_savingSound">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddSound" Disabled="@_savingSound">@L["Add"]</Button>
</Field>
</div>
}
@if (_machineSound?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Company"]
</th>
<th>
@L["Name"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _machineSound)
{
<tr>
<td>
@item.CompanyName
</td>
<td>
@item.Name
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowSoundDeleteModal(item.Id);}" Disabled="@_addingSound">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<hr />
<h3>@L["Processors belonging to this machine"]</h3>
<Button Color="Color.Success" Clicked="OnAddCpuClick" Disabled="_addingCpu">@L["Add new (processor by machine)"]</Button>
@if (_addingCpu)
{
<div>
<Field>
<FieldLabel>@L["Processors"]</FieldLabel>
<Select Disabled="_savingCpu" TValue="int?" @bind-SelectedValue="@_addingCpuId">
@foreach (var cpu in _cpus)
{
<SelectItem TValue="int?" Value="@cpu.Id">@cpu.CompanyName - @cpu.Name</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Nominal speed (MHz)"]</FieldLabel>
<Check TValue="bool" @bind-Checked="@_unknownProcessorSpeed">@L["Unknown (processor by machine speed)"]</Check>
@if (!_unknownProcessorSpeed)
{
<Validation Validator="@ValidateProcessorSpeed">
<NumericEdit TValue="float?" Decimals="3" @bind-Value="@_addingProcessorSpeed" >
<Feedback>
<ValidationError>@L["Please enter a valid speed for this processor."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
<Button Color="Color.Primary" Clicked="@CancelAddCpu" Disabled="@_savingCpu">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddCpu" Disabled="@_savingCpu">@L["Add"]</Button>
</div>
}
@if (_machineCpus?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Company"]
</th>
<th>
@L["Name"]
</th>
<th>
@L["Speed"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _machineCpus)
{
<tr>
<td>
@item.CompanyName
</td>
<td>
@item.Name
</td>
<td>
@string.Format(L["{0:F3} MHz"], item.Speed)
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowCpuDeleteModal(item.Id);}" Disabled="@_addingCpu">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<hr />
<h3>@L["Memory belonging to this machine"]</h3>
<Button Color="Color.Success" Clicked="OnAddMemoryClick" Disabled="_addingMemory">@L["Add new (memory by machine)"]</Button>
@if (_addingMemory)
{
<div>
<Field>
<FieldLabel>@L["Memory type"]</FieldLabel>
<Select TValue="int" @bind-SelectedValue="@_addingMemoryType">
@foreach (int type in Enum.GetValues(typeof(MemoryType)))
{
<SelectItem TValue="int" Value="@type">@(((MemoryType)type).ToString())</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Memory usage"]</FieldLabel>
<Select TValue="int" @bind-SelectedValue="@_addingMemoryUsage">
@foreach (int usage in Enum.GetValues(typeof(MemoryUsage)))
{
<SelectItem TValue="int" Value="@usage">@(((MemoryUsage)usage).ToString())</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Nominal speed (Hz)"]</FieldLabel>
<Check TValue="bool" @bind-Checked="@_unknownMemorySpeed">@L["Unknown (memory by machine speed)"]</Check>
@if (!_unknownMemorySpeed)
{
<Validation Validator="@ValidateMemorySpeed">
<NumericEdit TValue="double?" Decimals="3" @bind-Value="@_addingMemorySpeed" >
<Feedback>
<ValidationError>@L["Please enter a valid speed for this memory."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
<Field>
<FieldLabel>@L["Memory size (bytes)"]</FieldLabel>
<Check TValue="bool" @bind-Checked="@_unknownMemorySize">@L["Unknown (memory by machine size)"]</Check>
@if (!_unknownMemorySize)
{
<Validation Validator="@ValidateMemorySize">
<NumericEdit TValue="long?" Decimals="0" @bind-Value="@_addingMemorySize" >
<Feedback>
<ValidationError>@L["Please enter a valid size for this memory."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
<Button Color="Color.Primary" Clicked="@CancelAddMemory" Disabled="@_savingMemory">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddMemory" Disabled="@_savingMemory">@L["Add"]</Button>
</div>
}
@if (_machineMemories?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Type"]
</th>
<th>
@L["Usage"]
</th>
<th>
@L["Size"]
</th>
<th>
@L["Speed"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _machineMemories)
{
<tr>
<td>
@item.Type
</td>
<td>
@item.Usage
</td>
<td>
@if (item.Size.HasValue)
{
@string.Format(L["{0} bytes"], item.Size)
}
else
{
@L["Unknown (memory by machine size)"]
}
</td>
<td>
@if (item.Speed.HasValue)
{
@string.Format(L["{0:F3} Hz"], item.Speed)
}
else
{
@L["Unknown (memory by machine speed)"]
}
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowMemoryDeleteModal(item.Id);}" Disabled="@_addingMemory">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<hr />
<h3>@L["Storage belonging to this machine"]</h3>
<Button Color="Color.Success" Clicked="OnAddStorageClick" Disabled="_addingStorage">@L["Add new (storage by machine)"]</Button>
@if (_addingStorage)
{
<div>
<Field>
<FieldLabel>@L["Storage type"]</FieldLabel>
<Select TValue="int" @bind-SelectedValue="@_addingStorageType">
@foreach (int type in Enum.GetValues(typeof(StorageType)))
{
<SelectItem TValue="int" Value="@type">@(((StorageType)type).ToString())</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Storage interface"]</FieldLabel>
<Select TValue="int" @bind-SelectedValue="@_addingStorageInterface">
@foreach (int usage in Enum.GetValues(typeof(StorageInterface)))
{
<SelectItem TValue="int" Value="@usage">@(((StorageInterface)usage).ToString())</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Nominal capacity (bytes)"]</FieldLabel>
<Check TValue="bool" @bind-Checked="@_unknownStorageSize">@L["Unknown or empty (storage by machine nominal capacity)"]</Check>
@if (!_unknownStorageSize)
{
<Validation Validator="@ValidateStorageSize">
<NumericEdit TValue="long?" Decimals="0" @bind-Value="@_addingStorageSize" >
<Feedback>
<ValidationError>@L["Please enter a valid size for this storage."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
<Button Color="Color.Primary" Clicked="@CancelAddStorage" Disabled="@_savingStorage">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddStorage" Disabled="@_savingStorage">@L["Add"]</Button>
</div>
}
@if (_machineStorage?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Type"]
</th>
<th>
@L["Interface"]
</th>
<th>
@L["Nominal capacity"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _machineStorage)
{
<tr>
<td>
@item.Type
</td>
<td>
@item.Interface
</td>
<td>
@if (item.Capacity.HasValue)
{
@string.Format(L["{0} bytes"], item.Capacity)
}
else
{
@L["Unknown or empty (storage by machine nominal capacity)"]
}
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowStorageDeleteModal(item.Id);}" Disabled="@_addingStorage">@L["Delete"]</Button>
</td>
</tr>
}
</tbody>
</table>
</div>
}
<hr />
<h3>@L["Screens attached to this machine"]</h3>
<Button Color="Color.Success" Clicked="OnAddScreenClick" Disabled="_addingScreen">@L["Add new (screen by machine)"]</Button>
@if (_addingScreen)
{
<div>
<Field>
<FieldLabel>@L["Screens"]</FieldLabel>
<Select Disabled="_savingScreen" TValue="int?" @bind-SelectedValue="@_addingScreenId">
@foreach (var screen in _screens)
{
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>
}
}
</Select>
<Button Color="Color.Primary" Clicked="@CancelAddScreen" Disabled="@_savingScreen">@L["Cancel"]</Button>
<Button Color="Color.Success" Clicked="@ConfirmAddScreen" Disabled="@_savingScreen">@L["Add"]</Button>
</Field>
</div>
}
@if (_machineScreens?.Count > 0)
{
<div>
<table class="table table-striped">
<thead>
<tr>
<th>
@L["Diagonal"]
</th>
<th>
@L["Width"]
</th>
<th>
@L["Height"]
</th>
<th>
@L["Type"]
</th>
<th>
@L["Effective colors"]
</th>
<th>
@L["Native resolution"]
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in _machineScreens)
{
<tr>
<td>
@item.Screen.Diagonal
</td>
<td>
@item.Screen.Width
</td>
<td>
@item.Screen.Height
</td>
<td>
@item.Screen.Type
</td>
<td>
@item.Screen.EffectiveColors
</td>
<td>
@item.Screen.NativeResolution
</td>
<td>
<Button Color="Color.Danger" Clicked="() => {ShowScreenDeleteModal(item.Id);}" Disabled="@_addingScreen">@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>
@if(_photos.Count > 0)
{
foreach (var photo in _photos)
{
<div class="col-md-2">
<figure class="figure">
<picture>
<source type="image/avif" srcset="/assets/photos/machines/thumbs/avif/hd/@(photo).avif, /assets/photos/machines/thumbs/avif/1440p/@(photo).avif 2x, /assets/photos/machines/thumbs/avif/4k/@(photo).avif 3x">
<source type="image/heic" srcset="/assets/photos/machines/thumbs/heif/hd/@(photo).heic, /assets/photos/machines/thumbs/heif/1440p/@(photo).heic 2x, /assets/photos/machines/thumbs/heif/4k/@(photo).heic 3x">
<source type="image/webp" srcset="/assets/photos/machines/thumbs/webp/hd/@(photo).webp, /assets/photos/machines/thumbs/webp/1440p/@(photo).webp 2x, /assets/photos/machines/thumbs/webp/4k/@(photo).webp 3x">
<source type="image/jp2" srcset="/assets/photos/machines/thumbs/jp2k/hd/@(photo).jp2, /assets/photos/machines/thumbs/jp2k/1440p/@(photo).jp2 2x, /assets/photos/machines/thumbs/jp2k/4k/@(photo).jp2 3x">
<img class="figure-img img-fluid rounded" srcset="/assets/photos/machines/thumbs/jpeg/hd/@(photo).jpg, /assets/photos/machines/thumbs/jpeg/1440p/@(photo).jpg 2x, /assets/photos/machines/thumbs/jpeg/4k/@(photo).jpg 3x" src="/assets/photos/machines/thumbs/jpeg/hd/@(photo).jpg" alt="" height="auto" width="auto" style="max-height: 256px; max-width: 256px" />
</picture>
<figcaption class="figure-caption">
<a href="/admin/machines/photo/details/@photo" target="_blank">@L["Details"]</a></figcaption>
</figure>
</div>
}
}
}