mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move admin companis 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.1045</Version>
|
<Version>3.0.99.1047</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>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// MARECHAI: Master repository of computing history artifacts information
|
// MARECHAI: Master repository of computing history artifacts information
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Filename : Index.cshtml
|
// Filename : Companies.razor
|
||||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
//
|
//
|
||||||
// --[ Description ] ----------------------------------------------------------
|
// --[ Description ] ----------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Admin view index
|
// List of companies
|
||||||
//
|
//
|
||||||
// --[ License ] --------------------------------------------------------------
|
// --[ License ] --------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -29,75 +29,86 @@
|
|||||||
// Copyright © 2003-2020 Natalia Portillo
|
// Copyright © 2003-2020 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@model IEnumerable<Marechai.Areas.Admin.Models.CompanyViewModel>
|
|
||||||
|
|
||||||
@{
|
@page "/admin/companies"
|
||||||
ViewData["Title"] = "Companies (Admin)";
|
@inherits OwningComponentBase<CompaniesService>
|
||||||
|
@inject IStringLocalizer<CompaniesService> L
|
||||||
|
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||||
|
<h3>@L["Companies"]</h3>
|
||||||
|
@if (_companies is null)
|
||||||
|
{
|
||||||
|
<p>@L["Loading..."]</p>
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
<h2>Companies</h2>
|
|
||||||
<p>
|
|
||||||
<a asp-action="Create" class="btn btn-primary">
|
|
||||||
Create New
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Name)
|
@L["Name"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Founded)
|
@L["Founded"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Status)
|
@L["Status"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Country)
|
@L["Country"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.SoldView)
|
@L["Sold"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.SoldTo)
|
@L["Sold to"]
|
||||||
</th>
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var item in _companies)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Name)
|
@item.Name
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Founded)
|
@($"{item.Founded:d}")
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Status)
|
@item.Status
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Country)
|
@item.Country
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.SoldView)
|
@item.SoldView
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.SoldTo)
|
@item.SoldTo
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Details" asp-route-id="@item.Id" class="btn btn-primary">
|
<span class="btn btn-primary">
|
||||||
Details
|
@L["Details"]
|
||||||
</a>
|
</span>
|
||||||
<a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-secondary">
|
<span class="btn btn-secondary">
|
||||||
Edit
|
@L["Edit"]
|
||||||
</a>
|
</span>
|
||||||
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">
|
<span class="btn btn-danger">
|
||||||
Delete
|
@L["Delete"]
|
||||||
</a>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
List<CompanyViewModel> _companies;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_companies = await Service.GetCompaniesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,9 +37,12 @@
|
|||||||
<h3>@L["Administration area"]</h3>
|
<h3>@L["Administration area"]</h3>
|
||||||
<p>@L["Welcome to the administration area. Act with care!"]</p>
|
<p>@L["Welcome to the administration area. Act with care!"]</p>
|
||||||
<ul>
|
<ul>
|
||||||
<authorizeview Roles="UberAdmin">
|
<AuthorizeView Roles="UberAdmin">
|
||||||
<li>
|
<li>
|
||||||
<a href="/admin/browser_tests">@L["Browser tests"]</a>
|
<a href="/admin/browser_tests">@L["Browser tests"]</a>
|
||||||
</li>
|
</li>
|
||||||
</authorizeview>
|
</AuthorizeView>
|
||||||
|
<li>
|
||||||
|
<a href="/admin/companies">@L["Companies"]</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -134,4 +134,8 @@
|
|||||||
<value>Pruebas de navegadores</value>
|
<value>Pruebas de navegadores</value>
|
||||||
<comment>Browser tests.</comment>
|
<comment>Browser tests.</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Companies" xml:space="preserve">
|
||||||
|
<value>Compañías</value>
|
||||||
|
<comment>Companies.</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -118,6 +118,10 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<data name="Companies" xml:space="preserve">
|
||||||
|
<value>Compañías</value>
|
||||||
|
<comment>Companies</comment>
|
||||||
|
</data>
|
||||||
<data name="Loading..." xml:space="preserve">
|
<data name="Loading..." xml:space="preserve">
|
||||||
<value>Cargando...</value>
|
<value>Cargando...</value>
|
||||||
<comment>Message that appears while data is being loaded from database</comment>
|
<comment>Message that appears while data is being loaded from database</comment>
|
||||||
@@ -254,4 +258,24 @@
|
|||||||
<value>Compañías cuyo nombre empieza por {0}.</value>
|
<value>Compañías cuyo nombre empieza por {0}.</value>
|
||||||
<comment>Companies with {0}, a single character, as the start of the name</comment>
|
<comment>Companies with {0}, a single character, as the start of the name</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Sold" xml:space="preserve">
|
||||||
|
<value>Vendida</value>
|
||||||
|
<comment>Sold</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Sold to" xml:space="preserve">
|
||||||
|
<value>Vendida a</value>
|
||||||
|
<comment>Sold to</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>
|
</root>
|
||||||
@@ -57,7 +57,9 @@ namespace Marechai.Services
|
|||||||
LastLogo = c.
|
LastLogo = c.
|
||||||
Logos.OrderByDescending(l => l.Year).
|
Logos.OrderByDescending(l => l.Year).
|
||||||
FirstOrDefault().Guid,
|
FirstOrDefault().Guid,
|
||||||
Name = c.Name
|
Name = c.Name, Founded = c.Founded,
|
||||||
|
Sold = c.Sold, SoldTo = c.SoldTo.Name,
|
||||||
|
Country = c.Country.Name, Status = c.Status
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
public Task<Company> GetCompanyAsync(int id) => _context.Companies.FirstOrDefaultAsync(c => c.Id == id);
|
public Task<Company> GetCompanyAsync(int id) => _context.Companies.FirstOrDefaultAsync(c => c.Id == id);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Marechai.Database;
|
||||||
|
|
||||||
namespace Marechai.ViewModels
|
namespace Marechai.ViewModels
|
||||||
{
|
{
|
||||||
@@ -7,5 +8,17 @@ namespace Marechai.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public Guid? LastLogo { get; set; }
|
public Guid? LastLogo { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public DateTime? Founded { get; set; }
|
||||||
|
public DateTime? Sold { get; set; }
|
||||||
|
public string SoldTo { get; set; }
|
||||||
|
public string Country { get; set; }
|
||||||
|
public CompanyStatus Status { get; set; }
|
||||||
|
|
||||||
|
public string SoldView => Status != CompanyStatus.Active && Status != CompanyStatus.Unknown
|
||||||
|
? Sold?.ToShortDateString() ?? "Unknown"
|
||||||
|
: Sold?.ToShortDateString() ?? (SoldTo is null
|
||||||
|
? ""
|
||||||
|
: "Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user