mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add sound synthesizer editing in admin view.
This commit is contained in:
@@ -1,129 +0,0 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Edit.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Admin view edit
|
||||
//
|
||||
// --[ 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
|
||||
*******************************************************************************/
|
||||
}
|
||||
@model Marechai.Database.Models.SoundSynth
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Edit";
|
||||
}
|
||||
<h2>Edit</h2>
|
||||
<h4>Sound synthetizer</h4>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<form asp-action="Edit">
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger">
|
||||
</div>
|
||||
<input type="hidden" asp-for="Id" />
|
||||
<div class="form-group">
|
||||
<label asp-for="Company" class="control-label">
|
||||
</label>
|
||||
<select asp-for="CompanyId" class="form-control" asp-items="ViewBag.CompanyId">
|
||||
</select>
|
||||
<span asp-validation-for="CompanyId" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Name" class="control-label">
|
||||
</label>
|
||||
<input asp-for="Name" class="form-control" />
|
||||
<span asp-validation-for="Name" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ModelCode" class="control-label">
|
||||
</label>
|
||||
<input asp-for="ModelCode" class="form-control" />
|
||||
<span asp-validation-for="ModelCode" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Introduced" class="control-label">
|
||||
</label>
|
||||
<input asp-for="Introduced" class="form-control" />
|
||||
<span asp-validation-for="Introduced" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Type" class="control-label">
|
||||
</label>
|
||||
<input asp-for="Type" class="form-control" />
|
||||
<span asp-validation-for="Type" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Voices" class="control-label">
|
||||
</label>
|
||||
<input asp-for="Voices" class="form-control" />
|
||||
<span asp-validation-for="Voices" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Frequency" class="control-label">
|
||||
</label>
|
||||
<input asp-for="Frequency" class="form-control" />
|
||||
<span asp-validation-for="Frequency" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Depth" class="control-label">
|
||||
</label>
|
||||
<input asp-for="Depth" class="form-control" />
|
||||
<span asp-validation-for="Depth" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="SquareWave" class="control-label">
|
||||
</label>
|
||||
<input asp-for="SquareWave" class="form-control" />
|
||||
<span asp-validation-for="SquareWave" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="WhiteNoise" class="control-label">
|
||||
</label>
|
||||
<input asp-for="WhiteNoise" class="form-control" />
|
||||
<span asp-validation-for="WhiteNoise" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="Save" />
|
||||
<a asp-action="Index" class="btn btn-secondary">
|
||||
Back to List
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Index.cshtml
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Admin view index
|
||||
//
|
||||
// --[ 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
|
||||
*******************************************************************************/
|
||||
}
|
||||
@model IEnumerable<Marechai.Areas.Admin.Models.SoundSynthViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Sound synthesizers (Admin)";
|
||||
}
|
||||
<h2>Sound synthesizers</h2>
|
||||
<p>
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
Create new
|
||||
</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Company)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.ModelCode)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Introduced)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Type)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Company)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ModelCode)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.IntroducedView)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Type)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">
|
||||
Details
|
||||
</a>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">
|
||||
Edit
|
||||
</a>
|
||||
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">
|
||||
Delete
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>3.0.99.1195</Version>
|
||||
<Version>3.0.99.1219</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
@@ -31,9 +31,11 @@
|
||||
}
|
||||
|
||||
@page "/admin/sound_synths/details/{Id:int}"
|
||||
@page "/admin/sound_synths/edit/{Id:int}"
|
||||
@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 />
|
||||
@@ -46,80 +48,209 @@
|
||||
}
|
||||
|
||||
<div>
|
||||
@if (_editable || _model.CompanyId != null)
|
||||
@if (_editing || _model.CompanyId != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Company"]</FieldLabel>
|
||||
<Select Disabled="!_editable" TValue="int?" @bind-SelectedValue="@_model.CompanyId">
|
||||
@foreach (var company in _companies)
|
||||
{
|
||||
<SelectItem TValue="int?" Value="@company.Id">@company.Name</SelectItem>
|
||||
}
|
||||
</Select>
|
||||
@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>
|
||||
<TextEdit Disabled="!_editable" @bind-Text="@_model.Name"/>
|
||||
<TextEdit Disabled="!_editing" @bind-Text="@_model.Name"/>
|
||||
</Field>
|
||||
@if (_editable || _model.ModelCode != null)
|
||||
@if (_editing || _model.ModelCode != null)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Model code"]</FieldLabel>
|
||||
<TextEdit Disabled="!_editable" @bind-Text="@_model.ModelCode"/>
|
||||
@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 (_editable || _model.Introduced.HasValue)
|
||||
@if (_editing || _model.Introduced.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Introduced"]</FieldLabel>
|
||||
<DateEdit Disabled="!_editable" TValue="DateTime?" @bind-Date="@_model.Introduced"/>
|
||||
</Field>
|
||||
@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 (_editable || _model.Voices.HasValue)
|
||||
@if (_editing || _model.Voices.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Digitized voices"]</FieldLabel>
|
||||
<NumericEdit Disabled="!_editable" TValue="int?" Decimals="0" @bind-Value="@_model.Voices"/>
|
||||
</Field>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownVoices">@L["Unknown (voices)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownVoices)
|
||||
{
|
||||
<Validation Validator="@ValidateNullableIntegerBiggerThanZero">
|
||||
<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 (_editable || _model.Frequency.HasValue)
|
||||
@if (_editing || _model.Frequency.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Sample rate (Hz)"]</FieldLabel>
|
||||
<NumericEdit Disabled="!_editable" TValue="double?" Decimals="0" @bind-Value="@_model.Frequency"/>
|
||||
</Field>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownSampleRate">@L["Unknown (sample rate)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownSampleRate)
|
||||
{
|
||||
<Validation Validator="@ValidateNullableDoubleBiggerThanZero">
|
||||
<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 (_editable || _model.Depth.HasValue)
|
||||
@if (_editing || _model.Depth.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Sample resolution (bits)"]</FieldLabel>
|
||||
<NumericEdit Disabled="!_editable" TValue="int?" Decimals="0" @bind-Value="@_model.Depth"/>
|
||||
</Field>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownSampleResolution">@L["Unknown (sample resolution)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownSampleResolution)
|
||||
{
|
||||
<Validation Validator="@ValidateNullableIntegerBiggerThanZero">
|
||||
<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 (_editable || _model.SquareWave.HasValue)
|
||||
@if (_editing || _model.SquareWave.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Square wave channels"]</FieldLabel>
|
||||
<NumericEdit Disabled="!_editable" TValue="int?" Decimals="0" @bind-Value="@_model.SquareWave"/>
|
||||
</Field>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownSquareWaveChannels">@L["Unknown (square wave channels)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownSquareWaveChannels)
|
||||
{
|
||||
<Validation Validator="@ValidateNullableIntegerBiggerThanZero">
|
||||
<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 (_editable || _model.WhiteNoise.HasValue)
|
||||
@if (_editing || _model.WhiteNoise.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["White noise channels"]</FieldLabel>
|
||||
<NumericEdit Disabled="!_editable" TValue="int?" Decimals="0" @bind-Value="@_model.WhiteNoise"/>
|
||||
</Field>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownWhiteNoiseChannels">@L["Unknown (white noise channels)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownWhiteNoiseChannels)
|
||||
{
|
||||
<Validation Validator="@ValidateNullableIntegerBiggerThanZero">
|
||||
<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 (_editable || _model.Type.HasValue)
|
||||
@if (_editing || _model.Type.HasValue)
|
||||
{
|
||||
<Field>
|
||||
<FieldLabel>@L["Type"]</FieldLabel>
|
||||
<NumericEdit Disabled="!_editable" TValue="int?" Decimals="0" @bind-Value="@_model.Type"/>
|
||||
</Field>
|
||||
@if (_editing)
|
||||
{
|
||||
<Check TValue="bool" @bind-Checked="@_unknownType">@L["Unknown (type)"]</Check>
|
||||
}
|
||||
@if (!_editing ||
|
||||
!_unknownType)
|
||||
{
|
||||
<Validation Validator="@ValidateNullableIntegerBiggerThanZero">
|
||||
<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>
|
||||
<span class="btn btn-primary">@L["Edit"]</span>
|
||||
@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>
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Blazorise;
|
||||
using Marechai.Shared;
|
||||
using Marechai.ViewModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -7,10 +10,20 @@ namespace Marechai.Pages.Admin.Details
|
||||
{
|
||||
public partial class SoundSynth
|
||||
{
|
||||
List<CompanyViewModel> _companies;
|
||||
bool _editable;
|
||||
bool _loaded;
|
||||
Database.Models.SoundSynth _model;
|
||||
List<CompanyViewModel> _companies;
|
||||
bool _editing;
|
||||
bool _loaded;
|
||||
SoundSynthViewModel _model;
|
||||
bool _prototype;
|
||||
bool _unknownCompany;
|
||||
bool _unknownIntroduced;
|
||||
bool _unknownModelCode;
|
||||
bool _unknownSampleRate;
|
||||
bool _unknownSampleResolution;
|
||||
bool _unknownSquareWaveChannels;
|
||||
bool _unknownType;
|
||||
bool _unknownVoices;
|
||||
bool _unknownWhiteNoiseChannels;
|
||||
[Parameter]
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -27,7 +40,109 @@ namespace Marechai.Pages.Admin.Details
|
||||
_companies = await CompaniesService.GetAsync();
|
||||
_model = await Service.GetAsync(Id);
|
||||
|
||||
_editing = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
|
||||
StartsWith("admin/sound_synths/edit/", StringComparison.InvariantCulture);
|
||||
|
||||
if(_editing)
|
||||
SetCheckboxes();
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void SetCheckboxes()
|
||||
{
|
||||
_unknownCompany = !_model.CompanyId.HasValue;
|
||||
_unknownModelCode = string.IsNullOrWhiteSpace(_model.ModelCode);
|
||||
_unknownIntroduced = !_model.Introduced.HasValue;
|
||||
_prototype = _model.Introduced?.Year == 1000;
|
||||
_unknownVoices = !_model.Voices.HasValue;
|
||||
_unknownSampleRate = !_model.Frequency.HasValue;
|
||||
_unknownSampleResolution = !_model.Depth.HasValue;
|
||||
_unknownSquareWaveChannels = !_model.SquareWave.HasValue;
|
||||
_unknownWhiteNoiseChannels = !_model.WhiteNoise.HasValue;
|
||||
_unknownType = !_model.Type.HasValue;
|
||||
}
|
||||
|
||||
void OnEditClicked()
|
||||
{
|
||||
_editing = true;
|
||||
SetCheckboxes();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void OnCancelClicked()
|
||||
{
|
||||
_editing = false;
|
||||
_model = await Service.GetAsync(Id);
|
||||
SetCheckboxes();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void OnSaveClicked()
|
||||
{
|
||||
if(_unknownCompany)
|
||||
_model.CompanyId = null;
|
||||
else if(_model.CompanyId < 0)
|
||||
return;
|
||||
|
||||
if(_unknownModelCode)
|
||||
_model.ModelCode = null;
|
||||
else if(string.IsNullOrWhiteSpace(_model.ModelCode))
|
||||
return;
|
||||
|
||||
if(_unknownIntroduced)
|
||||
_model.Introduced = null;
|
||||
else if(_prototype)
|
||||
_model.Introduced = new DateTime(1000, 1, 1);
|
||||
else if(_model.Introduced >= DateTime.UtcNow.Date)
|
||||
return;
|
||||
|
||||
if(_unknownVoices)
|
||||
_model.Voices = null;
|
||||
else if(_model.Voices < 0)
|
||||
return;
|
||||
|
||||
if(_unknownSampleRate)
|
||||
_model.Frequency = null;
|
||||
else if(_model.Frequency < 0)
|
||||
return;
|
||||
|
||||
if(_unknownSampleResolution)
|
||||
_model.Depth = null;
|
||||
else if(_model.Depth < 0)
|
||||
return;
|
||||
|
||||
if(_unknownSquareWaveChannels)
|
||||
_model.SquareWave = null;
|
||||
else if(_model.SquareWave < 0)
|
||||
return;
|
||||
|
||||
if(_unknownWhiteNoiseChannels)
|
||||
_model.WhiteNoise = null;
|
||||
else if(_model.WhiteNoise < 0)
|
||||
return;
|
||||
|
||||
if(_unknownType)
|
||||
_model.Type = null;
|
||||
else if(_model.Type < 0)
|
||||
return;
|
||||
|
||||
_editing = false;
|
||||
await Service.UpdateAsync(_model);
|
||||
_model = await Service.GetAsync(Id);
|
||||
SetCheckboxes();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void ValidateModelCode(ValidatorEventArgs e) =>
|
||||
Validators.ValidateStringWithMaxLength(e, L["Model code must be 45 characters or less."], 45);
|
||||
|
||||
void ValidateIntroduced(ValidatorEventArgs e) => Validators.ValidateIntroducedDate(e);
|
||||
|
||||
void ValidateNullableIntegerBiggerThanZero(ValidatorEventArgs e) =>
|
||||
Validators.ValidateNullableIntegerBiggerThanZero(e);
|
||||
|
||||
void ValidateNullableDoubleBiggerThanZero(ValidatorEventArgs e) =>
|
||||
Validators.ValidateNullableDoubleBiggerThanZero(e);
|
||||
}
|
||||
}
|
||||
@@ -88,9 +88,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary" href="/admin/sound_synths/details/@item.Id">@L["Details"]</a>
|
||||
<span class="btn btn-secondary">
|
||||
@L["Edit"]
|
||||
</span>
|
||||
<a class="btn btn-secondary" href="/admin/sound_synths/edit/@item.Id">@L["Edit"]</a>
|
||||
<Button Color="Color.Danger" Clicked="() => {ShowModal(item.Id);}">@L["Delete"]</Button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
157
Marechai/Resources/Services/SoundSynthsService.en.resx
Normal file
157
Marechai/Resources/Services/SoundSynthsService.en.resx
Normal file
@@ -0,0 +1,157 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ReSharper disable MarkupTextTypo -->
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Unknown (company)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to a company</comment>
|
||||
</data>
|
||||
<data name="Unknown (model code)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to a model code</comment>
|
||||
</data>
|
||||
<data name="Unknown (introduction date)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to an introduction date</comment>
|
||||
</data>
|
||||
<data name="Unknown (voices)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to digitized voices</comment>
|
||||
</data>
|
||||
<data name="Unknown (sample rate)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to sample rate</comment>
|
||||
</data>
|
||||
<data name="Unknown (sample resolution)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to sample resolution</comment>
|
||||
</data>
|
||||
<data name="Unknown (square wave channels)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to square wave channels</comment>
|
||||
</data>
|
||||
<data name="Unknown (white noise channels)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to white noise channels</comment>
|
||||
</data>
|
||||
<data name="Unknown (type)" xml:space="preserve">
|
||||
<value>Unknown</value>
|
||||
<comment>Unknown, referring to sound synthesizer type</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -202,4 +202,84 @@
|
||||
<value>Canales de ruido blanco</value>
|
||||
<comment>White noise channels</comment>
|
||||
</data>
|
||||
<data name="Unknown (company)" xml:space="preserve">
|
||||
<value>Desconocida</value>
|
||||
<comment>Unknown, referring to a company</comment>
|
||||
</data>
|
||||
<data name="Unknown (model code)" xml:space="preserve">
|
||||
<value>Desconocido</value>
|
||||
<comment>Unknown, referring to a model code</comment>
|
||||
</data>
|
||||
<data name="Unknown (introduction date)" xml:space="preserve">
|
||||
<value>Desconocida</value>
|
||||
<comment>Unknown, referring to an introduction date</comment>
|
||||
</data>
|
||||
<data name="Unknown (voices)" xml:space="preserve">
|
||||
<value>Desconocidas</value>
|
||||
<comment>Unknown, referring to digitized voices</comment>
|
||||
</data>
|
||||
<data name="Unknown (sample rate)" xml:space="preserve">
|
||||
<value>Desconocida</value>
|
||||
<comment>Unknown, referring to sample rate</comment>
|
||||
</data>
|
||||
<data name="Unknown (sample resolution)" xml:space="preserve">
|
||||
<value>Desconocida</value>
|
||||
<comment>Unknown, referring to sample resolution</comment>
|
||||
</data>
|
||||
<data name="Unknown (square wave channels)" xml:space="preserve">
|
||||
<value>Desconocidos</value>
|
||||
<comment>Unknown, referring to square wave channels</comment>
|
||||
</data>
|
||||
<data name="Unknown (white noise channels)" xml:space="preserve">
|
||||
<value>Desconocidos</value>
|
||||
<comment>Unknown, referring to white noise channels</comment>
|
||||
</data>
|
||||
<data name="Unknown (type)" xml:space="preserve">
|
||||
<value>Desconocido</value>
|
||||
<comment>Unknown, referring to sound synthesizer type</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid model code." xml:space="preserve">
|
||||
<value>Por favor introduce un modelo válido.</value>
|
||||
<comment>Please enter a valid model code.</comment>
|
||||
</data>
|
||||
<data name="Prototype" xml:space="preserve">
|
||||
<value>Prototipo</value>
|
||||
<comment>Prototype</comment>
|
||||
</data>
|
||||
<data name="Please enter an introduction date." xml:space="preserve">
|
||||
<value>Por favor introduce una fecha válida.</value>
|
||||
<comment>Please enter an introduction date.</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid number of voices." xml:space="preserve">
|
||||
<value>Por favor introduce un número de voces válido.</value>
|
||||
<comment>Please enter a valid number of voices.</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid sample rate." xml:space="preserve">
|
||||
<value>Por favor introduce una frequencia de muestreo válida.</value>
|
||||
<comment>Please enter a valid sample rate.</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid number of bits for sample resolution." xml:space="preserve">
|
||||
<value>Por favor introduce un número de bits de resolución de muestreo válido.</value>
|
||||
<comment>Please enter a valid number of bits for sample resolution.</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid number of square wave channels." xml:space="preserve">
|
||||
<value>Por favor introduce un número de canales de onda cuadrada válido.</value>
|
||||
<comment>Please enter a valid number of square wave channels.</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid number of white noise channels." xml:space="preserve">
|
||||
<value>Por favor introduce un número de canales de rudio blanco válido.</value>
|
||||
<comment>Please enter a valid number of white noise channels.</comment>
|
||||
</data>
|
||||
<data name="Please enter a valid sound synthesizer type." xml:space="preserve">
|
||||
<value>Por favor introduce un tipo de sintetizador válido.</value>
|
||||
<comment>Please enter a valid sound synthesizer type.</comment>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
<value>Guardar</value>
|
||||
<comment>Save</comment>
|
||||
</data>
|
||||
<data name="Model code must be 45 characters or less." xml:space="preserve">
|
||||
<value>El modelo debe contener 45 caracteres o menos.</value>
|
||||
<comment>Model code must be 45 characters or less.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -34,7 +34,42 @@ namespace Marechai.Services
|
||||
WhiteNoise = s.WhiteNoise, Type = s.Type
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<SoundSynth> GetAsync(int id) => await _context.SoundSynths.FindAsync(id);
|
||||
public async Task<SoundSynthViewModel> GetAsync(int id) => await _context.SoundSynths.Where(s => s.Id == id).
|
||||
Select(s => new SoundSynthViewModel
|
||||
{
|
||||
Id = s.Id, Name = s.Name,
|
||||
CompanyId = s.Company.Id,
|
||||
CompanyName = s.Company.Name,
|
||||
ModelCode = s.ModelCode,
|
||||
Introduced = s.Introduced,
|
||||
Voices = s.Voices,
|
||||
Frequency = s.Frequency,
|
||||
Depth = s.Depth,
|
||||
SquareWave = s.SquareWave,
|
||||
WhiteNoise = s.WhiteNoise,
|
||||
Type = s.Type
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
public async Task UpdateAsync(SoundSynthViewModel viewModel)
|
||||
{
|
||||
SoundSynth model = await _context.SoundSynths.FindAsync(viewModel.Id);
|
||||
|
||||
if(model is null)
|
||||
return;
|
||||
|
||||
model.Depth = viewModel.Depth;
|
||||
model.Frequency = viewModel.Frequency;
|
||||
model.Introduced = viewModel.Introduced;
|
||||
model.Name = viewModel.Name;
|
||||
model.Type = viewModel.Type;
|
||||
model.Voices = viewModel.Voices;
|
||||
model.CompanyId = viewModel.CompanyId;
|
||||
model.ModelCode = viewModel.ModelCode;
|
||||
model.SquareWave = viewModel.SquareWave;
|
||||
model.WhiteNoise = viewModel.WhiteNoise;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
|
||||
49
Marechai/Shared/Validators.cs
Normal file
49
Marechai/Shared/Validators.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Blazorise;
|
||||
|
||||
namespace Marechai.Shared
|
||||
{
|
||||
public static class Validators
|
||||
{
|
||||
public static void ValidateStringWithMaxLength(ValidatorEventArgs e, string message, int maxLength)
|
||||
{
|
||||
string item = e.Value as string;
|
||||
|
||||
if(item?.Length > maxLength)
|
||||
{
|
||||
e.ErrorText = message;
|
||||
e.Status = ValidationStatus.Error;
|
||||
}
|
||||
else
|
||||
e.Status = string.IsNullOrWhiteSpace(item) ? ValidationStatus.Error : ValidationStatus.Success;
|
||||
}
|
||||
|
||||
public static void ValidateIntroducedDate(ValidatorEventArgs e)
|
||||
{
|
||||
if(!(e.Value is DateTime item) ||
|
||||
item.Year < 1900 ||
|
||||
item.Date >= DateTime.UtcNow.Date)
|
||||
e.Status = ValidationStatus.Error;
|
||||
else
|
||||
e.Status = ValidationStatus.Success;
|
||||
}
|
||||
|
||||
public static void ValidateNullableDoubleBiggerThanZero(ValidatorEventArgs e)
|
||||
{
|
||||
if(!(e.Value is double item) ||
|
||||
item < 0)
|
||||
e.Status = ValidationStatus.Error;
|
||||
else
|
||||
e.Status = ValidationStatus.Success;
|
||||
}
|
||||
|
||||
public static void ValidateNullableIntegerBiggerThanZero(ValidatorEventArgs e)
|
||||
{
|
||||
if(!(e.Value is int item) ||
|
||||
item < 0)
|
||||
e.Status = ValidationStatus.Error;
|
||||
else
|
||||
e.Status = ValidationStatus.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user