mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move people admin index to Blazor.
This commit is contained in:
@@ -48,8 +48,6 @@
|
||||
<br />
|
||||
<a asp-controller="News">News</a>
|
||||
<br />
|
||||
<a asp-controller="People">People</a>
|
||||
<br />
|
||||
<a asp-controller="ProcessorsByMachines">Processors by machines</a>
|
||||
<br />
|
||||
<a asp-controller="Processors">Processors</a>
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
@model IEnumerable<Marechai.Database.Models.Person>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "People";
|
||||
}
|
||||
<h1>People</h1>
|
||||
<p>
|
||||
<a asp-action="Create" class="btn btn-primary">Create new</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.FullName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CountryOfBirth)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.BirthDate)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.DeathDate)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Webpage)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Twitter)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Facebook)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FullName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CountryOfBirth.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.BirthDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DeathDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Webpage)
|
||||
</td>
|
||||
<td>
|
||||
@if (item.Twitter != null)
|
||||
{
|
||||
<a href="https://twitter.com/@Html.DisplayFor(modelItem => item.Twitter)">@Html.DisplayFor(modelItem => item.Twitter)</a>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (item.Facebook != null)
|
||||
{
|
||||
<a href="https://www.facebook.com/@Html.DisplayFor(modelItem => item.Facebook)">@Html.DisplayFor(modelItem => item.Facebook)</a>
|
||||
}
|
||||
</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.1060</Version>
|
||||
<Version>3.0.99.1061</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
@@ -67,6 +67,9 @@
|
||||
<Content Update="Pages\Admin\Machines.razor">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
<Content Update="Pages\Admin\People.razor">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Areas\Admin\Views\BrowserTests\Delete.cshtml" />
|
||||
|
||||
@@ -65,6 +65,9 @@
|
||||
<li>
|
||||
<a href="/admin/machines">@L["Machines"]</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin/people">@L["People"]</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="content">
|
||||
|
||||
131
Marechai/Pages/Admin/People.razor
Normal file
131
Marechai/Pages/Admin/People.razor
Normal file
@@ -0,0 +1,131 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : People.razor
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// List of people
|
||||
//
|
||||
// --[ 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/people"
|
||||
@inherits OwningComponentBase<PeopleService>
|
||||
@inject IStringLocalizer<PeopleService> L
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
<h3>@L["People"]</h3>
|
||||
@if (_people 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["Known name"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Country of birth"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Birth date"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Date of death"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Webpage"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Twitter"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Facebook"]
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in _people)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.FullName
|
||||
</td>
|
||||
<td>
|
||||
@item.CountryOfBirth
|
||||
</td>
|
||||
<td>
|
||||
@($"{item.BirthDate:d}")
|
||||
</td>
|
||||
<td>
|
||||
@($"{item.DeathDate:d}")
|
||||
</td>
|
||||
<td>
|
||||
@item.Webpage
|
||||
</td>
|
||||
<td>
|
||||
@if (item.Twitter != null)
|
||||
{
|
||||
<a href="https://twitter.com/@item.Twitter">@item.Twitter</a>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (item.Facebook != null)
|
||||
{
|
||||
<a href="https://www.facebook.com/@item.Facebook">@item.Facebook</a>
|
||||
}
|
||||
</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<PersonViewModel> _people;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_people = await Service.GetAsync();
|
||||
}
|
||||
}
|
||||
@@ -186,4 +186,8 @@
|
||||
<value>Máquinas</value>
|
||||
<comment>Machines.</comment>
|
||||
</data>
|
||||
<data name="People" xml:space="preserve">
|
||||
<value>Gente</value>
|
||||
<comment>People.</comment>
|
||||
</data>
|
||||
</root>
|
||||
173
Marechai/Resources/Services/PeopleService.es.resx
Normal file
173
Marechai/Resources/Services/PeopleService.es.resx
Normal file
@@ -0,0 +1,173 @@
|
||||
<?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="People" xml:space="preserve">
|
||||
<value>Gente</value>
|
||||
<comment>People</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="Known name" xml:space="preserve">
|
||||
<value>Nombre conocido</value>
|
||||
<comment>Known name</comment>
|
||||
</data>
|
||||
<data name="Country of birth" xml:space="preserve">
|
||||
<value>País de nacimiento</value>
|
||||
<comment>Country of birth</comment>
|
||||
</data>
|
||||
<data name="Birth date" xml:space="preserve">
|
||||
<value>Fecha de nacimiento</value>
|
||||
<comment>Birth date</comment>
|
||||
</data>
|
||||
<data name="Date of death" xml:space="preserve">
|
||||
<value>Fecha de fallecimiento</value>
|
||||
<comment>Date of death</comment>
|
||||
</data>
|
||||
<data name="Webpage" xml:space="preserve">
|
||||
<value>Página web</value>
|
||||
<comment>Webpage</comment>
|
||||
</data>
|
||||
<data name="Twitter" xml:space="preserve">
|
||||
<value>Twitter</value>
|
||||
<comment>Twitter</comment>
|
||||
</data>
|
||||
<data name="Facebook" xml:space="preserve">
|
||||
<value>Facebook</value>
|
||||
<comment>Facebook</comment>
|
||||
</data>
|
||||
<data name="Create new" xml:space="preserve">
|
||||
<value>Crear nueva</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>
|
||||
26
Marechai/Services/PeopleService.cs
Normal file
26
Marechai/Services/PeopleService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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 PeopleService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public PeopleService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<PersonViewModel>> GetAsync() =>
|
||||
await _context.People.OrderBy(p => p.DisplayName).ThenBy(p => p.Alias).ThenBy(p => p.Name).
|
||||
ThenBy(p => p.Surname).Select(p => new PersonViewModel
|
||||
{
|
||||
Id = p.Id, Name = p.Name, Surname = p.Surname, CountryOfBirth = p.CountryOfBirth.Name,
|
||||
BirthDate = p.BirthDate, DeathDate = p.DeathDate, Webpage = p.Webpage,
|
||||
Twitter = p.Twitter, Facebook = p.Facebook, Photo = p.Photo, Alias = p.Alias,
|
||||
DisplayName = p.DisplayName
|
||||
}).ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ namespace Marechai.Services
|
||||
services.AddScoped<InstructionSetsService>();
|
||||
services.AddScoped<LicensesService>();
|
||||
services.AddScoped<MachineFamiliesService>();
|
||||
services.AddScoped<PeopleService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Marechai/ViewModels/PersonViewModel.cs
Normal file
21
Marechai/ViewModels/PersonViewModel.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace Marechai.ViewModels
|
||||
{
|
||||
public class PersonViewModel : BaseViewModel<int>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
public string CountryOfBirth { get; set; }
|
||||
public DateTime BirthDate { get; set; }
|
||||
public DateTime? DeathDate { get; set; }
|
||||
public string Webpage { get; set; }
|
||||
public string Twitter { get; set; }
|
||||
public string Facebook { get; set; }
|
||||
public Guid Photo { get; set; }
|
||||
public string Alias { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user