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

288 lines
11 KiB
Plaintext
Raw Normal View History

2020-05-26 02:41:55 +01:00
@{
/******************************************************************************
// 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/machines/details/{Id:int}"
2020-05-27 14:24:47 +01:00
@page "/admin/machines/edit/{Id:int}"
2020-05-28 02:57:49 +01:00
@page "/admin/machines/create"
2020-05-26 02:41:55 +01:00
@using Marechai.Database
@inherits OwningComponentBase<MachinesService>
@inject IStringLocalizer<MachinesService> L
@inject CompaniesService CompaniesService
@inject MachineFamiliesService MachineFamiliesService
2020-05-27 14:24:47 +01:00
@inject NavigationManager NavigationManager
2020-05-29 02:45:06 +01:00
@inject GpusByMachineService GpusByMachineService
@inject GpusService GpusService
@inject SoundSynthsByMachineService SoundSynthsByMachineService
@inject SoundSynthsService SoundSynthsService
2020-05-26 02:41:55 +01:00
@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>
2020-05-27 14:24:47 +01:00
<Select Disabled="!_editing" TValue="int" @bind-SelectedValue="@_model.CompanyId">
2020-05-26 02:41:55 +01:00
@foreach (var company in _companies)
{
<SelectItem TValue="int" Value="@company.Id">@company.Name</SelectItem>
}
</Select>
</Field>
<Field>
<FieldLabel>@L["Name"]</FieldLabel>
2020-05-27 14:24:47 +01:00
<Validation Validator="@ValidateName">
<TextEdit Disabled="!_editing" @bind-Text="@_model.Name">
<Feedback>
<ValidationError>@L["Please enter a valid name."]</ValidationError>
</Feedback>
</TextEdit>
</Validation>
2020-05-26 02:41:55 +01:00
</Field>
<Field>
<FieldLabel>@L["Type"]</FieldLabel>
2020-05-27 14:24:47 +01:00
<Select Disabled="!_editing" TValue="int" @bind-SelectedValue="@Type">
2020-05-26 02:41:55 +01:00
@foreach (int type in Enum.GetValues(typeof(MachineType)))
{
<SelectItem TValue="int" Value="@type">@(((MachineType)type).ToString())</SelectItem>
}
</Select>
</Field>
2020-05-27 14:24:47 +01:00
@if (_editing || _model.Model != null)
2020-05-26 02:41:55 +01:00
{
<Field>
2020-05-27 14:24:47 +01:00
<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>
}
2020-05-26 02:41:55 +01:00
</Field>
}
2020-05-27 14:24:47 +01:00
@if (_editing || _model.Introduced.HasValue)
2020-05-26 02:41:55 +01:00
{
<Field>
<FieldLabel>@L["Introduced"]</FieldLabel>
2020-05-27 14:24:47 +01:00
@if (_editing)
2020-05-26 02:41:55 +01:00
{
2020-05-27 14:24:47 +01:00
<Check TValue="bool" Disabled="_prototype" @bind-Checked="@_unknownIntroduced">@L["Unknown (introduction date)"]</Check>
<Check TValue="bool" Disabled="_unknownIntroduced" @bind-Checked="@_prototype">@L["Prototype"]</Check>
2020-05-26 02:41:55 +01:00
}
2020-05-27 14:24:47 +01:00
@if (!_editing ||
(!_prototype && !_unknownIntroduced))
2020-05-26 02:41:55 +01:00
{
2020-05-27 14:24:47 +01:00
<Validation Validator="@ValidateIntroduced">
<DateEdit Disabled="!_editing" TValue="DateTime?" @bind-Date="@_model.Introduced">
<Feedback>
<ValidationError>@L["Please enter an introduction date."]</ValidationError>
</Feedback>
</DateEdit>
</Validation>
2020-05-26 02:41:55 +01:00
}
2020-05-27 14:24:47 +01:00
</Field>
2020-05-26 02:41:55 +01:00
}
2020-05-27 14:24:47 +01:00
@if (_editing || _model.FamilyId != null)
2020-05-26 02:41:55 +01:00
{
<Field>
<FieldLabel>@L["Family"]</FieldLabel>
2020-05-27 14:24:47 +01:00
@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>
}
2020-05-26 02:41:55 +01:00
</Field>
}
</div>
<div>
2020-05-27 14:24:47 +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>
}
2020-05-26 02:41:55 +01:00
<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="() => {ShowSoundDeleteModal(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="() => {ShowGpuDeleteModal(item.Id);}" Disabled="@_addingSound">@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>
}