Updated the proostekrant to work properly again.
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
@page "/seizoenen"
|
||||
@attribute [Authorize(Policy = "Editor")]
|
||||
@inject SeasonService SeizoenSvc
|
||||
@inject ArticleService Artikelen
|
||||
@inject LatexService Latex
|
||||
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Af
|
||||
|
||||
<PageTitle>Seizoenen — ProostenKrant</PageTitle>
|
||||
|
||||
<h1 class="page-heading">Seizoenen & drukwerk</h1>
|
||||
<p class="page-intro">Per seizoen wordt een editie van de krant gedrukt. Publiceer artikelen en druk daarna de editie.</p>
|
||||
|
||||
@if (_melding is not null)
|
||||
{
|
||||
<p class="alert alert-success">
|
||||
@_melding
|
||||
@if (_nieuwPdf is not null)
|
||||
{
|
||||
<text> <a href="/edities/@_nieuwPdf">Download de krant →</a></text>
|
||||
}
|
||||
</p>
|
||||
}
|
||||
@if (_fout is not null)
|
||||
{
|
||||
<div class="alert alert-error">
|
||||
<p>@_fout</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="season-grid">
|
||||
@foreach (var seizoen in _seizoenInfo)
|
||||
{
|
||||
<section class="season-card seizoen-@seizoen.Season.CssKey">
|
||||
<div class="season-card-head">
|
||||
<h2>@seizoen.Season.Name @seizoen.Season.StartDate.Year</h2>
|
||||
@if (seizoen.IsHuidig)
|
||||
{
|
||||
<span class="tag">lopende editie</span>
|
||||
}
|
||||
</div>
|
||||
<p class="muted">
|
||||
@Krant.DutchShortDate(seizoen.Season.StartDate) — @Krant.DutchShortDate(seizoen.Season.EndDate)
|
||||
</p>
|
||||
<ul class="season-stats">
|
||||
<li><strong>@seizoen.Gepubliceerd</strong> gepubliceerd</li>
|
||||
<li><strong>@seizoen.Klad</strong> klad</li>
|
||||
</ul>
|
||||
<div class="form-actions">
|
||||
<form method="post" action="/api/genereer-pdf" class="inline-form">
|
||||
<input type="hidden" name="SeizoenId" value="@seizoen.Season.Id" />
|
||||
<input type="hidden" name="__RequestVerificationToken" value="@_afToken" />
|
||||
<button type="submit" class="btn btn-primary">Druk deze editie</button>
|
||||
</form>
|
||||
<a class="btn" href="/seizoenen/@seizoen.Season.Id">Artikelen bekijken</a>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
<h2 class="section-heading">Gedrukte edities</h2>
|
||||
@if (_edities.Count > 0)
|
||||
{
|
||||
<table class="krant-tabel">
|
||||
<thead>
|
||||
<tr><th>Editie</th><th>Datum</th><th>Grootte</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var editie in _edities)
|
||||
{
|
||||
<tr>
|
||||
<td>@editie.DisplayName</td>
|
||||
<td>@Krant.DutchShortDate(editie.Date)</td>
|
||||
<td>@(editie.SizeBytes / 1024) kB</td>
|
||||
<td><a class="btn" href="/edities/@editie.FileName">Download PDF</a></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted">Er werd nog geen editie gedrukt.</p>
|
||||
}
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromForm(FormName = "genereer-seizoen")]
|
||||
private GenereerInput Input { get; set; } = new();
|
||||
|
||||
private sealed class GenereerInput
|
||||
{
|
||||
public int SeasonId { get; set; }
|
||||
}
|
||||
private List<(Season Season, int Gepubliceerd, int Klad, bool IsHuidig)> _seizoenInfo = new();
|
||||
private List<Edition> _edities = new();
|
||||
private string? _melding;
|
||||
private string? _fout;
|
||||
private string? _nieuwPdf;
|
||||
|
||||
private string? _afToken;
|
||||
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_afToken = Af.GetAndStoreTokens(HttpContext).RequestToken;
|
||||
var seasons = await SeizoenSvc.GetAllAsync();
|
||||
var alle = await Artikelen.GetAllAsync();
|
||||
_seizoenInfo = seasons.Select(s =>
|
||||
{
|
||||
var vanS = alle.Where(a => a.SeasonId == s.Id).ToList();
|
||||
return (s, vanS.Count(a => a.Status == "published"), vanS.Count(a => a.Status == "draft"),
|
||||
s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now);
|
||||
}).ToList();
|
||||
_edities = Latex.ListEditions();
|
||||
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;
|
||||
query.TryGetValue("pdf", out var pdf);
|
||||
_nieuwPdf = pdf;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user