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">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>3.0.99.1045</Version>
|
||||
<Version>3.0.99.1047</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
@{
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Index.cshtml
|
||||
// Filename : Companies.razor
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Admin view index
|
||||
// List of companies
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -29,75 +29,86 @@
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
}
|
||||
@model IEnumerable<Marechai.Areas.Admin.Models.CompanyViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Companies (Admin)";
|
||||
@page "/admin/companies"
|
||||
@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">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Name)
|
||||
@L["Name"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Founded)
|
||||
@L["Founded"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Status)
|
||||
@L["Status"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Country)
|
||||
@L["Country"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SoldView)
|
||||
@L["Sold"]
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.SoldTo)
|
||||
@L["Sold to"]
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
@foreach (var item in _companies)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Name)
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Founded)
|
||||
@($"{item.Founded:d}")
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Status)
|
||||
@item.Status
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Country)
|
||||
@item.Country
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SoldView)
|
||||
@item.SoldView
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.SoldTo)
|
||||
@item.SoldTo
|
||||
</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>
|
||||
<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<CompanyViewModel> _companies;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_companies = await Service.GetCompaniesAsync();
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,12 @@
|
||||
<h3>@L["Administration area"]</h3>
|
||||
<p>@L["Welcome to the administration area. Act with care!"]</p>
|
||||
<ul>
|
||||
<authorizeview Roles="UberAdmin">
|
||||
<AuthorizeView Roles="UberAdmin">
|
||||
<li>
|
||||
<a href="/admin/browser_tests">@L["Browser tests"]</a>
|
||||
</li>
|
||||
</authorizeview>
|
||||
</AuthorizeView>
|
||||
<li>
|
||||
<a href="/admin/companies">@L["Companies"]</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -134,4 +134,8 @@
|
||||
<value>Pruebas de navegadores</value>
|
||||
<comment>Browser tests.</comment>
|
||||
</data>
|
||||
<data name="Companies" xml:space="preserve">
|
||||
<value>Compañías</value>
|
||||
<comment>Companies.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -118,6 +118,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Companies" xml:space="preserve">
|
||||
<value>Compañías</value>
|
||||
<comment>Companies</comment>
|
||||
</data>
|
||||
<data name="Loading..." xml:space="preserve">
|
||||
<value>Cargando...</value>
|
||||
<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>
|
||||
<comment>Companies with {0}, a single character, as the start of the name</comment>
|
||||
</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>
|
||||
@@ -57,7 +57,9 @@ namespace Marechai.Services
|
||||
LastLogo = c.
|
||||
Logos.OrderByDescending(l => l.Year).
|
||||
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();
|
||||
|
||||
public Task<Company> GetCompanyAsync(int id) => _context.Companies.FirstOrDefaultAsync(c => c.Id == id);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Marechai.Database;
|
||||
|
||||
namespace Marechai.ViewModels
|
||||
{
|
||||
@@ -7,5 +8,17 @@ namespace Marechai.ViewModels
|
||||
public int Id { get; set; }
|
||||
public Guid? LastLogo { 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