Updated the proostekrant to work properly again.
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
@page "/dashboard"
|
||||
@attribute [Authorize(Policy = "Editor")]
|
||||
@inject AuthenticationStateProvider AuthStateProvider
|
||||
@inject ArticleService Artikelen
|
||||
@inject SeasonService Seizoenen
|
||||
@inject LatexService Latex
|
||||
@inject UserService Gebruikers
|
||||
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Af
|
||||
|
||||
<PageTitle>Dashboard — ProostenKrant</PageTitle>
|
||||
|
||||
<h1 class="page-heading">Dashboard redactie</h1>
|
||||
<p class="page-intro">Welkom, @_editorNaam. Overzicht van de krant en sneltoetsen voor de redactie.</p>
|
||||
|
||||
@if (_melding is not null)
|
||||
{
|
||||
<p class="alert alert-success">@_melding</p>
|
||||
}
|
||||
@if (_fout is not null)
|
||||
{
|
||||
<div class="alert alert-error">
|
||||
<p>@_fout</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<span class="stat-number">@_drafts</span>
|
||||
<span class="stat-label">Kladartikelen</span>
|
||||
<a href="/artikelen?status=draft" class="stat-link">Bekijken →</a>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-number">@_gepubliceerd</span>
|
||||
<span class="stat-label">Gepubliceerd</span>
|
||||
<a href="/artikelen?status=published" class="stat-link">Bekijken →</a>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-number">@_gebruikers.Count</span>
|
||||
<span class="stat-label">Familieleden</span>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-number">@_edities.Count</span>
|
||||
<span class="stat-label">Gedrukte edities</span>
|
||||
<a href="/archief" class="stat-link">Archief →</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-columns">
|
||||
<section class="dashboard-main">
|
||||
<h2 class="section-heading">Huidige editie</h2>
|
||||
@if (_huidigSeizoen is not null)
|
||||
{
|
||||
<div class="season-card seizoen-@_huidigSeizoen.CssKey">
|
||||
<h3>@_huidigSeizoen.Name @DateTime.Now.Year</h3>
|
||||
<p class="muted">
|
||||
Van @Krant.DutchShortDate(_huidigSeizoen.StartDate) t/m @Krant.DutchShortDate(_huidigSeizoen.EndDate).
|
||||
@(_seizoenDrafts.Count) klad, @(_seizoenPublished.Count) gepubliceerd.
|
||||
</p>
|
||||
<div class="form-actions">
|
||||
<form method="post" action="/api/genereer-pdf" class="inline-form">
|
||||
<input type="hidden" name="SeizoenId" value="@_huidigSeizoen.Id" />
|
||||
<input type="hidden" name="__RequestVerificationToken" value="@_afToken" />
|
||||
<button type="submit" class="btn btn-primary">Druk de @_huidigSeizoen.Name-editie</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted">Er is geen lopend seizoen gedefinieerd.</p>
|
||||
}
|
||||
|
||||
<h2 class="section-heading">Laatste artikelen</h2>
|
||||
<table class="krant-tabel">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Titel</th>
|
||||
<th>Schrijver</th>
|
||||
<th>Seizoen</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var artikel in _recent.Take(8))
|
||||
{
|
||||
<tr>
|
||||
<td><a href="/artikelen/@artikel.Id">@artikel.Title</a></td>
|
||||
<td>@artikel.AuthorName</td>
|
||||
<td>@(artikel.SeasonName ?? "—")</td>
|
||||
<td>
|
||||
<span class="status status-@artikel.Status">@(artikel.Status == "published" ? "gepubliceerd" : "klad")</span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<aside class="dashboard-side">
|
||||
<h2 class="section-heading">Sneltoetsen</h2>
|
||||
<ul class="quick-links">
|
||||
<li><a class="btn" href="/artikelen/nieuw">Nieuw artikel</a></li>
|
||||
<li><a class="btn" href="/seizoenen">Seizoenen & drukwerk</a></li>
|
||||
<li><a class="btn" href="/artikelen?status=draft">Kladartikelen publiceren</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 class="section-heading">Laatste edities</h2>
|
||||
<ul class="edition-list">
|
||||
@foreach (var editie in _edities.Take(5))
|
||||
{
|
||||
<li>
|
||||
<a href="/edities/@editie.FileName" class="edition-link">
|
||||
<span class="edition-name">@editie.DisplayName</span>
|
||||
<span class="edition-size">@(editie.SizeBytes / 1024) kB</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string? _editorNaam;
|
||||
private Season? _huidigSeizoen;
|
||||
private List<Article> _recent = new();
|
||||
private List<Article> _seizoenDrafts = new();
|
||||
private List<Article> _seizoenPublished = new();
|
||||
private List<User> _gebruikers = new();
|
||||
private List<Edition> _edities = new();
|
||||
private int _drafts;
|
||||
private int _gepubliceerd;
|
||||
private string? _melding;
|
||||
private string? _fout;
|
||||
private string? _afToken;
|
||||
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_afToken = Af.GetAndStoreTokens(HttpContext).RequestToken;
|
||||
var state = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
_editorNaam = KrantAuth.EditorName(state.User) ?? "redacteur";
|
||||
_huidigSeizoen = await Seizoenen.GetCurrentAsync();
|
||||
_recent = await Artikelen.GetAllAsync();
|
||||
_gebruikers = await Gebruikers.GetAllAsync();
|
||||
_edities = Latex.ListEditions();
|
||||
_drafts = _recent.Count(a => a.Status == "draft");
|
||||
_gepubliceerd = _recent.Count(a => a.Status == "published");
|
||||
if (_huidigSeizoen is not null)
|
||||
{
|
||||
_seizoenDrafts = _recent.Where(a => a.SeasonId == _huidigSeizoen.Id && a.Status == "draft").ToList();
|
||||
_seizoenPublished = await Artikelen.GetBySeasonAsync(_huidigSeizoen.Id);
|
||||
}
|
||||
LeesMelding();
|
||||
}
|
||||
|
||||
private void LeesMelding()
|
||||
{
|
||||
var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(new Uri(Nav.Uri).Query);
|
||||
query.TryGetValue("melding", out var melding);
|
||||
query.TryGetValue("fout", out var fout);
|
||||
_melding = melding;
|
||||
_fout = fout;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user