Compare commits

...

8 Commits

Author SHA1 Message Date
749a4eb5fa v1.0.4 2026-02-24 11:42:19 +01:00
e514f3af0e Merge pull request 'net10.0-sln-to-slnx' (#2) from net10.0-sln-to-slnx into main
Reviewed-on: #2
2026-02-24 10:39:23 +00:00
68529dbce4 neu report integriert 2026-02-19 19:58:08 +01:00
22bec79bab Merge new changes into net10.0 2026-02-19 17:08:34 +01:00
Adam Gaiswinkler
8b357f5653 PDF-Layout: Glassmorphism-Design mit abgerundeten Karten und Schatten 2026-02-19 16:36:15 +01:00
Adam Gaiswinkler
e7ee313472 feat: implementiert PDF-Generierung mit Hintergrundbild und Dokumentation 2026-02-18 22:43:26 +01:00
Adam Gaiswinkler
1bff5ebbbd feat(halloffame): implement image upload and enhance module functionality
- Added image upload system (JPG/PNG, max 5MB) with live preview and removal option
- Fixed Concurrency Exception during deletion (split transactions for reports and entries)
- Optimized card layout: consistent height and height-based truncation for descriptions
- Added sort direction toggle (Ascending/Descending) with arrow icons for Date, Name, and Year
- Refactored HallOfFameService to use streams for Server/Wasm compatibility
- Improved error handling and UI feedback for upload and delete operations
2026-02-10 17:45:48 +01:00
7d11271d7c Update dll references to use net10.0 paths and use dotnet pack instead 2026-01-29 22:30:06 +01:00
25 changed files with 1265 additions and 155 deletions

View File

@@ -0,0 +1,301 @@
@using SZUAbsolventenverein.Module.HallOfFame.Services
@using SZUAbsolventenverein.Module.HallOfFame.Models
@using Oqtane.Security
@using Oqtane.Shared
@using Interfaces
@namespace SZUAbsolventenverein.Module.HallOfFame
@inherits ModuleBase
@inject IHallOfFameService HallOfFameService
@inject NavigationManager NavigationManager
@inject IReportUI ReportingComponent
@if (_item == null)
{
<p><em>Loading...</em></p>
}
else
{
<div class="hall-of-fame-details container mt-4">
<div class="card shadow-lg border-0 overflow-hidden" style="border-radius: 20px;">
<div class="row g-0">
<div class="col-lg-5 position-relative bg-light d-flex align-items-center justify-content-center p-4" style="min-height: 400px; background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);">
@if (!string.IsNullOrEmpty(_item.Image))
{
<div class="detail-image-bg" style="background-image: url('@_item.Image');"></div>
<img src="@_item.Image" class="img-fluid rounded-3 shadow position-relative" style="max-height: 450px; z-index: 1; border: 8px solid white; object-fit: cover;" alt="@_item.Name">
}
else
{
<div class="text-muted position-relative" style="z-index: 1;"><i class="oi oi-person" style="font-size: 8rem; opacity: 0.2;"></i></div>
}
</div>
<div class="col-lg-7">
<div class="card-body p-4 p-md-5">
<div class="mb-4">
<nav aria-label="breadcrumb">
<ol class="breadcrumb mb-2">
<li class="breadcrumb-item"><a href="@NavigateUrl()">Hall of Fame</a></li>
<li class="breadcrumb-item active" aria-current="page">Details</li>
</ol>
</nav>
<h1 class="display-4 fw-bold text-dark mb-0">@_item.Name</h1>
<h3 class="text-primary fw-light">Absolvent des Jahrgangs @_item.Year</h3>
</div>
<hr class="my-4" style="width: 100px; height: 3px; background-color: var(--primary); opacity: 1;">
<div class="description-section mb-5">
<h5 class="text-uppercase fw-bold text-muted mb-3" style="letter-spacing: 1px; font-size: 0.9rem;">Werdegang & Erfolge</h5>
@if (_item.IsReported && UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" + RoleNames.Host))
{
<div class="alert alert-danger mb-3 p-3">
<h6 class="mb-2"><i class="oi oi-warning me-2"></i><strong>Meldungen:</strong></h6>
@if (_reports != null && _reports.Any())
{
<ul class="list-group list-group-flush bg-transparent">
@foreach (var report in _reports)
{
<li class="list-group-item bg-transparent d-flex justify-content-between align-items-center border-0 border-bottom">
<div>
<strong>@report.CreatedBy (@report.CreatedOn.ToShortDateString()):</strong><br />
<span>@report.Reason</span>
</div>
<button class="btn btn-sm btn-outline-danger" @onclick="() => DeleteReport(report.HallOfFameReportId)" title="Meldung löschen">
<i class="oi oi-trash"></i>
</button>
</li>
}
</ul>
}
else
{
<p class="mb-0">Keine detaillierten Meldungen gefunden.</p>
}
</div>
}
<div class="lead text-dark mb-4" style="line-height: 1.7; font-size: 1.1rem;">
@foreach (var line in (_item.Description?.Replace("\t", " ").Split('\n') ?? Array.Empty<string>()))
{
<div class="hof-description-line">@line</div>
}
</div>
</div>
<div class="d-flex flex-wrap gap-3 mt-5 no-print">
<button type="button" class="btn btn-primary btn-lg px-4 shadow-sm" @onclick="ShowPdfPreview">
<i class="oi oi-eye me-2"></i> PDF Vorschau
</button>
@if (!string.IsNullOrEmpty(_item.Link))
{
<a href="@_item.Link" target="_blank" class="btn btn-secondary btn-lg px-4 shadow-sm">
<i class="oi oi-external-link me-2"></i> Webseite besuchen
</a>
}
<NavLink class="btn btn-outline-secondary btn-lg px-4" href="@NavigateUrl()">
<i class="oi oi-arrow-left me-2"></i> Zurück
</NavLink>
<div class="ms-auto d-flex gap-2">
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" + RoleNames.Host))
{
<button class="btn btn-danger btn-lg px-4" @onclick="DeleteEntry">
<i class="oi oi-trash me-2"></i> Löschen
</button>
}
@if (ReportingComponent != null)
{
<DynamicComponent Type="@ReportingComponent.ReportType" Parameters="@_parameters"/>
}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@if (_showPdfModal)
{
<div class="modal fade show" style="display: block; background: rgba(0,0,0,0.6); z-index: 1050;" tabindex="-1">
<div class="modal-dialog modal-xl modal-dialog-centered" style="max-width: 90vw; height: 90vh;">
<div class="modal-content" style="height: 90vh;">
<div class="modal-header">
<h5 class="modal-title"><i class="oi oi-document me-2"></i> PDF Vorschau</h5>
<button type="button" class="btn-close" @onclick="ClosePdfPreview"></button>
</div>
<div class="modal-body p-0" style="flex: 1; overflow: hidden;">
<iframe src="@_pdfPreviewUrl" style="width: 100%; height: 100%; border: none;"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" @onclick="ClosePdfPreview">Schließen</button>
<button type="button" class="btn btn-primary" @onclick="DownloadPdf">
<i class="oi oi-data-transfer-download me-2"></i> Herunterladen
</button>
</div>
</div>
</div>
</div>
}
}
<style>
.detail-image-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-size: cover;
background-position: center;
filter: blur(30px) brightness(1.1);
opacity: 0.15;
z-index: 0;
}
.hall-of-fame-details .card {
background: #ffffff;
}
.hall-of-fame-details .breadcrumb-item a {
text-decoration: none;
color: var(--primary);
}
@@media print {
.no-print, header, footer, nav, .app-sidebar, .breadcrumb, .btn-link, .app-navbar {
display: none !important;
}
/* Reset containers for printing */
html, body, .app-viewport, .app-main, .app-container, main, .hall-of-fame-details, .container {
height: auto !important;
min-height: auto !important;
overflow: visible !important;
position: static !important;
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
}
body {
background-color: white !important;
}
.card {
box-shadow: none !important;
border: none !important;
position: relative !important;
display: block !important; /* Force block instead of flex for better printing */
}
.row {
display: block !important; /* Stack columns vertically for print if needed, or keeping it but ensuring it doesn't clip */
}
.col-lg-5, .col-lg-7 {
width: 100% !important;
display: block !important;
float: none !important;
}
.hall-of-fame-details {
margin-top: 0 !important;
}
img {
max-width: 100% !important;
page-break-inside: avoid;
}
}
</style>
@code {
public override string Actions => "Details";
private HallOfFame _item;
private int _id;
private List<HallOfFameReport> _reports;
private Dictionary<string, object> _parameters = new Dictionary<string, object>();
private bool _showPdfModal = false;
private string _pdfPreviewUrl = "";
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
try
{
_id = Int32.Parse(PageState.QueryString["id"]);
_item = await HallOfFameService.GetHallOfFameAsync(_id, ModuleState.ModuleId);
if (_item != null && ReportingComponent != null)
{
_parameters = ReportingComponent.ConstructParameterList(_item, RenderModeBoundary);
}
if (_item != null && _item.IsReported && UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" + RoleNames.Host))
{
_reports = await HallOfFameService.GetHallOfFameReportsAsync(_id, ModuleState.ModuleId);
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading HallOfFame {HallOfFameId} {Error}", _id, ex.Message);
AddModuleMessage("Fehler beim Laden der Details.", MessageType.Error);
}
}
private void ShowPdfPreview()
{
_pdfPreviewUrl = $"/api/HallOfFamePdf?moduleid={ModuleState.ModuleId}";
_showPdfModal = true;
}
private void ClosePdfPreview()
{
_showPdfModal = false;
_pdfPreviewUrl = "";
}
private async Task DownloadPdf()
{
var url = $"/api/HallOfFamePdf?moduleid={ModuleState.ModuleId}&download=true";
await JSRuntime.InvokeVoidAsync("eval", $"var a = document.createElement('a'); a.href = '{url}'; a.download = 'HallOfFame.pdf'; document.body.appendChild(a); a.click(); document.body.removeChild(a);");
}
private async Task DeleteEntry()
{
try
{
await HallOfFameService.DeleteHallOfFameAsync(_item.HallOfFameId, ModuleState.ModuleId);
NavigationManager.NavigateTo(NavigateUrl());
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting HallOfFame {Error}", ex.Message);
AddModuleMessage("Fehler beim Löschen des Eintrags.", MessageType.Error);
}
}
private async Task DeleteReport(int reportId)
{
try
{
await HallOfFameService.DeleteHallOfFameReportAsync(reportId, ModuleState.ModuleId);
AddModuleMessage("Meldung gelöscht.", MessageType.Success);
await LoadData();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting Report {Error}", ex.Message);
AddModuleMessage("Fehler beim Löschen der Meldung.", MessageType.Error);
}
}
}

View File

@@ -1,6 +1,7 @@
@using Oqtane.Modules.Controls
@using SZUAbsolventenverein.Module.HallOfFame.Services
@using SZUAbsolventenverein.Module.HallOfFame.Models
@using Microsoft.AspNetCore.Components.Forms
@namespace SZUAbsolventenverein.Module.HallOfFame
@inherits ModuleBase
@@ -20,21 +21,47 @@
<div class="row mb-3 align-items-center">
<Label Class="col-sm-3 col-form-label" For="year" HelpText="Jahrgang (z.B. 2020)" ResourceKey="Year">Jahrgang: </Label>
<div class="col-sm-9">
<input id="year" type="number" class="form-control" @bind="@_year" required min="1990" max="2100" />
<input id="year" type="number" class="form-control" @bind="@_year" required min="1900" max="@Int32.MaxValue" />
<div class="invalid-feedback">Bitte gib einen gültigen Jahrgang ein.</div>
</div>
</div>
<div class="row mb-3 align-items-center">
<Label Class="col-sm-3 col-form-label" For="description" HelpText="Kurzbeschreibung / Werdegang" ResourceKey="Description">Beschreibung: </Label>
<div class="col-sm-9">
<textarea id="description" class="form-control" @bind="@_description" required rows="5" maxlength="1500"></textarea>
<textarea id="description" class="form-control" @bind="@_description" required rows="5" maxlength="500"></textarea>
<div class="text-muted small">@(_description?.Length ?? 0) / 500 Zeichen</div>
<div class="invalid-feedback">Bitte gib eine Beschreibung ein.</div>
</div>
</div>
<div class="row mb-3 align-items-center">
<Label Class="col-sm-3 col-form-label" For="image" HelpText="Bild URL (optional)" ResourceKey="Image">Bild URL: </Label>
<div class="row mb-3">
<Label Class="col-sm-3 col-form-label" For="image" HelpText="Porträtfoto hochladen (JPG/PNG)" ResourceKey="Image">Foto: </Label>
<div class="col-sm-9">
<input id="image" class="form-control" @bind="@_image" />
<div class="mb-2">
@if (!string.IsNullOrEmpty(_image))
{
<div class="position-relative d-inline-block">
<img src="@_image" style="max-height: 150px; border-radius: 8px; margin-bottom: 10px; border: 1px solid #ddd;" alt="Vorschau" />
<button type="button" class="btn btn-sm btn-danger" style="position: absolute; top: 5px; right: 5px;" @onclick="RemoveImage" title="Bild entfernen">
<i class="oi oi-x"></i>
</button>
</div>
}
else
{
<div class="bg-light d-flex align-items-center justify-content-center text-muted" style="height: 150px; width: 150px; border: 2px dashed #ddd; border-radius: 8px;">
Kein Bild
</div>
}
</div>
<InputFile OnChange="HandleFileSelected" class="form-control" accept=".jpg,.jpeg,.png" />
<div class="text-muted small mt-1">Nur JPG oder PNG, max. 5 MB.</div>
@if (_uploading)
{
<div class="spinner-border spinner-border-sm text-primary mt-2" role="status">
<span class="visually-hidden">Wird hochgeladen...</span>
</div>
<span class="small text-primary ms-1">Wird hochgeladen...</span>
}
</div>
</div>
<div class="row mb-3 align-items-center">
@@ -52,11 +79,19 @@
</div>
</div>
<div class="mt-4">
<button type="button" class="btn btn-secondary me-2" @onclick="@(() => Save("Draft"))">Als Entwurf speichern</button>
<button type="button" class="btn btn-primary" @onclick="@(() => Save("Published"))">Veröffentlichen</button>
<div class="mt-4 d-flex justify-content-between align-items-center">
<div>
<button type="button" class="btn btn-secondary me-2" @onclick="@(() => Save("Draft"))" disabled="@_uploading">Als Entwurf speichern</button>
<button type="button" class="btn btn-primary" @onclick="@(() => Save("Published"))" disabled="@_uploading">Veröffentlichen</button>
<NavLink class="btn btn-link ms-2" href="@NavigateUrl()">Abbrechen</NavLink>
</div>
@if (PageState.Action == "Edit")
{
<button type="button" class="btn btn-outline-danger" @onclick="DeleteEntry" disabled="@_uploading">
<i class="oi oi-trash me-1"></i> Eintrag löschen
</button>
}
</div>
<br /><br />
@if (PageState.Action == "Edit")
@@ -79,6 +114,7 @@
private ElementReference form;
private bool validated = false;
private bool _uploading = false;
private int _id;
private string _name;
@@ -102,7 +138,6 @@
_id = Int32.Parse(PageState.QueryString["id"]);
HallOfFame HallOfFame = await HallOfFameService.GetHallOfFameAsync(_id, ModuleState.ModuleId);
// Security check: only allow editing own entry
if (HallOfFame != null)
{
if (HallOfFame.UserId != PageState.User.UserId)
@@ -126,11 +161,9 @@
}
else // Add Mode
{
// Check if user already has an entry to prevent duplicates
var existing = await HallOfFameService.GetHallOfFameByUserIdAsync(PageState.User.UserId, ModuleState.ModuleId);
if (existing != null)
{
// Use NavigateUrl with parameters properly (simplified here)
NavigationManager.NavigateTo(EditUrl(existing.HallOfFameId.ToString()));
}
}
@@ -142,6 +175,50 @@
}
}
private async Task HandleFileSelected(InputFileChangeEventArgs e)
{
var file = e.File;
if (file == null) return;
if (file.Size > 5 * 1024 * 1024)
{
AddModuleMessage("Die Datei ist zu groß (max. 5 MB allowed).", MessageType.Warning);
return;
}
try
{
_uploading = true;
using var stream = file.OpenReadStream(5 * 1024 * 1024);
var url = await HallOfFameService.UploadFileAsync(stream, file.Name, ModuleState.ModuleId);
if (!string.IsNullOrEmpty(url))
{
_image = url;
AddModuleMessage("Foto erfolgreich hochgeladen.", MessageType.Success);
}
else
{
AddModuleMessage("Fehler beim Hochladen des Fotos.", MessageType.Error);
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Uploading File {Error}", ex.Message);
AddModuleMessage("Ein technischer Fehler ist beim Upload aufgetreten.", MessageType.Error);
}
finally
{
_uploading = false;
StateHasChanged();
}
}
private void RemoveImage()
{
_image = string.Empty;
StateHasChanged();
}
private async Task Save(string status)
{
try
@@ -156,7 +233,7 @@
{
HallOfFame HallOfFame = new HallOfFame();
HallOfFame.ModuleId = ModuleState.ModuleId;
HallOfFame.UserId = PageState.User.UserId; // Set Owner
HallOfFame.UserId = PageState.User.UserId;
HallOfFame.Name = _name;
HallOfFame.Year = _year;
HallOfFame.Description = _description;
@@ -170,7 +247,6 @@
else
{
HallOfFame HallOfFame = await HallOfFameService.GetHallOfFameAsync(_id, ModuleState.ModuleId);
// Ensure we don't overwrite with invalid user logic, though server checks too
if (HallOfFame.UserId == PageState.User.UserId)
{
HallOfFame.Name = _name;
@@ -197,4 +273,18 @@
AddModuleMessage(Localizer["Message.SaveError"], MessageType.Error);
}
}
private async Task DeleteEntry()
{
try
{
await HallOfFameService.DeleteHallOfFameAsync(_id, ModuleState.ModuleId);
NavigationManager.NavigateTo(NavigateUrl());
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting HallOfFame {Error}", ex.Message);
AddModuleMessage("Fehler beim Löschen des Eintrags.", MessageType.Error);
}
}
}

View File

@@ -1,5 +1,7 @@
@using SZUAbsolventenverein.Module.HallOfFame.Services
@using SZUAbsolventenverein.Module.HallOfFame.Models
@using Oqtane.Security
@using Oqtane.Shared
@namespace SZUAbsolventenverein.Module.HallOfFame
@inherits ModuleBase
@@ -13,30 +15,44 @@
}
else
{
<div class="row mb-4">
<div class="col text-end">
<div class="row mb-4 align-items-center">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text"><i class="oi oi-magnifying-glass"></i></span>
<input type="text" class="form-control" placeholder="Suchen nach Namen oder Begriffen..." @bind="_searchText" @bind:event="oninput" />
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<select class="form-select" @bind="_sortOption">
<option value="CreatedOn">Datum</option>
<option value="Name">Name</option>
<option value="Year">Jahrgang</option>
</select>
<button class="btn btn-outline-secondary" type="button" @onclick="ToggleSortDirection" title="@(_sortAscending ? "Aufsteigend" : "Absteigend")">
<i class="oi @(_sortAscending ? "oi-arrow-top" : "oi-arrow-bottom")"></i>
</button>
</div>
</div>
<div class="col-md-3 text-end">
@if (PageState.User != null)
{
if (_myEntry != null)
{
<ActionLink Action="Edit" Parameters="@($"id=" + _myEntry.HallOfFameId.ToString())" Text="Hall-of-Fame-Eintrag bearbeiten" />
<ActionLink Action="Edit" Parameters="@($"id=" + _myEntry.HallOfFameId.ToString())" Text="Mein Eintrag" />
}
else
{
<ActionLink Action="Add" Text="Neuen Hall-of-Fame-Eintrag erstellen" />
<ActionLink Action="Add" Text="Eintragen" />
}
}
else
{
<p class="text-muted">Einloggen, um einen Eintrag zu erstellen.</p>
}
</div>
</div>
@if (@_HallOfFames.Count != 0)
{
<div class="row">
@foreach (var item in _HallOfFames)
@foreach (var item in FilteredHallOfFames)
{
<div class="col-md-4 mb-3">
<div class="card h-100">
@@ -44,13 +60,35 @@ else
{
<img src="@item.Image" class="card-img-top" alt="@item.Name" style="max-height: 200px; object-fit: cover;">
}
<div class="card-body">
<div class="card-body d-flex flex-column">
<h5 class="card-title">@item.Name (@item.Year)</h5>
<p class="card-text">@item.Description</p>
@if (!string.IsNullOrEmpty(item.Link))
@if (item.IsReported && UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" + RoleNames.Host))
{
<a href="@item.Link" target="_blank" class="btn btn-sm btn-outline-primary">Mehr Infos</a>
<div class="alert alert-danger p-1 mb-2" style="font-size: 0.8rem;">
<i class="oi oi-warning me-1"></i> <strong>Dieser Eintrag wurde gemeldet!</strong>
</div>
}
<div class="hof-description-container" style="
max-height: 150px;
overflow: hidden;
position: relative;
flex-grow: 1;
margin-bottom: 0.5rem;
">
@foreach (var line in (item.Description?.Replace("\t", " ").Split('\n') ?? Array.Empty<string>()))
{
<div class="hof-description-line">@line</div>
}
</div>
<div class="d-flex justify-content-between align-items-center">
<ActionLink Action="Details" Parameters="@($"id=" + item.HallOfFameId.ToString())" Class="btn btn-sm btn-outline-primary" Text="Details ansehen" />
<div>
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" + RoleNames.Host))
{
<button class="btn btn-sm btn-outline-danger me-1" @onclick="@(() => Delete(item.HallOfFameId))" title="Löschen"><i class="oi oi-trash"></i></button>
}
</div>
</div>
</div>
</div>
</div>
@@ -66,7 +104,6 @@ else
}
@code {
public override string RenderMode => RenderModes.Static;
public override List<Resource> Resources => new List<Resource>()
{
@@ -76,12 +113,58 @@ else
List<HallOfFame> _HallOfFames;
HallOfFame _myEntry;
string _searchText = "";
string _sortOption = "CreatedOn";
bool _sortAscending = false;
IEnumerable<HallOfFame> FilteredHallOfFames
{
get
{
var items = _HallOfFames.AsEnumerable();
if (!string.IsNullOrEmpty(_searchText))
{
items = items.Where(i =>
(i.Name?.Contains(_searchText, StringComparison.OrdinalIgnoreCase) ?? false) ||
(i.Description?.Contains(_searchText, StringComparison.OrdinalIgnoreCase) ?? false)
);
}
items = _sortOption switch
{
"Name" => _sortAscending ? items.OrderBy(i => i.Name) : items.OrderByDescending(i => i.Name),
"Year" => _sortAscending ? items.OrderBy(i => i.Year) : items.OrderByDescending(i => i.Year),
"CreatedOn" or _ => _sortAscending ? items.OrderBy(i => i.CreatedOn) : items.OrderByDescending(i => i.CreatedOn)
};
return items;
}
}
private string TruncateDescription(string description)
{
if (string.IsNullOrEmpty(description)) return "";
const int maxLength = 150;
if (description.Length <= maxLength) return description;
return description.Substring(0, maxLength).TrimEnd() + "...";
}
private void ToggleSortDirection()
{
_sortAscending = !_sortAscending;
}
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
try
{
_HallOfFames = await HallOfFameService.GetHallOfFamesAsync(ModuleState.ModuleId);
var allEntries = await HallOfFameService.GetHallOfFamesAsync(ModuleState.ModuleId);
_HallOfFames = allEntries.Where(i => i.Status == "Published").ToList();
if (PageState.User != null)
{
@@ -94,4 +177,19 @@ else
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
}
}
private async Task Delete(int hallOfFameId)
{
try
{
await HallOfFameService.DeleteHallOfFameAsync(hallOfFameId, ModuleState.ModuleId);
AddModuleMessage("Eintrag wurde gelöscht.", MessageType.Success);
await LoadData();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting HallOfFame {Error}", ex.Message);
AddModuleMessage("Fehler beim Löschen des Eintrags.", MessageType.Error);
}
}
}

View File

@@ -9,9 +9,9 @@ namespace SZUAbsolventenverein.Module.HallOfFame
{
Name = "HallOfFame",
Description = "The Hall of Fame module displays selected individuals or achievements within the CMS. Entries are shown online, can be exported as a PDF, and are only published with user consen.",
Version = "1.0.0",
Version = "1.0.4",
ServerManagerType = "SZUAbsolventenverein.Module.HallOfFame.Manager.HallOfFameManager, SZUAbsolventenverein.Module.HallOfFame.Server.Oqtane",
ReleaseVersions = "1.0.0",
ReleaseVersions = "1.0.0,1.0.2,1.0.3,1.0.4",
Dependencies = "SZUAbsolventenverein.Module.HallOfFame.Shared.Oqtane",
PackageName = "SZUAbsolventenverein.Module.HallOfFame"
};

View File

@@ -13,6 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Interfaces" Version="0.0.0-12" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
@@ -25,8 +26,8 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Oqtane.Client"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Client.dll</HintPath></Reference>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll</HintPath></Reference>
<Reference Include="Oqtane.Client"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Client.dll</HintPath></Reference>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
</ItemGroup>
<PropertyGroup>

View File

@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net;
using System.Threading.Tasks;
using Oqtane.Services;
using Oqtane.Shared;
using System.Text.Json;
namespace SZUAbsolventenverein.Module.HallOfFame.Services
{
@@ -18,8 +20,11 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
Task<Models.HallOfFame> AddHallOfFameAsync(Models.HallOfFame HallOfFame);
Task<Models.HallOfFame> UpdateHallOfFameAsync(Models.HallOfFame HallOfFame);
Task DeleteHallOfFameAsync(int HallOfFameId, int ModuleId);
Task ReportAsync(int HallOfFameId, int ModuleId, string reason);
Task<List<Models.HallOfFameReport>> GetHallOfFameReportsAsync(int HallOfFameId, int ModuleId);
Task DeleteHallOfFameReportAsync(int HallOfFameReportId, int ModuleId);
Task<string> UploadFileAsync(System.IO.Stream stream, string fileName, int ModuleId);
}
public class HallOfFameService : ServiceBase, IHallOfFameService
@@ -30,8 +35,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
public async Task<List<Models.HallOfFame>> GetHallOfFamesAsync(int ModuleId)
{
List<Models.HallOfFame> HallOfFames = await GetJsonAsync<List<Models.HallOfFame>>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Models.HallOfFame>().ToList());
return HallOfFames.OrderBy(item => item.Name).ToList();
return await GetJsonAsync<List<Models.HallOfFame>>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Models.HallOfFame>().ToList());
}
public async Task<Models.HallOfFame> GetHallOfFameAsync(int HallOfFameId, int ModuleId)
@@ -58,5 +62,38 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
{
await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{HallOfFameId}/{ModuleId}", EntityNames.Module, ModuleId));
}
public async Task ReportAsync(int HallOfFameId, int ModuleId, string reason)
{
await PutAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/report/{HallOfFameId}?reason={WebUtility.UrlEncode(reason)}", EntityNames.Module, ModuleId));
}
public async Task<List<Models.HallOfFameReport>> GetHallOfFameReportsAsync(int HallOfFameId, int ModuleId)
{
return await GetJsonAsync<List<Models.HallOfFameReport>>(CreateAuthorizationPolicyUrl($"{Apiurl}/reports/{HallOfFameId}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Models.HallOfFameReport>().ToList());
}
public async Task DeleteHallOfFameReportAsync(int HallOfFameReportId, int ModuleId)
{
await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/report/{HallOfFameReportId}/{ModuleId}", EntityNames.Module, ModuleId));
}
public async Task<string> UploadFileAsync(System.IO.Stream stream, string fileName, int ModuleId)
{
var uri = CreateAuthorizationPolicyUrl($"{Apiurl}/upload", EntityNames.Module, ModuleId);
using var content = new MultipartFormDataContent();
var fileContent = new StreamContent(stream);
fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
content.Add(fileContent, "file", fileName);
var response = await GetHttpClient().PostAsync(uri, content);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<Dictionary<string, string>>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
return result["url"];
}
return null;
}
}
}

View File

@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$projectname$</id>
<version>1.0.1</version>
<version>1.0.4</version>
<authors>SZUAbsolventenverein</authors>
<owners>SZUAbsolventenverein</owners>
<title>HallOfFame</title>
@@ -17,7 +17,7 @@
<summary></summary>
<packageTypes>
<packageType name="Dependency" />
<packageType name="Oqtane.Framework" version="6.2.0" />
<packageType name="Oqtane.Framework" version="10.0.3" />
</packageTypes>
</metadata>
<files>
@@ -27,11 +27,11 @@
<file src="..\Server\bin\Release\$targetframework$\$ProjectName$.Server.Oqtane.pdb" target="lib\$targetframework$" />
<file src="..\Shared\bin\Release\$targetframework$\$ProjectName$.Shared.Oqtane.dll" target="lib\$targetframework$" />
<file src="..\Shared\bin\Release\$targetframework$\$ProjectName$.Shared.Oqtane.pdb" target="lib\$targetframework$" />
<file src="..\Server\obj\Release\net9.0\staticwebassets\msbuild.$ProjectName$.Microsoft.AspNetCore.StaticWebAssetEndpoints.props" target="build\Microsoft.AspNetCore.StaticWebAssetEndpoints.props" />
<file src="..\Server\obj\Release\net9.0\staticwebassets\msbuild.$ProjectName$.Microsoft.AspNetCore.StaticWebAssets.props" target="build\Microsoft.AspNetCore.StaticWebAssets.props" />
<file src="..\Server\obj\Release\net9.0\staticwebassets\msbuild.build.$ProjectName$.props" target="build\$ProjectName$.props" />
<file src="..\Server\obj\Release\net9.0\staticwebassets\msbuild.buildMultiTargeting.$ProjectName$.props" target="buildMultiTargeting\$ProjectName$.props" />
<file src="..\Server\obj\Release\net9.0\staticwebassets\msbuild.buildTransitive.$ProjectName$.props" target="buildTransitive\$ProjectName$.props" />
<file src="..\Server\obj\Release\net10.0\staticwebassets\msbuild.$ProjectName$.Microsoft.AspNetCore.StaticWebAssetEndpoints.props" target="build\Microsoft.AspNetCore.StaticWebAssetEndpoints.props" />
<file src="..\Server\obj\Release\net10.0\staticwebassets\msbuild.$ProjectName$.Microsoft.AspNetCore.StaticWebAssets.props" target="build\Microsoft.AspNetCore.StaticWebAssets.props" />
<file src="..\Server\obj\Release\net10.0\staticwebassets\msbuild.build.$ProjectName$.props" target="build\$ProjectName$.props" />
<file src="..\Server\obj\Release\net10.0\staticwebassets\msbuild.buildMultiTargeting.$ProjectName$.props" target="buildMultiTargeting\$ProjectName$.props" />
<file src="..\Server\obj\Release\net10.0\staticwebassets\msbuild.buildTransitive.$ProjectName$.props" target="buildTransitive\$ProjectName$.props" />
<file src="..\Server\wwwroot\**\*.*" target="staticwebassets" />
<file src="icon.png" target="" />
</files>

View File

@@ -9,5 +9,5 @@ cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName.Server.Oqtane.dll" "../
cp -f "../Server/bin/Debug/$TargetFramework/$ProjectName.Server.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName.Shared.Oqtane.dll" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
cp -f "../Shared/bin/Debug/$TargetFramework/$ProjectName.Shared.Oqtane.pdb" "../../oqtane.framework/Oqtane.Server/bin/Debug/$TargetFramework/"
mkdir -p "../../oqtane.framework/Oqtane.Server/wwwroot/_content/$ProjectName/"
cp -rf "../Server/wwwroot/"* "../../oqtane.framework/Oqtane.Server/wwwroot/_content/$ProjectName/"

View File

@@ -3,5 +3,5 @@ ProjectName=$2
find . -name *.nupkg -delete
dotnet run --project ../../fixProps/FixProps/FixProps.csproj
nuget pack $ProjectName.nuspec -Properties "targetframework=${TargetFramework};ProjectName=${ProjectName}"
dotnet pack $ProjectName.nuspec "/p:targetframework=${TargetFramework};ProjectName=${ProjectName}"
cp -f *.nupkg ../../oqtane.framework/Oqtane.Server/Packages/

85
QuestPDF_Integration.md Normal file
View File

@@ -0,0 +1,85 @@
# PDF-Design: Modern Glassmorphism Layout
## Design-Konzept
Das PDF-Layout verwendet ein **modernes Glassmorphism-Design** — inspiriert von Apple Keynote-Slides und Behance Case Studies. Jede Seite besteht aus einem vollflächigen Hintergrundbild mit zwei **schwebenden Glass-Cards** (Titel oben, Beschreibung unten).
## Aufbau (Layer-System)
```
┌─────────────────────────────────┐
│ LAYER 1: Vollbild-Hintergrund │ ← Edge-to-Edge Bild
│ │
│ LAYER 2: Oberes Dark-Overlay │ ← Kontrast für Titelkarte
│ ┌───────────────────────────┐ │
│ │ ███ TITELKARTE (Glass) ███ │ ← Name + Jahr
│ └───────────────────────────┘ │
│ │
│ (Bild sichtbar) │
│ │
│ LAYER 3: Unteres Dark-Overlay │ ← Kontrast für Beschreibung
│ ┌───────────────────────────┐ │
│ │ ███ BESCHREIBUNG (Glass) ██ │ ← Bio-Text
│ └───────────────────────────┘ │
└─────────────────────────────────┘
```
## Glassmorphism-Technik (Build-Safe)
Jede Karte nutzt die `Decoration` API mit mehrfachen `.Before()` Layern:
```csharp
.Decoration(card =>
{
// 1. Weicher Schatten (sehr dezent, außen)
card.Before()
.Border(4f).BorderColor("#18000000")
.CornerRadius(20);
// 2. Lichtkante (innerer Glas-Rim)
card.Before()
.Border(1f).BorderColor("#44FFFFFF")
.CornerRadius(20);
// 3. Halbtransparenter dunkler Hintergrund
card.Before()
.Background("#C8181828")
.CornerRadius(20);
// 4. Inhalt (Text)
card.Content()
.PaddingVertical(28)
.PaddingHorizontal(36)
.Column(inner => { /* ... */ });
});
```
## Design-Details
| Element | Stil |
|---------|------|
| **Name** | 36pt, ExtraBold, Uppercase, Weiß, Letter-Spacing 0.5 |
| **Trennlinie** | 1.5pt, halbtransparent Weiß (#55FFFFFF) |
| **Jahrgang** | 15pt, gedämpft (#CCFFFFFF), Letter-Spacing 1.5 |
| **Beschreibungs-Header** | 14pt, SemiBold, gedämpft, Letter-Spacing 2 |
| **Beschreibungstext** | 11pt, 1.5 Zeilenhöhe, leicht gedämpft (#E8FFFFFF) |
| **Titelkarte Radius** | 20px |
| **Beschreibungskarte Radius** | 16px |
| **Overlay oben** | 220pt Höhe, #99000000 |
| **Overlay unten** | 280pt Höhe, #AA000000 |
| **Seiten-Padding** | 40pt rundum |
## Vorteile dieses Ansatzes
-**100% Build-Safe**: Keine SkiaSharp-Abhängigkeit, rein QuestPDF Fluent API
-**Stabil auf jedem Bild**: Kontrast-Overlays garantieren Lesbarkeit
-**Visuell hochwertig**: Glasskarte + Tiefe + Typografie-Hierarchie
-**Strukturell unverändert**: Name oben, Beschreibung unten, Bild vollflächig
## Build-Befehl
```bash
dotnet build Server/SZUAbsolventenverein.Module.HallOfFame.Server.csproj
```
Letzte erfolgreiche Kompilierung: 19. Februar 2026 — 0 Fehler, 0 Warnungen.

View File

@@ -1,3 +1,4 @@
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic;
@@ -10,6 +11,8 @@ using SZUAbsolventenverein.Module.HallOfFame.Services;
using Oqtane.Controllers;
using System.Net;
using System.Threading.Tasks;
using System.IO;
using Microsoft.AspNetCore.Hosting;
namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
{
@@ -17,10 +20,12 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
public class HallOfFameController : ModuleControllerBase
{
private readonly IHallOfFameService _HallOfFameService;
private readonly IWebHostEnvironment _environment;
public HallOfFameController(IHallOfFameService HallOfFameService, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor)
public HallOfFameController(IHallOfFameService HallOfFameService, ILogManager logger, IHttpContextAccessor accessor, IWebHostEnvironment environment) : base(logger, accessor)
{
_HallOfFameService = HallOfFameService;
_environment = environment;
}
// GET: api/<controller>?moduleid=x
@@ -33,9 +38,10 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
{
var list = await _HallOfFameService.GetHallOfFamesAsync(ModuleId);
// Filter: Show only Published unless user has Edit permissions (simplified check for now, can be expanded)
// For now, let's filter in memory or service. The requirement says: "Hauptseite zeigt nur Published".
// We will filter here.
if (User.IsInRole(RoleNames.Admin) || User.IsInRole(RoleNames.Host))
{
return list;
}
return list.Where(item => item.Status == "Published");
}
else
@@ -138,7 +144,47 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
return HallOfFame;
}
// DELETE api/<controller>/5
// PUT api/<controller>/report/5
[HttpPut("report/{id}")]
[Authorize(Policy = PolicyNames.ViewModule)]
public async Task Report(int id, [FromQuery] string reason)
{
Models.HallOfFame HallOfFame = await _HallOfFameService.GetHallOfFameAsync(id, -1);
if (HallOfFame != null && IsAuthorizedEntityId(EntityNames.Module, HallOfFame.ModuleId))
{
await _HallOfFameService.ReportAsync(id, HallOfFame.ModuleId, reason);
}
}
// GET api/<controller>/reports/5?moduleid=x
[HttpGet("reports/{id}")]
[Authorize(Policy = PolicyNames.EditModule)]
public async Task<IEnumerable<Models.HallOfFameReport>> GetReports(int id, string moduleid)
{
int ModuleId;
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
{
return await _HallOfFameService.GetHallOfFameReportsAsync(id, ModuleId);
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized HallOfFame GetReports Attempt {HallOfFameId} {ModuleId}", id, moduleid);
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return null;
}
}
// DELETE api/<controller>/report/5/x
[HttpDelete("report/{id}/{moduleid}")]
[Authorize(Policy = PolicyNames.EditModule)]
public async Task DeleteReport(int id, int moduleid)
{
if (IsAuthorizedEntityId(EntityNames.Module, moduleid))
{
await _HallOfFameService.DeleteHallOfFameReportAsync(id, moduleid);
}
}
[HttpDelete("{id}/{moduleid}")]
[Authorize(Policy = PolicyNames.EditModule)]
public async Task Delete(int id, int moduleid)
@@ -154,5 +200,33 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
}
}
[HttpPost("upload")]
[Authorize(Policy = PolicyNames.EditModule)]
public async Task<IActionResult> Upload(IFormFile file)
{
if (file == null || file.Length == 0) return BadRequest("Keine Datei ausgewählt.");
var extension = Path.GetExtension(file.FileName).ToLower();
if (extension != ".jpg" && extension != ".jpeg" && extension != ".png")
{
return BadRequest("Nur JPG und PNG Dateien sind erlaubt.");
}
var folder = Path.Combine(_environment.WebRootPath, "Content", "HallOfFame");
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
var fileName = Guid.NewGuid().ToString() + extension;
var path = Path.Combine(folder, fileName);
using (var stream = new FileStream(path, FileMode.Create))
{
await file.CopyToAsync(stream);
}
return Ok(new { url = "/Content/HallOfFame/" + fileName });
}
}
}

View File

@@ -0,0 +1,188 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting;
using Oqtane.Shared;
using Oqtane.Enums;
using Oqtane.Infrastructure;
using Oqtane.Controllers;
using SZUAbsolventenverein.Module.HallOfFame.Services;
using System.Linq;
using System.Threading.Tasks;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
{
[Route(ControllerRoutes.ApiRoute)]
public class HallOfFamePdfController : ModuleControllerBase
{
private readonly IHallOfFameService _hallOfFameService;
private readonly IWebHostEnvironment _environment;
public HallOfFamePdfController(IHallOfFameService hallOfFameService, ILogManager logger, IHttpContextAccessor accessor, IWebHostEnvironment environment) : base(logger, accessor)
{
_hallOfFameService = hallOfFameService;
_environment = environment;
}
// GET: api/<controller>?moduleid=x&download=true/false
[HttpGet]
[Authorize(Policy = PolicyNames.ViewModule)]
public async Task<IActionResult> Get(string moduleid, bool download = false)
{
int ModuleId;
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
{
var entries = await _hallOfFameService.GetHallOfFamesAsync(ModuleId);
var publishedEntries = entries.Where(e => e.Status == "Published").ToList();
var document = Document.Create(container =>
{
foreach (var entry in publishedEntries)
{
// Bild laden falls vorhanden
byte[] imageBytes = null;
if (!string.IsNullOrEmpty(entry.Image))
{
try
{
var fullImagePath = System.IO.Path.Combine(
_environment.WebRootPath, entry.Image.TrimStart('/'));
if (System.IO.File.Exists(fullImagePath))
imageBytes = System.IO.File.ReadAllBytes(fullImagePath);
}
catch { }
}
container.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(0);
page.Content().Layers(layers =>
{
// ── Hintergrundbild (Edge-to-Edge) ──
if (imageBytes != null)
{
layers.Layer().Image(imageBytes).FitUnproportionally();
}
else
{
layers.Layer().Background("#1A1A2E");
}
// ── Inhalt (PrimaryLayer) ──
layers.PrimaryLayer()
.Padding(40)
.Column(column =>
{
// ═══ TITELKARTE (oben) ═══
column.Item()
.Border(5f).BorderColor("#20000000")
.CornerRadius(24)
.Border(3f).BorderColor("#33000000")
.CornerRadius(22)
.Border(1f).BorderColor("#44FFFFFF")
.Background("#CC1A1A2E")
.CornerRadius(20)
.PaddingVertical(28)
.PaddingHorizontal(36)
.Column(inner =>
{
// Name: groß, dominant, Uppercase
inner.Item()
.PaddingBottom(6)
.Text(entry.Name.ToUpper())
.FontSize(36)
.ExtraBold()
.FontColor(Colors.White)
.LetterSpacing(0.5f);
// Trennlinie
inner.Item()
.PaddingVertical(8)
.Height(1.5f)
.Background("#55FFFFFF");
// Jahr: sekundär, elegant
inner.Item()
.PaddingTop(4)
.Text($"Jahrgang {entry.Year}")
.FontSize(15)
.FontColor("#CCFFFFFF")
.LetterSpacing(1.5f);
});
// ═══ BESCHREIBUNGSKARTE (unten) ═══
var description = entry.Description ?? "";
var sections = description.Split('\n')
.Select(s => s.Trim())
.Where(s => !string.IsNullOrEmpty(s))
.ToArray();
column.Item().ExtendVertical().AlignBottom()
.Border(5f).BorderColor("#20000000")
.CornerRadius(20)
.Border(3f).BorderColor("#33000000")
.CornerRadius(18)
.Border(1f).BorderColor("#33FFFFFF")
.Background("#CC1A1A2E")
.CornerRadius(16)
.PaddingVertical(24)
.PaddingHorizontal(32)
.Column(descColumn =>
{
if (sections.Length > 0)
{
// Überschrift
descColumn.Item()
.PaddingBottom(12)
.Text("Beschreibung")
.FontSize(14)
.SemiBold()
.FontColor("#B0FFFFFF")
.LetterSpacing(2f);
// Trennlinie
descColumn.Item()
.PaddingBottom(14)
.Height(1f)
.Background("#33FFFFFF");
// Text
foreach (var line in sections)
{
descColumn.Item()
.PaddingBottom(8)
.Text(line)
.FontSize(11)
.FontColor("#E8FFFFFF")
.LineHeight(1.5f);
}
}
});
});
});
});
}
});
byte[] pdfBytes = document.GeneratePdf();
if (download)
{
return File(pdfBytes, "application/pdf", "HallOfFame.pdf");
}
// Inline: PDF wird im Browser angezeigt (Vorschau)
return File(pdfBytes, "application/pdf");
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized HallOfFame PDF Get Attempt {ModuleId}", moduleid);
return Forbid();
}
}
}
}

View File

@@ -1,83 +0,0 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations;
using SZUAbsolventenverein.Module.HallOfFame.Migrations.EntityBuilders;
using SZUAbsolventenverein.Module.HallOfFame.Repository;
namespace SZUAbsolventenverein.Module.HallOfFame.Migrations
{
[DbContext(typeof(HallOfFameContext))]
[Migration("SZUAbsolventenverein.Module.HallOfFame.01.00.00.01")]
public class AddHallOfFameColumns : MultiDatabaseMigration
{
public AddHallOfFameColumns(IDatabase database) : base(database)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
var entityBuilder = new HallOfFameEntityBuilder(migrationBuilder, ActiveDatabase);
migrationBuilder.AddColumn<int>(
name: "Year",
table: "SZUAbsolventenvereinHallOfFame",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "Description",
table: "SZUAbsolventenvereinHallOfFame",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Image",
table: "SZUAbsolventenvereinHallOfFame",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Link",
table: "SZUAbsolventenvereinHallOfFame",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Status",
table: "SZUAbsolventenvereinHallOfFame",
maxLength: 50,
nullable: true);
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "SZUAbsolventenvereinHallOfFame",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Year",
table: "SZUAbsolventenvereinHallOfFame");
migrationBuilder.DropColumn(
name: "Description",
table: "SZUAbsolventenvereinHallOfFame");
migrationBuilder.DropColumn(
name: "Image",
table: "SZUAbsolventenvereinHallOfFame");
migrationBuilder.DropColumn(
name: "Link",
table: "SZUAbsolventenvereinHallOfFame");
migrationBuilder.DropColumn(
name: "Status",
table: "SZUAbsolventenvereinHallOfFame");
migrationBuilder.DropColumn(
name: "UserId",
table: "SZUAbsolventenvereinHallOfFame");
}
}
}

View File

@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations;
using SZUAbsolventenverein.Module.HallOfFame.Migrations.EntityBuilders;
using SZUAbsolventenverein.Module.HallOfFame.Repository;
namespace SZUAbsolventenverein.Module.HallOfFame.Migrations
{
[DbContext(typeof(HallOfFameContext))]
[Migration("SZUAbsolventenverein.Module.HallOfFame.01.00.00.03")]
public class AddReportTable : MultiDatabaseMigration
{
public AddReportTable(IDatabase database) : base(database)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
var entityBuilder = new HallOfFameReportEntityBuilder(migrationBuilder, ActiveDatabase);
entityBuilder.Create();
}
protected override void Down(MigrationBuilder migrationBuilder)
{
var entityBuilder = new HallOfFameReportEntityBuilder(migrationBuilder, ActiveDatabase);
entityBuilder.Drop();
}
}
}

View File

@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations;
using Oqtane.Migrations.EntityBuilders;
namespace SZUAbsolventenverein.Module.HallOfFame.Migrations.EntityBuilders
{
public class HallOfFameReportEntityBuilder : AuditableBaseEntityBuilder<HallOfFameReportEntityBuilder>
{
private const string _entityTableName = "SZUAbsolventenvereinHallOfFameReport";
private readonly PrimaryKey<HallOfFameReportEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinHallOfFameReport", x => x.HallOfFameReportId);
private readonly ForeignKey<HallOfFameReportEntityBuilder> _hallOfFameForeignKey = new("FK_SZUAbsolventenvereinHallOfFameReport_HallOfFame", x => x.HallOfFameId, "SZUAbsolventenvereinHallOfFame", "HallOfFameId", ReferentialAction.Cascade);
public HallOfFameReportEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
{
EntityTableName = _entityTableName;
PrimaryKey = _primaryKey;
ForeignKeys.Add(_hallOfFameForeignKey);
}
protected override HallOfFameReportEntityBuilder BuildTable(ColumnsBuilder table)
{
HallOfFameReportId = AddAutoIncrementColumn(table, "HallOfFameReportId");
HallOfFameId = AddIntegerColumn(table, "HallOfFameId");
Reason = AddMaxStringColumn(table, "Reason");
AddAuditableColumns(table);
return this;
}
public OperationBuilder<AddColumnOperation> HallOfFameReportId { get; set; }
public OperationBuilder<AddColumnOperation> HallOfFameId { get; set; }
public OperationBuilder<AddColumnOperation> Reason { get; set; }
}
}

View File

@@ -10,6 +10,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
public class HallOfFameContext : DBContextBase, ITransientService, IMultiDatabase
{
public virtual DbSet<Models.HallOfFame> HallOfFame { get; set; }
public virtual DbSet<Models.HallOfFameReport> HallOfFameReport { get; set; }
public HallOfFameContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
{
@@ -21,6 +22,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
base.OnModelCreating(builder);
builder.Entity<Models.HallOfFame>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinHallOfFame"));
builder.Entity<Models.HallOfFameReport>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinHallOfFameReport"));
}
}
}

View File

@@ -13,6 +13,11 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
Models.HallOfFame AddHallOfFame(Models.HallOfFame HallOfFame);
Models.HallOfFame UpdateHallOfFame(Models.HallOfFame HallOfFame);
void DeleteHallOfFame(int HallOfFameId);
IEnumerable<Models.HallOfFameReport> GetHallOfFameReports(int HallOfFameId);
Models.HallOfFameReport GetHallOfFameReport(int HallOfFameReportId);
Models.HallOfFameReport AddHallOfFameReport(Models.HallOfFameReport HallOfFameReport);
void DeleteHallOfFameReport(int HallOfFameReportId);
}
public class HallOfFameRepository : IHallOfFameRepository, ITransientService
@@ -27,7 +32,14 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
public IEnumerable<Models.HallOfFame> GetHallOfFames(int ModuleId)
{
using var db = _factory.CreateDbContext();
return db.HallOfFame.Where(item => item.ModuleId == ModuleId).ToList();
var items = db.HallOfFame.Where(item => item.ModuleId == ModuleId)
.OrderByDescending(item => item.CreatedOn)
.ToList();
foreach (var item in items)
{
item.Description = item.Description?.Replace("\t", " ");
}
return items;
}
public Models.HallOfFame GetHallOfFame(int HallOfFameId)
@@ -38,19 +50,28 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
public Models.HallOfFame GetHallOfFame(int HallOfFameId, bool tracking)
{
using var db = _factory.CreateDbContext();
Models.HallOfFame item;
if (tracking)
{
return db.HallOfFame.Find(HallOfFameId);
item = db.HallOfFame.Find(HallOfFameId);
}
else
{
return db.HallOfFame.AsNoTracking().FirstOrDefault(item => item.HallOfFameId == HallOfFameId);
item = db.HallOfFame.AsNoTracking().FirstOrDefault(i => i.HallOfFameId == HallOfFameId);
}
if (item != null)
{
item.Description = item.Description?.Replace("\t", " ");
}
return item;
}
public Models.HallOfFame AddHallOfFame(Models.HallOfFame HallOfFame)
{
using var db = _factory.CreateDbContext();
HallOfFame.Description = HallOfFame.Description?.Replace("\t", " ");
HallOfFame.Image ??= "";
HallOfFame.Link ??= "";
db.HallOfFame.Add(HallOfFame);
db.SaveChanges();
return HallOfFame;
@@ -59,6 +80,9 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
public Models.HallOfFame UpdateHallOfFame(Models.HallOfFame HallOfFame)
{
using var db = _factory.CreateDbContext();
HallOfFame.Description = HallOfFame.Description?.Replace("\t", " ");
HallOfFame.Image ??= "";
HallOfFame.Link ??= "";
db.Entry(HallOfFame).State = EntityState.Modified;
db.SaveChanges();
return HallOfFame;
@@ -66,10 +90,64 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
public void DeleteHallOfFame(int HallOfFameId)
{
using var db = _factory.CreateDbContext();
Models.HallOfFame HallOfFame = db.HallOfFame.Find(HallOfFameId);
db.HallOfFame.Remove(HallOfFame);
// First transaction: Delete all associated reports
using (var db = _factory.CreateDbContext())
{
var reports = db.HallOfFameReport.Where(item => item.HallOfFameId == HallOfFameId).ToList();
if (reports.Any())
{
db.HallOfFameReport.RemoveRange(reports);
db.SaveChanges();
}
}
// Second transaction: Delete the HallOfFame entry itself
using (var db = _factory.CreateDbContext())
{
var hallOfFame = db.HallOfFame.Find(HallOfFameId);
if (hallOfFame != null)
{
db.HallOfFame.Remove(hallOfFame);
db.SaveChanges();
}
}
}
public IEnumerable<Models.HallOfFameReport> GetHallOfFameReports(int HallOfFameId)
{
using var db = _factory.CreateDbContext();
return db.HallOfFameReport.Where(item => item.HallOfFameId == HallOfFameId)
.OrderByDescending(item => item.CreatedOn)
.ToList();
}
public Models.HallOfFameReport GetHallOfFameReport(int HallOfFameReportId)
{
using var db = _factory.CreateDbContext();
return db.HallOfFameReport.Find(HallOfFameReportId);
}
public Models.HallOfFameReport AddHallOfFameReport(Models.HallOfFameReport HallOfFameReport)
{
using var db = _factory.CreateDbContext();
db.HallOfFameReport.Add(HallOfFameReport);
db.SaveChanges();
return HallOfFameReport;
}
public void DeleteHallOfFameReport(int HallOfFameReportId)
{
using var db = _factory.CreateDbContext();
// Clear any tracked entities to avoid conflicts
db.ChangeTracker.Clear();
Models.HallOfFameReport HallOfFameReport = db.HallOfFameReport.Find(HallOfFameReportId);
if (HallOfFameReport != null)
{
db.HallOfFameReport.Remove(HallOfFameReport);
db.SaveChanges();
}
}
}
}

View File

@@ -23,6 +23,7 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
<PackageReference Include="QuestPDF" Version="2026.2.1" />
</ItemGroup>
<ItemGroup>
@@ -31,7 +32,19 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Oqtane.Server"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Server.dll</HintPath></Reference>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll</HintPath></Reference>
<Reference Include="Oqtane.Server"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Server.dll</HintPath></Reference>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
</ItemGroup>
<!-- Copy QuestPDF and Module DLLs to Oqtane.Server so they are available at runtime -->
<Target Name="CopyQuestPdfToOqtane" AfterTargets="Build">
<Message Importance="high" Text="Deploying QuestPDF and Module DLLs to Oqtane bin..." />
<Copy SourceFiles="$(OutputPath)QuestPDF.dll" DestinationFolder="$(ProjectDir)..\..\oqtane.framework\Oqtane.Server\bin\$(Configuration)\$(TargetFramework)\" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(OutputPath)SZUAbsolventenverein.Module.HallOfFame.Server.Oqtane.dll" DestinationFolder="$(ProjectDir)..\..\oqtane.framework\Oqtane.Server\bin\$(Configuration)\$(TargetFramework)\" SkipUnchangedFiles="false" />
<Copy SourceFiles="$(OutputPath)SZUAbsolventenverein.Module.HallOfFame.Shared.Oqtane.dll" DestinationFolder="$(ProjectDir)..\..\oqtane.framework\Oqtane.Server\bin\$(Configuration)\$(TargetFramework)\" SkipUnchangedFiles="false" />
<ItemGroup>
<QuestPdfNativeFiles Include="$(OutputPath)runtimes\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(QuestPdfNativeFiles)" DestinationFiles="@(QuestPdfNativeFiles->'$(ProjectDir)..\..\oqtane.framework\Oqtane.Server\bin\$(Configuration)\$(TargetFramework)\runtimes\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
</Project>

View File

@@ -2,12 +2,16 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using System.Net.Http;
using Oqtane.Enums;
using Oqtane.Infrastructure;
using Oqtane.Models;
using Oqtane.Security;
using Oqtane.Shared;
using SZUAbsolventenverein.Module.HallOfFame.Repository;
using Microsoft.AspNetCore.Hosting;
using System.IO;
using System;
namespace SZUAbsolventenverein.Module.HallOfFame.Services
{
@@ -18,14 +22,16 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
private readonly ILogManager _logger;
private readonly IHttpContextAccessor _accessor;
private readonly Alias _alias;
private readonly IWebHostEnvironment _environment;
public ServerHallOfFameService(IHallOfFameRepository HallOfFameRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
public ServerHallOfFameService(IHallOfFameRepository HallOfFameRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor, IWebHostEnvironment environment)
{
_HallOfFameRepository = HallOfFameRepository;
_userPermissions = userPermissions;
_logger = logger;
_accessor = accessor;
_alias = tenantManager.GetAlias();
_environment = environment;
}
public Task<List<Models.HallOfFame>> GetHallOfFamesAsync(int ModuleId)
@@ -111,5 +117,104 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
}
return Task.CompletedTask;
}
public Task ReportAsync(int HallOfFameId, int ModuleId, string reason)
{
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
{
var report = new Models.HallOfFameReport
{
HallOfFameId = HallOfFameId,
Reason = reason
};
_HallOfFameRepository.AddHallOfFameReport(report);
var hallOfFame = _HallOfFameRepository.GetHallOfFame(HallOfFameId);
if (hallOfFame != null && !hallOfFame.IsReported)
{
hallOfFame.IsReported = true;
_HallOfFameRepository.UpdateHallOfFame(hallOfFame);
}
_logger.Log(LogLevel.Information, this, LogFunction.Update, "HallOfFame Reported {HallOfFameId}", HallOfFameId);
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized HallOfFame Report Attempt {HallOfFameId} {ModuleId}", HallOfFameId, ModuleId);
}
return Task.CompletedTask;
}
public Task<List<Models.HallOfFameReport>> GetHallOfFameReportsAsync(int HallOfFameId, int ModuleId)
{
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
{
return Task.FromResult(_HallOfFameRepository.GetHallOfFameReports(HallOfFameId).ToList());
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized HallOfFame Get Reports Attempt {HallOfFameId} {ModuleId}", HallOfFameId, ModuleId);
return null;
}
}
public Task DeleteHallOfFameReportAsync(int HallOfFameReportId, int ModuleId)
{
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
{
var report = _HallOfFameRepository.GetHallOfFameReport(HallOfFameReportId);
if (report != null)
{
int hallOfFameId = report.HallOfFameId;
_HallOfFameRepository.DeleteHallOfFameReport(HallOfFameReportId);
// Check if there are any reports left for this entry
var remainingReports = _HallOfFameRepository.GetHallOfFameReports(hallOfFameId);
if (!remainingReports.Any())
{
var hallOfFame = _HallOfFameRepository.GetHallOfFame(hallOfFameId);
if (hallOfFame != null)
{
hallOfFame.IsReported = false;
_HallOfFameRepository.UpdateHallOfFame(hallOfFame);
}
}
}
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "HallOfFame Report Deleted {HallOfFameReportId}", HallOfFameReportId);
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized HallOfFame Delete Report Attempt {HallOfFameReportId} {ModuleId}", HallOfFameReportId, ModuleId);
}
return Task.CompletedTask;
}
public async Task<string> UploadFileAsync(Stream stream, string fileName, int ModuleId)
{
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
{
var extension = Path.GetExtension(fileName).ToLower();
if (extension != ".jpg" && extension != ".jpeg" && extension != ".png")
{
return null;
}
var folder = Path.Combine(_environment.WebRootPath, "Content", "HallOfFame");
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
var newFileName = Guid.NewGuid().ToString() + extension;
var path = Path.Combine(folder, newFileName);
using (var fileStream = new FileStream(path, FileMode.Create))
{
await stream.CopyToAsync(fileStream);
}
return "/Content/HallOfFame/" + newFileName;
}
return null;
}
}
}

View File

@@ -21,6 +21,9 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Startup
public void ConfigureServices(IServiceCollection services)
{
// QuestPDF Lizenz konfigurieren
QuestPDF.Settings.License = QuestPDF.Infrastructure.LicenseType.Community;
services.AddTransient<IHallOfFameService, ServerHallOfFameService>();
services.AddDbContextFactory<HallOfFameContext>(opt => { }, ServiceLifetime.Transient);
}

View File

@@ -1 +1,17 @@
/* Module Custom Styles */
.hof-description-container {
min-height: 120px;
/* Adjust this value based on the desired card size */
margin-bottom: 1rem;
}
.hof-description-line {
display: block;
padding-left: 1.1em;
text-indent: -1.1em;
margin-bottom: 0.2rem;
line-height: 1.5;
word-break: break-word;
text-align: left;
}

View File

@@ -1,12 +1,13 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Interfaces;
using Oqtane.Models;
namespace SZUAbsolventenverein.Module.HallOfFame.Models
{
[Table("SZUAbsolventenvereinHallOfFame")]
public class HallOfFame : IAuditable
public class HallOfFame : IAuditable, IReportable
{
[Key]
public int HallOfFameId { get; set; }
@@ -19,8 +20,21 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Models
public string Link { get; set; }
public string Status { get; set; } // "Draft" or "Published"
public int UserId { get; set; } // Owner
[NotMapped]
public bool IsReported { get; set; }
[NotMapped]
public string ReportReason { get; set; }
[NotMapped]
public string ModuleName => "";
[NotMapped]
public int ModuleID => ModuleId;
[NotMapped]
public int EntityID => HallOfFameId;
[NotMapped]
public string UserName => Name;
public string CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public string ModifiedBy { get; set; }

View File

@@ -0,0 +1,21 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Oqtane.Models;
namespace SZUAbsolventenverein.Module.HallOfFame.Models
{
[Table("SZUAbsolventenvereinHallOfFameReport")]
public class HallOfFameReport : IAuditable
{
[Key]
public int HallOfFameReportId { get; set; }
public int HallOfFameId { get; set; }
public string Reason { get; set; }
public string CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public string ModifiedBy { get; set; }
public DateTime ModifiedOn { get; set; }
}
}

View File

@@ -12,11 +12,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Interfaces" Version="0.0.0-12" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net9.0\Oqtane.Shared.dll</HintPath></Reference>
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
</ItemGroup>
</Project>