mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move sound synthesizers admin index to Blazor.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<Version>3.0.99.1067</Version>
|
<Version>3.0.99.1068</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
@@ -79,6 +79,9 @@
|
|||||||
<Content Update="Pages\Admin\Screens.razor">
|
<Content Update="Pages\Admin\Screens.razor">
|
||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Update="Pages\Admin\SoundSynths.razor">
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
||||||
|
|||||||
@@ -77,6 +77,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/admin/screens">@L["Screens"]</a>
|
<a href="/admin/screens">@L["Screens"]</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/admin/sound_synths">@L["Sound synthesizers"]</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|||||||
114
Marechai/Pages/Admin/SoundSynths.razor
Normal file
114
Marechai/Pages/Admin/SoundSynths.razor
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
@{
|
||||||
|
/******************************************************************************
|
||||||
|
// MARECHAI: Master repository of computing history artifacts information
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : SoundSynths.razor
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// List of sound synthesizers
|
||||||
|
//
|
||||||
|
// --[ 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"
|
||||||
|
@using Marechai.Database.Models
|
||||||
|
@inherits OwningComponentBase<SoundSynthsService>
|
||||||
|
@inject IStringLocalizer<SoundSynthsService> L
|
||||||
|
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||||
|
<h3>@L["Sound synthesizers"]</h3>
|
||||||
|
@if (_soundSynths is null)
|
||||||
|
{
|
||||||
|
<p>@L["Loading..."]</p>
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
<p>
|
||||||
|
<span class="btn btn-primary">
|
||||||
|
@L["Create new"]
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
@L["Company"]
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@L["Name"]
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@L["Model code"]
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@L["Introduced"]
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@L["Type"]
|
||||||
|
</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in _soundSynths)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@item.CompanyName
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.Name
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.ModelCode
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.IntroducedView
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@item.Type
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="btn btn-primary">
|
||||||
|
@L["Details"]
|
||||||
|
</span>
|
||||||
|
<span class="btn btn-secondary">
|
||||||
|
@L["Edit"]
|
||||||
|
</span>
|
||||||
|
<span class="btn btn-danger">
|
||||||
|
@L["Delete"]
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
List<SoundSynthViewModel> _soundSynths;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_soundSynths = await Service.GetAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -202,4 +202,8 @@
|
|||||||
<value>Pantallas</value>
|
<value>Pantallas</value>
|
||||||
<comment>Screens.</comment>
|
<comment>Screens.</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Sound synthesizers" xml:space="preserve">
|
||||||
|
<value>Sintetizadores de sonido</value>
|
||||||
|
<comment>Sound synthesizers.</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
165
Marechai/Resources/Services/SoundSynthsService.es.resx
Normal file
165
Marechai/Resources/Services/SoundSynthsService.es.resx
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<?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="Sound synthesizers" xml:space="preserve">
|
||||||
|
<value>Sintetizadores de sonido</value>
|
||||||
|
<comment>Sound synthesizers</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Loading..." xml:space="preserve">
|
||||||
|
<value>Cargando...</value>
|
||||||
|
<comment>Message that appears while data is being loaded from database</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Name" xml:space="preserve">
|
||||||
|
<value>Nombre</value>
|
||||||
|
<comment>Name</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Company" xml:space="preserve">
|
||||||
|
<value>Compañía</value>
|
||||||
|
<comment>Company</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Model code" xml:space="preserve">
|
||||||
|
<value>Modelo</value>
|
||||||
|
<comment>Model</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Introduced" xml:space="preserve">
|
||||||
|
<value>Introducido el</value>
|
||||||
|
<comment>Introduced</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Type" xml:space="preserve">
|
||||||
|
<value>Tipo</value>
|
||||||
|
<comment>Type</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Create new" xml:space="preserve">
|
||||||
|
<value>Crear nuevo</value>
|
||||||
|
<comment>Create new</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Details" xml:space="preserve">
|
||||||
|
<value>Detalles</value>
|
||||||
|
<comment>Details</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Edit" xml:space="preserve">
|
||||||
|
<value>Editar</value>
|
||||||
|
<comment>Edit</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Delete" xml:space="preserve">
|
||||||
|
<value>Eliminar</value>
|
||||||
|
<comment>Delete</comment>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -13,13 +13,15 @@ namespace Marechai.Services
|
|||||||
readonly MarechaiContext _context;
|
readonly MarechaiContext _context;
|
||||||
readonly IStringLocalizer<MachinesService> _l;
|
readonly IStringLocalizer<MachinesService> _l;
|
||||||
readonly ProcessorsService _processorsService;
|
readonly ProcessorsService _processorsService;
|
||||||
|
readonly SoundSynthsService _soundSynthsService;
|
||||||
|
|
||||||
public MachinesService(MarechaiContext context, IStringLocalizer<MachinesService> localizer,
|
public MachinesService(MarechaiContext context, IStringLocalizer<MachinesService> localizer,
|
||||||
ProcessorsService processorsService)
|
ProcessorsService processorsService, SoundSynthsService soundSynthsService)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_l = localizer;
|
_l = localizer;
|
||||||
_processorsService = processorsService;
|
_processorsService = processorsService;
|
||||||
|
_soundSynthsService = soundSynthsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MachineViewModel>> GetAsync() =>
|
public async Task<List<MachineViewModel>> GetAsync() =>
|
||||||
@@ -85,15 +87,7 @@ namespace Marechai.Services
|
|||||||
|
|
||||||
model.Processors = await _processorsService.GetByMachineAsync(machine.Id);
|
model.Processors = await _processorsService.GetByMachineAsync(machine.Id);
|
||||||
|
|
||||||
model.SoundSynthesizers =
|
model.SoundSynthesizers = await _soundSynthsService.GetByMachineAsync(machine.Id);
|
||||||
await _context.SoundByMachine.Where(s => s.MachineId == machine.Id).Select(s => s.SoundSynth).
|
|
||||||
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
|
|
||||||
}).ToListAsync();
|
|
||||||
|
|
||||||
model.Storage = await _context.StorageByMachine.Where(s => s.MachineId == machine.Id).
|
model.Storage = await _context.StorageByMachine.Where(s => s.MachineId == machine.Id).
|
||||||
Select(s => new StorageViewModel
|
Select(s => new StorageViewModel
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ namespace Marechai.Services
|
|||||||
services.AddScoped<PeopleService>();
|
services.AddScoped<PeopleService>();
|
||||||
services.AddScoped<ProcessorsService>();
|
services.AddScoped<ProcessorsService>();
|
||||||
services.AddScoped<ScreensService>();
|
services.AddScoped<ScreensService>();
|
||||||
|
services.AddScoped<SoundSynthsService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
37
Marechai/Services/SoundSynthsService.cs
Normal file
37
Marechai/Services/SoundSynthsService.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Marechai.Database.Models;
|
||||||
|
using Marechai.ViewModels;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Marechai.Services
|
||||||
|
{
|
||||||
|
public class SoundSynthsService
|
||||||
|
{
|
||||||
|
readonly MarechaiContext _context;
|
||||||
|
|
||||||
|
public SoundSynthsService(MarechaiContext context) => _context = context;
|
||||||
|
|
||||||
|
public async Task<List<SoundSynthViewModel>> GetAsync() =>
|
||||||
|
await _context.SoundSynths.OrderBy(s => s.Company.Name).ThenBy(s => s.Name).ThenBy(s => s.ModelCode).
|
||||||
|
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
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
public async Task<List<SoundSynthViewModel>> GetByMachineAsync(int machineId) =>
|
||||||
|
await _context.SoundByMachine.Where(s => s.MachineId == machineId).Select(s => s.SoundSynth).
|
||||||
|
OrderBy(s => s.Company.Name).ThenBy(s => s.Name).ThenBy(s => s.ModelCode).
|
||||||
|
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
|
||||||
|
}).ToListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Marechai.ViewModels
|
namespace Marechai.ViewModels
|
||||||
{
|
{
|
||||||
@@ -15,5 +16,8 @@ namespace Marechai.ViewModels
|
|||||||
public int? SquareWave { get; set; }
|
public int? SquareWave { get; set; }
|
||||||
public int? WhiteNoise { get; set; }
|
public int? WhiteNoise { get; set; }
|
||||||
public int? Type { get; set; }
|
public int? Type { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public string IntroducedView => Introduced?.ToShortDateString() ?? "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user