Files
marechai/Marechai/Pages/Admin/Details/SoundSynth.razor
2020-12-20 21:34:13 +00:00

259 lines
9.8 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/sound_synths/details/{Id:int}"
@page "/admin/sound_synths/edit/{Id:int}"
@page "/admin/sound_synths/create"
@using Marechai.Database.Models
@inherits OwningComponentBase<SoundSynthsService>
@inject IStringLocalizer<SoundSynthsService> L
@inject CompaniesService CompaniesService
@inject NavigationManager NavigationManager
@inject UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@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 @bind-Checked="@_unknownCompany" @TValue="bool">@L["Unknown (company)"]</Check>
}
@if(!_editing ||
!_unknownCompany)
{
<Select @bind-SelectedValue="@_model.CompanyId" Disabled="!_editing" @TValue="int?">
@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 @bind-Text="@_model.Name" Disabled="!_editing">
<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 @bind-Checked="@_unknownModelCode" @TValue="bool">@L["Unknown (model code)"]</Check>
}
@if(!_editing ||
!_unknownModelCode)
{
<Validation Validator="@ValidateModelCode">
<TextEdit @bind-Text="@_model.ModelCode" Disabled="!_editing">
<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 @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)
{
<Validation Validator="@ValidateIntroduced">
<DateEdit @bind-Date="@_model.Introduced" Disabled="!_editing" @TValue="DateTime?">
<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 @bind-Checked="@_unknownVoices" @TValue="bool">@L["Unknown (voices)"]</Check>
}
@if(!_editing ||
!_unknownVoices)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit @bind-Value="@_model.Voices" Decimals="0" Disabled="!_editing" @TValue="int?">
<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 @bind-Checked="@_unknownSampleRate" @TValue="bool">@L["Unknown (sample rate)"]</Check>
}
@if(!_editing ||
!_unknownSampleRate)
{
<Validation Validator="@ValidateDoubleBiggerThanZero">
<NumericEdit @bind-Value="@_model.Frequency" Decimals="0" Disabled="!_editing" @TValue="double?">
<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 @bind-Checked="@_unknownSampleResolution" @TValue="bool">@L["Unknown (sample resolution)"]</Check>
}
@if(!_editing ||
!_unknownSampleResolution)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit @bind-Value="@_model.Depth" Decimals="0" Disabled="!_editing" @TValue="int?">
<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 @bind-Checked="@_unknownSquareWaveChannels" @TValue="bool">@L["Unknown (square wave channels)"]</Check>
}
@if(!_editing ||
!_unknownSquareWaveChannels)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit @bind-Value="@_model.SquareWave" Decimals="0" Disabled="!_editing" @TValue="int?">
<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 @bind-Checked="@_unknownWhiteNoiseChannels" @TValue="bool">@L["Unknown (white noise channels)"]</Check>
}
@if(!_editing ||
!_unknownWhiteNoiseChannels)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit @bind-Value="@_model.WhiteNoise" Decimals="0" Disabled="!_editing" @TValue="int?">
<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 @bind-Checked="@_unknownType" @TValue="bool">@L["Unknown (type)"]</Check>
}
@if(!_editing ||
!_unknownType)
{
<Validation Validator="@ValidateIntegerBiggerThanZero">
<NumericEdit @bind-Value="@_model.Type" Decimals="0" Disabled="!_editing" @TValue="int?">
<Feedback>
<ValidationError>@L["Please enter a valid sound synthesizer type."]</ValidationError>
</Feedback>
</NumericEdit>
</Validation>
}
</Field>
}
</div>
<div>
@if(!_editing)
{
<Button Clicked="@OnEditClicked" Color="Color.Primary">@L["Edit"]</Button>
}
else
{
<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/sound_synths">@L["Back to list"]</a>
</div>