mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move news 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.1061</Version>
|
<Version>3.0.99.1062</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>
|
||||||
@@ -70,6 +70,9 @@
|
|||||||
<Content Update="Pages\Admin\People.razor">
|
<Content Update="Pages\Admin\People.razor">
|
||||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Update="Pages\Admin\News.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" />
|
||||||
|
|||||||
@@ -68,6 +68,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/admin/people">@L["People"]</a>
|
<a href="/admin/people">@L["People"]</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/admin/news">@L["News"]</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
@{
|
@{
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
// MARECHAI: Master repository of computing history artifacts information
|
// MARECHAI: Master repository of computing history artifacts information
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Filename : Index.cshtml
|
// Filename : News.razor
|
||||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
//
|
//
|
||||||
// --[ Description ] ----------------------------------------------------------
|
// --[ Description ] ----------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Admin view index
|
// List of news
|
||||||
//
|
//
|
||||||
// --[ License ] --------------------------------------------------------------
|
// --[ License ] --------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -29,46 +29,63 @@
|
|||||||
// Copyright © 2003-2020 Natalia Portillo
|
// Copyright © 2003-2020 Natalia Portillo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
}
|
}
|
||||||
@model IEnumerable<Marechai.Database.Models.News>
|
|
||||||
|
|
||||||
@{
|
@page "/admin/news"
|
||||||
ViewData["Title"] = "News (Admin)";
|
@using Marechai.Database.Models
|
||||||
|
@inherits OwningComponentBase<NewsService>
|
||||||
|
@inject IStringLocalizer<NewsService> L
|
||||||
|
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||||
|
<h3>@L["News"]</h3>
|
||||||
|
@if (_news is null)
|
||||||
|
{
|
||||||
|
<p>@L["Loading..."]</p>
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
<h2>News</h2>
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Date)
|
@L["Date"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.Type)
|
@L["Type"]
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayNameFor(model => model.AddedId)
|
@L["Affected ID"]
|
||||||
</th>
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var item in Model)
|
@foreach (var item in _news)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Date)
|
@item.Timestamp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Type)
|
@item.Type
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.AddedId)
|
@item.AffectedId
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<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<NewsViewModel> _news;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_news = await Service.GetAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -190,4 +190,8 @@
|
|||||||
<value>Gente</value>
|
<value>Gente</value>
|
||||||
<comment>People.</comment>
|
<comment>People.</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="News" xml:space="preserve">
|
||||||
|
<value>Noticias</value>
|
||||||
|
<comment>News.</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -154,4 +154,20 @@
|
|||||||
<value>Videoconsola actualizada en la colección</value>
|
<value>Videoconsola actualizada en la colección</value>
|
||||||
<comment>Updated console in collection</comment>
|
<comment>Updated console in collection</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Loading..." xml:space="preserve">
|
||||||
|
<value>Cargando...</value>
|
||||||
|
<comment>Loading...</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Date" xml:space="preserve">
|
||||||
|
<value>Noticias</value>
|
||||||
|
<comment>News</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Type" xml:space="preserve">
|
||||||
|
<value>Tipo</value>
|
||||||
|
<comment>Type</comment>
|
||||||
|
</data>
|
||||||
|
<data name="Affected ID" xml:space="preserve">
|
||||||
|
<value>ID afectado</value>
|
||||||
|
<comment>Affected ID</comment>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -30,9 +30,11 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Marechai.Database;
|
using Marechai.Database;
|
||||||
using Marechai.Database.Models;
|
using Marechai.Database.Models;
|
||||||
using Marechai.ViewModels;
|
using Marechai.ViewModels;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
namespace Marechai.Services
|
namespace Marechai.Services
|
||||||
@@ -48,6 +50,12 @@ namespace Marechai.Services
|
|||||||
_l = localizer;
|
_l = localizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<NewsViewModel>> GetAsync() => await _context.News.OrderByDescending(n => n.Date).
|
||||||
|
Select(n => new NewsViewModel
|
||||||
|
{
|
||||||
|
Id = n.Id, Timestamp = n.Date, Type = n.Type, AffectedId = n.AddedId
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
public List<NewsViewModel> GetNews()
|
public List<NewsViewModel> GetNews()
|
||||||
{
|
{
|
||||||
List<NewsViewModel> news = new List<NewsViewModel>();
|
List<NewsViewModel> news = new List<NewsViewModel>();
|
||||||
|
|||||||
@@ -29,11 +29,14 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Marechai.Database;
|
||||||
|
|
||||||
namespace Marechai.ViewModels
|
namespace Marechai.ViewModels
|
||||||
{
|
{
|
||||||
public sealed class NewsViewModel
|
public sealed class NewsViewModel : BaseViewModel<int>
|
||||||
{
|
{
|
||||||
|
public NewsViewModel() { }
|
||||||
|
|
||||||
public NewsViewModel(int affectedId, string text, DateTime timestamp, string controller, string itemName)
|
public NewsViewModel(int affectedId, string text, DateTime timestamp, string controller, string itemName)
|
||||||
{
|
{
|
||||||
AffectedId = affectedId;
|
AffectedId = affectedId;
|
||||||
@@ -43,10 +46,11 @@ namespace Marechai.ViewModels
|
|||||||
ItemName = itemName;
|
ItemName = itemName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AffectedId { get; }
|
public NewsType Type { get; set; }
|
||||||
|
public int AffectedId { get; set; }
|
||||||
public string Controller { get; }
|
public string Controller { get; }
|
||||||
public string ItemName { get; }
|
public string ItemName { get; }
|
||||||
public string Text { get; }
|
public string Text { get; }
|
||||||
public DateTime Timestamp { get; }
|
public DateTime Timestamp { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user