Add administrative zone.

This commit is contained in:
2020-05-24 02:41:23 +01:00
parent c8ea0ea711
commit be87adddc4
8 changed files with 242 additions and 4 deletions

View File

@@ -5,6 +5,20 @@ namespace Marechai.Database.Models
{ {
public class ApplicationRole : IdentityRole public class ApplicationRole : IdentityRole
{ {
public const string ROLE_UBERADMIN = "UberAdmin";
public const string ROLE_WRITER = "Writer";
public const string ROLE_PROOFREADER = "Proofreader";
public const string ROLE_TRANSLATOR = "Translator";
public const string ROLE_SUPERTRANSLATOR = "SuperTranslator";
public const string ROLE_COLLABORATOR = "Collaborator";
public const string ROLE_CURATOR = "Curator";
public const string ROLE_PHYSICALCURATOR = "PhysicalCurator";
public const string ROLE_TECHNICIAN = "Technician";
public const string ROLE_SUPERTECHNICIAN = "SuperTechnician";
public const string ROLE_ADMIN = "Administrator";
public const string ROLE_NONE = "NormalUser";
public ApplicationRole() => Created = DateTime.UtcNow; public ApplicationRole() => Created = DateTime.UtcNow;
public ApplicationRole(string name) : base(name) public ApplicationRole(string name) : base(name)

View File

@@ -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.1036</Version> <Version>3.0.99.1041</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>
@@ -39,4 +39,9 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Update="Resources\**\*.es.resx" /> <EmbeddedResource Update="Resources\**\*.es.resx" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Update="Pages\Admin\Index.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
</Project> </Project>

View File

@@ -0,0 +1,40 @@
@{
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : Index.razor
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Index of administration area
//
// --[ 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"
@inherits OwningComponentBase<AdminService>
@inject IStringLocalizer<AdminService> L
@attribute [Authorize(Roles = "UberAdmin, Admin")]
<h3>@L["Administration area"]</h3>
<p>@L["Welcome to the administration area. Act with care!"]</p>

View File

@@ -0,0 +1,133 @@
<?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="Loading..." xml:space="preserve">
<value>Cargando...</value>
<comment>Loading message</comment>
</data>
<data name="Administration area" xml:space="preserve">
<value>Área de administración</value>
<comment>Administration area</comment>
</data>
<data name="Welcome to the administration area. Act with care!" xml:space="preserve">
<value>Bienvenido/a al área de administración. ¡Actúa con cuidado!</value>
<comment>Welcome message.</comment>
</data>
</root>

View File

@@ -158,4 +158,8 @@
<value>Consolas</value> <value>Consolas</value>
<comment>Videogame consoles</comment> <comment>Videogame consoles</comment>
</data> </data>
<data name="Admin area" xml:space="preserve">
<value>Administración</value>
<comment>Administration area</comment>
</data>
</root> </root>

View File

@@ -0,0 +1,34 @@
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Filename : AdminService.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ Description ] ----------------------------------------------------------
//
// Administration service
//
// --[ 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
*******************************************************************************/
namespace Marechai.Services
{
public class AdminService { }
}

View File

@@ -46,6 +46,7 @@ namespace Marechai.Services
services.AddScoped<ComputersService>(); services.AddScoped<ComputersService>();
services.AddScoped<ConsolesService>(); services.AddScoped<ConsolesService>();
services.AddScoped<MachinesService>(); services.AddScoped<MachinesService>();
services.AddScoped<AdminService>();
} }
} }
} }

View File

@@ -29,17 +29,24 @@
<span class="fa fa-gamepad" aria-hidden="true"></span>&nbsp;@L["Consoles"] <span class="fa fa-gamepad" aria-hidden="true"></span>&nbsp;@L["Consoles"]
</NavLink> </NavLink>
</li> </li>
<AuthorizeView Roles="UberAdmin, Admin">
<li class="nav-item px-3">
<NavLink class="nav-link" href="admin">
<span class="fa fa-tools" aria-hidden="true"></span>&nbsp;@L["Admin area"]
</NavLink>
</li>
</AuthorizeView>
</ul> </ul>
</div> </div>
@code { @code {
private bool collapseNavMenu = true; private bool _collapseNavMenu = true;
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; private string NavMenuCssClass => _collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu() private void ToggleNavMenu()
{ {
collapseNavMenu = !collapseNavMenu; _collapseNavMenu = !_collapseNavMenu;
} }
} }