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

263 lines
10 KiB
Plaintext

@{
/******************************************************************************
// 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/sound_synths/details/{Id:int}"
@page "/admin/sound_synths/edit/{Id:int}"
@page "/admin/sound_synths/create"
@inherits OwningComponentBase<SoundSynthsService>
@inject IStringLocalizer<SoundSynthsService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Sound synthesizer details"]</h3>
<hr />
@if (!_loaded)
{
<p align="center">@L["Loading..."]</p>
return;
}
<div>
@if (_editing || _model.CompanyId != null)
{
<Field>
<FieldLabel>@L["Company"]</FieldLabel>
@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>
}
</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>
@if (_editing || _model.ModelCode != null)
{
<Field>
<FieldLabel>@L["Model code"]</FieldLabel>
@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>
}
</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.Voices.HasValue)
{
<Field>
<FieldLabel>@L["Digitized voices"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownVoices">@L["Unknown (voices)"]</Check>
}
@if (!_editing ||
!_unknownVoices)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int?" Decimals="0" @bind-Value="@_model.Voices" >
<Feedback>
<ValidationError>@L["Please enter a valid number of voices."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Frequency.HasValue)
{
<Field>
<FieldLabel>@L["Sample rate (Hz)"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownSampleRate">@L["Unknown (sample rate)"]</Check>
}
@if (!_editing ||
!_unknownSampleRate)
{
<Validation Validator="@ValidateDoubleBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="double?" Decimals="0" @bind-Value="@_model.Frequency" >
<Feedback>
<ValidationError>@L["Please enter a valid sample rate."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Depth.HasValue)
{
<Field>
<FieldLabel>@L["Sample resolution (bits)"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownSampleResolution">@L["Unknown (sample resolution)"]</Check>
}
@if (!_editing ||
!_unknownSampleResolution)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int?" Decimals="0" @bind-Value="@_model.Depth" >
<Feedback>
<ValidationError>@L["Please enter a valid number of bits for sample resolution."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.SquareWave.HasValue)
{
<Field>
<FieldLabel>@L["Square wave channels"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownSquareWaveChannels">@L["Unknown (square wave channels)"]</Check>
}
@if (!_editing ||
!_unknownSquareWaveChannels)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int?" Decimals="0" @bind-Value="@_model.SquareWave" >
<Feedback>
<ValidationError>@L["Please enter a valid number of square wave channels."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.WhiteNoise.HasValue)
{
<Field>
<FieldLabel>@L["White noise channels"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownWhiteNoiseChannels">@L["Unknown (white noise channels)"]</Check>
}
@if (!_editing ||
!_unknownWhiteNoiseChannels)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int?" Decimals="0" @bind-Value="@_model.WhiteNoise" >
<Feedback>
<ValidationError>@L["Please enter a valid number of white noise channels."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
@if (_editing || _model.Type.HasValue)
{
<Field>
<FieldLabel>@L["Type"]</FieldLabel>
@if (_editing)
{
<Check TValue="bool" @bind-Checked="@_unknownType">@L["Unknown (type)"]</Check>
}
@if (!_editing ||
!_unknownType)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit Disabled="!_editing" TValue="int?" Decimals="0" @bind-Value="@_model.Type" >
<Feedback>
<ValidationError>@L["Please enter a valid sound synthesizer type."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</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/sound_synths" class="btn btn-secondary">@L["Back to list"]</a>
</div>