Compare commits
14 Commits
7d11271d7c
...
aa218079db
| Author | SHA1 | Date | |
|---|---|---|---|
| aa218079db | |||
| e249a8c203 | |||
| 6b23a40196 | |||
| 5f2e7a9b56 | |||
| f42c3fe9f2 | |||
| 16cb602d3a | |||
| bfa8ff158c | |||
| 749a4eb5fa | |||
| e514f3af0e | |||
| 68529dbce4 | |||
| 22bec79bab | |||
|
|
8b357f5653 | ||
|
|
e7ee313472 | ||
|
|
1bff5ebbbd |
@@ -0,0 +1,305 @@
|
|||||||
|
@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;">
|
||||||
|
@((MarkupString)(_item.Description ?? ""))
|
||||||
|
</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 string GetPdfApiBase()
|
||||||
|
{
|
||||||
|
var aliasPath = PageState.Alias.Path;
|
||||||
|
var prefix = !string.IsNullOrEmpty(aliasPath) ? $"/{aliasPath}" : "";
|
||||||
|
return $"{prefix}/api/HallOfFamePdf";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowPdfPreview()
|
||||||
|
{
|
||||||
|
_pdfPreviewUrl = $"{GetPdfApiBase()}?moduleid={ModuleState.ModuleId}&id={_id}&authmoduleid={ModuleState.ModuleId}";
|
||||||
|
_showPdfModal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClosePdfPreview()
|
||||||
|
{
|
||||||
|
_showPdfModal = false;
|
||||||
|
_pdfPreviewUrl = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadPdf()
|
||||||
|
{
|
||||||
|
var url = $"{GetPdfApiBase()}?moduleid={ModuleState.ModuleId}&id={_id}&download=true&authmoduleid={ModuleState.ModuleId}";
|
||||||
|
await JSRuntime.InvokeVoidAsync("eval", $"var a = document.createElement('a'); a.href = '{url}'; a.download = 'HallOfFame_{_item?.Name ?? "export"}.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,84 +1,154 @@
|
|||||||
@using Oqtane.Modules.Controls
|
@using Oqtane.Modules.Controls
|
||||||
@using SZUAbsolventenverein.Module.HallOfFame.Services
|
@using SZUAbsolventenverein.Module.HallOfFame.Services
|
||||||
@using SZUAbsolventenverein.Module.HallOfFame.Models
|
@using SZUAbsolventenverein.Module.HallOfFame.Models
|
||||||
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
|
|
||||||
@namespace SZUAbsolventenverein.Module.HallOfFame
|
@namespace SZUAbsolventenverein.Module.HallOfFame
|
||||||
|
@implements IDisposable
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IHallOfFameService HallOfFameService
|
@inject IHallOfFameService HallOfFameService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IStringLocalizer<Edit> Localizer
|
@inject IStringLocalizer<Edit> Localizer
|
||||||
|
@inject ISettingService SettingService
|
||||||
|
|
||||||
<form @ref="form" class="@(validated ? " was-validated" : "needs-validation" )" novalidate>
|
<form @ref="form" class="@(validated ? " was-validated" : "needs-validation" )" novalidate>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-3 align-items-center">
|
<div class="row mb-3 align-items-center">
|
||||||
<Label Class="col-sm-3 col-form-label" For="name" HelpText="Gib deinen Namen ein" ResourceKey="Name">Name: </Label>
|
<div class="col-sm-3">
|
||||||
|
<Label For="name" HelpText="Gib deinen Namen ein" ResourceKey="Name">Name:</Label>
|
||||||
|
</div>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="name" class="form-control" @bind="@_name" required maxlength="120" />
|
<input id="name" class="form-control" @bind="@_name" required maxlength="120" />
|
||||||
<div class="invalid-feedback">Bitte gib einen Namen ein (max. 120 Zeichen).</div>
|
<div class="invalid-feedback">Bitte gib einen Namen ein (max. 120 Zeichen).</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3 align-items-center">
|
<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-3">
|
||||||
|
<Label For="year" HelpText="Gib das Jahr ein, in dem du die Matura abgeschlossen hast (z.B. 2020)"
|
||||||
|
ResourceKey="Year">Jahrgang: </Label>
|
||||||
|
</div>
|
||||||
<div class="col-sm-9">
|
<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 class="invalid-feedback">Bitte gib einen gültigen Jahrgang ein.</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3 align-items-center">
|
<div class="row mb-3">
|
||||||
<Label Class="col-sm-3 col-form-label" For="description" HelpText="Kurzbeschreibung / Werdegang" ResourceKey="Description">Beschreibung: </Label>
|
<div class="col-sm-3">
|
||||||
|
<Label For="description" HelpText="Kurzbeschreibung / Werdegang" ResourceKey="Description">Beschreibung:
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<textarea id="description" class="form-control" @bind="@_description" required rows="5" maxlength="1500"></textarea>
|
@if (_descriptionLoaded)
|
||||||
<div class="invalid-feedback">Bitte gib eine Beschreibung ein.</div>
|
{
|
||||||
|
<RichTextEditor Content="@_description" @ref="@_richTextEditorRef"
|
||||||
|
Placeholder="Beschreibe deinen Werdegang..."></RichTextEditor>
|
||||||
|
<div class="text-muted small mt-1">
|
||||||
|
Aktuell: <strong
|
||||||
|
class="@(_currentCharCount > _charLimit ? "text-danger" : "text-success")">@_currentCharCount</strong>
|
||||||
|
von maximal @_charLimit Zeichen.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3 align-items-center">
|
<div class="row mb-3">
|
||||||
<Label Class="col-sm-3 col-form-label" For="image" HelpText="Bild URL (optional)" ResourceKey="Image">Bild URL: </Label>
|
<div class="col-sm-3">
|
||||||
|
<Label For="image" HelpText="Porträtfoto hochladen (JPG/PNG)" ResourceKey="Image">Foto: </Label>
|
||||||
|
</div>
|
||||||
<div class="col-sm-9">
|
<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>
|
</div>
|
||||||
<div class="row mb-3 align-items-center">
|
<div class="row mb-3 align-items-center">
|
||||||
<Label Class="col-sm-3 col-form-label" For="link" HelpText="Externer Link (optional)" ResourceKey="Link">Link: </Label>
|
<div class="col-sm-3">
|
||||||
|
<Label For="link" HelpText="Externer Link (optional)" ResourceKey="Link">Link: </Label>
|
||||||
|
</div>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input id="link" type="url" class="form-control" @bind="@_link" placeholder="https://" />
|
<input id="link" type="url" class="form-control" @bind="@_link" placeholder="https://" />
|
||||||
<div class="invalid-feedback">Bitte gib eine gültige URL ein (startet mit http:// oder https://).</div>
|
<div class="invalid-feedback">Bitte gib eine gültige URL ein (startet mit http:// oder https://).</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3 align-items-center">
|
<div class="row mb-3 align-items-center">
|
||||||
<Label Class="col-sm-3 col-form-label" For="status" HelpText="Status" ResourceKey="Status">Status: </Label>
|
<div class="col-sm-3">
|
||||||
|
<Label For="status" HelpText="Status" ResourceKey="Status">Status: </Label>
|
||||||
|
</div>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<p>Aktuell: <strong>@(_status ?? "Neu")</strong></p>
|
<p>Aktuell: <strong>@(_status ?? "Neu")</strong></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-4">
|
<div class="mt-4 d-flex justify-content-between align-items-center">
|
||||||
<button type="button" class="btn btn-secondary me-2" @onclick="@(() => Save("Draft"))">Als Entwurf speichern</button>
|
<div>
|
||||||
<button type="button" class="btn btn-primary" @onclick="@(() => Save("Published"))">Veröffentlichen</button>
|
<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>
|
<NavLink class="btn btn-link ms-2" href="@NavigateUrl()">Abbrechen</NavLink>
|
||||||
</div>
|
</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 />
|
<br /><br />
|
||||||
@if (PageState.Action == "Edit")
|
@if (PageState.Action == "Edit")
|
||||||
{
|
{
|
||||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon">
|
||||||
|
</AuditInfo>
|
||||||
}
|
}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View; // Logic handles checking user own entry
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
|
||||||
|
|
||||||
public override string Actions => "Add,Edit";
|
public override string Actions => "Add,Edit";
|
||||||
|
|
||||||
public override string Title => "Hall of Fame Eintrag verwalten";
|
public override string Title => "Hall of Fame Eintrag verwalten";
|
||||||
|
|
||||||
public override List<Resource> Resources => new List<Resource>()
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
{
|
{
|
||||||
new Stylesheet("_content/SZUAbsolventenverein.Module.HallOfFame/Module.css")
|
new Stylesheet("_content/SZUAbsolventenverein.Module.HallOfFame/Module.css")
|
||||||
};
|
};
|
||||||
|
|
||||||
private ElementReference form;
|
private ElementReference form;
|
||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
private bool _uploading = false;
|
||||||
|
private RichTextEditor _richTextEditorRef;
|
||||||
|
private bool _descriptionLoaded = false;
|
||||||
|
|
||||||
private int _id;
|
private int _id;
|
||||||
private string _name;
|
private string _name;
|
||||||
@@ -92,17 +162,50 @@
|
|||||||
private DateTime _createdon;
|
private DateTime _createdon;
|
||||||
private string _modifiedby;
|
private string _modifiedby;
|
||||||
private DateTime _modifiedon;
|
private DateTime _modifiedon;
|
||||||
|
private int _charLimit = 500;
|
||||||
|
private int _currentCharCount = 0;
|
||||||
|
private System.Timers.Timer _timer;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
_timer = new System.Timers.Timer(1000); // 1 sekunde
|
||||||
|
_timer.Elapsed += async (s, e) =>
|
||||||
|
{
|
||||||
|
if (_richTextEditorRef != null && _descriptionLoaded)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var html = await _richTextEditorRef.GetHtml();
|
||||||
|
var plainText = System.Text.RegularExpressions.Regex.Replace(html ?? "", "<.*?>", String.Empty);
|
||||||
|
plainText = System.Net.WebUtility.HtmlDecode(plainText);
|
||||||
|
if (_currentCharCount != plainText.Length)
|
||||||
|
{
|
||||||
|
_currentCharCount = plainText.Length;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { } // Ignore interop errors during disposal
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_timer.Start();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Load character limit setting
|
||||||
|
var settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||||
|
var charLimitStr = SettingService.GetSetting(settings, "CharLimit", "500");
|
||||||
|
if (int.TryParse(charLimitStr, out var parsed) && parsed >= 4 && parsed <= 32000)
|
||||||
|
{
|
||||||
|
_charLimit = parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
_descriptionLoaded = false;
|
||||||
|
|
||||||
if (PageState.Action == "Edit")
|
if (PageState.Action == "Edit")
|
||||||
{
|
{
|
||||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||||
HallOfFame HallOfFame = await HallOfFameService.GetHallOfFameAsync(_id, ModuleState.ModuleId);
|
HallOfFame HallOfFame = await HallOfFameService.GetHallOfFameAsync(_id, ModuleState.ModuleId);
|
||||||
|
|
||||||
// Security check: only allow editing own entry
|
|
||||||
if (HallOfFame != null)
|
if (HallOfFame != null)
|
||||||
{
|
{
|
||||||
if (HallOfFame.UserId != PageState.User.UserId)
|
if (HallOfFame.UserId != PageState.User.UserId)
|
||||||
@@ -126,14 +229,13 @@
|
|||||||
}
|
}
|
||||||
else // Add Mode
|
else // Add Mode
|
||||||
{
|
{
|
||||||
// Check if user already has an entry to prevent duplicates
|
|
||||||
var existing = await HallOfFameService.GetHallOfFameByUserIdAsync(PageState.User.UserId, ModuleState.ModuleId);
|
var existing = await HallOfFameService.GetHallOfFameByUserIdAsync(PageState.User.UserId, ModuleState.ModuleId);
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
// Use NavigateUrl with parameters properly (simplified here)
|
|
||||||
NavigationManager.NavigateTo(EditUrl(existing.HallOfFameId.ToString()));
|
NavigationManager.NavigateTo(EditUrl(existing.HallOfFameId.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_descriptionLoaded = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -142,21 +244,82 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
private async Task Save(string status)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ClearModuleMessage();
|
||||||
validated = true;
|
validated = true;
|
||||||
|
// Get the HTML content from the rich text editor
|
||||||
|
if (_richTextEditorRef != null)
|
||||||
|
{
|
||||||
|
_description = await _richTextEditorRef.GetHtml();
|
||||||
|
}
|
||||||
|
|
||||||
var interop = new Oqtane.UI.Interop(JSRuntime);
|
var interop = new Oqtane.UI.Interop(JSRuntime);
|
||||||
if (await interop.FormValid(form))
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
|
// Custom character limit validation for rich text
|
||||||
|
var plainText = System.Text.RegularExpressions.Regex.Replace(_description ?? "", "<.*?>", String.Empty);
|
||||||
|
plainText = System.Net.WebUtility.HtmlDecode(plainText);
|
||||||
|
if (plainText.Length > _charLimit)
|
||||||
|
{
|
||||||
|
AddModuleMessage($"Fehler: Die Beschreibung ist zu lang (Aktuell {plainText.Length}, Maximal {_charLimit} Zeichen).",
|
||||||
|
MessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_status = status;
|
_status = status;
|
||||||
|
|
||||||
if (PageState.Action == "Add")
|
if (PageState.Action == "Add")
|
||||||
{
|
{
|
||||||
HallOfFame HallOfFame = new HallOfFame();
|
HallOfFame HallOfFame = new HallOfFame();
|
||||||
HallOfFame.ModuleId = ModuleState.ModuleId;
|
HallOfFame.ModuleId = ModuleState.ModuleId;
|
||||||
HallOfFame.UserId = PageState.User.UserId; // Set Owner
|
HallOfFame.UserId = PageState.User.UserId;
|
||||||
HallOfFame.Name = _name;
|
HallOfFame.Name = _name;
|
||||||
HallOfFame.Year = _year;
|
HallOfFame.Year = _year;
|
||||||
HallOfFame.Description = _description;
|
HallOfFame.Description = _description;
|
||||||
@@ -170,7 +333,6 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
HallOfFame HallOfFame = await HallOfFameService.GetHallOfFameAsync(_id, ModuleState.ModuleId);
|
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)
|
if (HallOfFame.UserId == PageState.User.UserId)
|
||||||
{
|
{
|
||||||
HallOfFame.Name = _name;
|
HallOfFame.Name = _name;
|
||||||
@@ -197,4 +359,24 @@
|
|||||||
AddModuleMessage(Localizer["Message.SaveError"], MessageType.Error);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_timer?.Stop();
|
||||||
|
_timer?.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
@using SZUAbsolventenverein.Module.HallOfFame.Services
|
@using SZUAbsolventenverein.Module.HallOfFame.Services
|
||||||
@using SZUAbsolventenverein.Module.HallOfFame.Models
|
@using SZUAbsolventenverein.Module.HallOfFame.Models
|
||||||
|
@using Oqtane.Security
|
||||||
|
@using Oqtane.Shared
|
||||||
|
|
||||||
@namespace SZUAbsolventenverein.Module.HallOfFame
|
@namespace SZUAbsolventenverein.Module.HallOfFame
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IHallOfFameService HallOfFameService
|
@inject IHallOfFameService HallOfFameService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
|
@inject ISettingService SettingService
|
||||||
|
|
||||||
@if (_HallOfFames == null)
|
@if (_HallOfFames == null)
|
||||||
{
|
{
|
||||||
@@ -13,44 +16,105 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="row mb-4">
|
<div class="row mb-4 align-items-center">
|
||||||
<div class="col text-end">
|
<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 (PageState.User != null)
|
||||||
{
|
{
|
||||||
if (_myEntry != 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
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" + RoleNames.Host))
|
||||||
|
{
|
||||||
|
<div class="row mb-3 align-items-center">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="d-flex align-items-center gap-2">
|
||||||
|
<label class="form-label mb-0 text-nowrap" style="font-size: 0.85rem;"><i
|
||||||
|
class="oi oi-pencil me-1"></i>Zeichenlimit:</label>
|
||||||
|
<input type="range" class="form-range flex-grow-1" min="4" max="32000" step="1" value="@_charLimit"
|
||||||
|
@oninput="OnCharLimitChanged" style="min-width: 200px;" />
|
||||||
|
<input type="number" class="form-control form-control-sm" style="width: 90px;" min="4" max="32000"
|
||||||
|
value="@_charLimit" @onchange="OnCharLimitInputChanged" />
|
||||||
|
<button class="btn btn-sm btn-outline-primary" @onclick="SaveCharLimit" title="Zeichenlimit speichern">
|
||||||
|
<i class="oi oi-check"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 text-muted" style="font-size: 0.8rem;">
|
||||||
|
Maximale Zeichen für Beschreibungen
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@if (@_HallOfFames.Count != 0)
|
@if (@_HallOfFames.Count != 0)
|
||||||
{
|
{
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@foreach (var item in _HallOfFames)
|
@foreach (var item in FilteredHallOfFames)
|
||||||
{
|
{
|
||||||
<div class="col-md-4 mb-3">
|
<div class="col-md-4 mb-3">
|
||||||
<div class="card h-100">
|
<div class="card h-100">
|
||||||
@if (!string.IsNullOrEmpty(item.Image))
|
@if (!string.IsNullOrEmpty(item.Image))
|
||||||
{
|
{
|
||||||
<img src="@item.Image" class="card-img-top" alt="@item.Name" style="max-height: 200px; object-fit: cover;">
|
<img src="@item.Image" class="card-img-top" alt="@item.Name"
|
||||||
|
style="height: 300px; object-fit: cover; object-position: top;">
|
||||||
}
|
}
|
||||||
<div class="card-body">
|
<div class="card-body d-flex flex-column">
|
||||||
<h5 class="card-title">@item.Name (@item.Year)</h5>
|
<h5 class="card-title">@item.Name (@item.Year)</h5>
|
||||||
<p class="card-text">@item.Description</p>
|
@if (item.IsReported && UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin + ";" +
|
||||||
@if (!string.IsNullOrEmpty(item.Link))
|
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;
|
||||||
|
">
|
||||||
|
@((MarkupString)(item.Description ?? ""))
|
||||||
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,32 +125,86 @@ else
|
|||||||
{
|
{
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
Es sind noch keine Hall-of-Fame-Einträge veröffentlicht.
|
Es sind noch keine Hall-of-Fame-Einträge veröffentlicht.
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public override string RenderMode => RenderModes.Static;
|
|
||||||
|
|
||||||
public override List<Resource> Resources => new List<Resource>()
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
{
|
{
|
||||||
new Stylesheet("_content/SZUAbsolventenverein.Module.HallOfFame/Module.css"),
|
new Stylesheet("_content/SZUAbsolventenverein.Module.HallOfFame/Module.css"),
|
||||||
new Script("_content/SZUAbsolventenverein.Module.HallOfFame/Module.js")
|
new Script("_content/SZUAbsolventenverein.Module.HallOfFame/Module.js")
|
||||||
};
|
};
|
||||||
|
|
||||||
List<HallOfFame> _HallOfFames;
|
List<HallOfFame> _HallOfFames;
|
||||||
HallOfFame _myEntry;
|
HallOfFame _myEntry;
|
||||||
|
string _searchText = "";
|
||||||
|
string _sortOption = "CreatedOn";
|
||||||
|
bool _sortAscending = false;
|
||||||
|
int _charLimit = 500;
|
||||||
|
|
||||||
|
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()
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadData()
|
||||||
{
|
{
|
||||||
try
|
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)
|
if (PageState.User != null)
|
||||||
{
|
{
|
||||||
_myEntry = await HallOfFameService.GetHallOfFameByUserIdAsync(PageState.User.UserId, ModuleState.ModuleId);
|
_myEntry = await HallOfFameService.GetHallOfFameByUserIdAsync(PageState.User.UserId, ModuleState.ModuleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load character limit setting
|
||||||
|
var settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||||
|
var charLimitStr = SettingService.GetSetting(settings, "CharLimit", "500");
|
||||||
|
if (int.TryParse(charLimitStr, out var parsed) && parsed >= 4 && parsed <= 32000)
|
||||||
|
{
|
||||||
|
_charLimit = parsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -94,4 +212,51 @@ else
|
|||||||
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
|
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCharLimitChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
if (int.TryParse(e.Value?.ToString(), out var val) && val >= 4 && val <= 32000)
|
||||||
|
{
|
||||||
|
_charLimit = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCharLimitInputChanged(ChangeEventArgs e)
|
||||||
|
{
|
||||||
|
if (int.TryParse(e.Value?.ToString(), out var val))
|
||||||
|
{
|
||||||
|
_charLimit = Math.Clamp(val, 4, 32000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveCharLimit()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||||
|
SettingService.SetSetting(settings, "CharLimit", _charLimit.ToString());
|
||||||
|
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
||||||
|
AddModuleMessage($"Zeichenlimit auf {_charLimit} gesetzt.", MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving CharLimit {Error}", ex.Message);
|
||||||
|
AddModuleMessage("Fehler beim Speichern des Zeichenlimits.", 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,9 @@ namespace SZUAbsolventenverein.Module.HallOfFame
|
|||||||
{
|
{
|
||||||
Name = "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.",
|
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.5",
|
||||||
ServerManagerType = "SZUAbsolventenverein.Module.HallOfFame.Manager.HallOfFameManager, SZUAbsolventenverein.Module.HallOfFame.Server.Oqtane",
|
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,1.0.5",
|
||||||
Dependencies = "SZUAbsolventenverein.Module.HallOfFame.Shared.Oqtane",
|
Dependencies = "SZUAbsolventenverein.Module.HallOfFame.Shared.Oqtane",
|
||||||
PackageName = "SZUAbsolventenverein.Module.HallOfFame"
|
PackageName = "SZUAbsolventenverein.Module.HallOfFame"
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
||||||
{
|
{
|
||||||
@@ -18,8 +20,11 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
|||||||
Task<Models.HallOfFame> AddHallOfFameAsync(Models.HallOfFame HallOfFame);
|
Task<Models.HallOfFame> AddHallOfFameAsync(Models.HallOfFame HallOfFame);
|
||||||
|
|
||||||
Task<Models.HallOfFame> UpdateHallOfFameAsync(Models.HallOfFame HallOfFame);
|
Task<Models.HallOfFame> UpdateHallOfFameAsync(Models.HallOfFame HallOfFame);
|
||||||
|
|
||||||
Task DeleteHallOfFameAsync(int HallOfFameId, int ModuleId);
|
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
|
public class HallOfFameService : ServiceBase, IHallOfFameService
|
||||||
@@ -30,8 +35,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
|||||||
|
|
||||||
public async Task<List<Models.HallOfFame>> GetHallOfFamesAsync(int ModuleId)
|
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 await GetJsonAsync<List<Models.HallOfFame>>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), Enumerable.Empty<Models.HallOfFame>().ToList());
|
||||||
return HallOfFames.OrderBy(item => item.Name).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Models.HallOfFame> GetHallOfFameAsync(int HallOfFameId, int ModuleId)
|
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));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>$projectname$</id>
|
<id>$projectname$</id>
|
||||||
<version>1.0.0</version>
|
<version>1.0.5</version>
|
||||||
<authors>SZUAbsolventenverein</authors>
|
<authors>SZUAbsolventenverein</authors>
|
||||||
<owners>SZUAbsolventenverein</owners>
|
<owners>SZUAbsolventenverein</owners>
|
||||||
<title>HallOfFame</title>
|
<title>HallOfFame</title>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<summary></summary>
|
<summary></summary>
|
||||||
<packageTypes>
|
<packageTypes>
|
||||||
<packageType name="Dependency" />
|
<packageType name="Dependency" />
|
||||||
<packageType name="Oqtane.Framework" version="6.2.0" />
|
<packageType name="Oqtane.Framework" version="10.0.3" />
|
||||||
</packageTypes>
|
</packageTypes>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
|||||||
@@ -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 "../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.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/"
|
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/"
|
cp -rf "../Server/wwwroot/"* "../../oqtane.framework/Oqtane.Server/wwwroot/"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -10,6 +11,8 @@ using SZUAbsolventenverein.Module.HallOfFame.Services;
|
|||||||
using Oqtane.Controllers;
|
using Oqtane.Controllers;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
||||||
{
|
{
|
||||||
@@ -17,10 +20,12 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
|||||||
public class HallOfFameController : ModuleControllerBase
|
public class HallOfFameController : ModuleControllerBase
|
||||||
{
|
{
|
||||||
private readonly IHallOfFameService _HallOfFameService;
|
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;
|
_HallOfFameService = HallOfFameService;
|
||||||
|
_environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/<controller>?moduleid=x
|
// GET: api/<controller>?moduleid=x
|
||||||
@@ -33,9 +38,10 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
|||||||
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
||||||
{
|
{
|
||||||
var list = await _HallOfFameService.GetHallOfFamesAsync(ModuleId);
|
var list = await _HallOfFameService.GetHallOfFamesAsync(ModuleId);
|
||||||
// Filter: Show only Published unless user has Edit permissions (simplified check for now, can be expanded)
|
if (User.IsInRole(RoleNames.Admin) || User.IsInRole(RoleNames.Host))
|
||||||
// For now, let's filter in memory or service. The requirement says: "Hauptseite zeigt nur Published".
|
{
|
||||||
// We will filter here.
|
return list;
|
||||||
|
}
|
||||||
return list.Where(item => item.Status == "Published");
|
return list.Where(item => item.Status == "Published");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -85,7 +91,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
|||||||
|
|
||||||
// POST api/<controller>
|
// POST api/<controller>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||||
public async Task<Models.HallOfFame> Post([FromBody] Models.HallOfFame HallOfFame)
|
public async Task<Models.HallOfFame> Post([FromBody] Models.HallOfFame HallOfFame)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, HallOfFame.ModuleId))
|
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, HallOfFame.ModuleId))
|
||||||
@@ -112,7 +118,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
|||||||
|
|
||||||
// PUT api/<controller>/5
|
// PUT api/<controller>/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||||
public async Task<Models.HallOfFame> Put(int id, [FromBody] Models.HallOfFame HallOfFame)
|
public async Task<Models.HallOfFame> Put(int id, [FromBody] Models.HallOfFame HallOfFame)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && HallOfFame.HallOfFameId == id && IsAuthorizedEntityId(EntityNames.Module, HallOfFame.ModuleId))
|
if (ModelState.IsValid && HallOfFame.HallOfFameId == id && IsAuthorizedEntityId(EntityNames.Module, HallOfFame.ModuleId))
|
||||||
@@ -138,7 +144,47 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
|||||||
return HallOfFame;
|
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}")]
|
[HttpDelete("{id}/{moduleid}")]
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
[Authorize(Policy = PolicyNames.EditModule)]
|
||||||
public async Task Delete(int id, int moduleid)
|
public async Task Delete(int id, int moduleid)
|
||||||
@@ -154,5 +200,33 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Controllers
|
|||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[HttpPost("upload")]
|
||||||
|
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||||
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
271
Server/Controllers/HallOfFamePDFController.cs
Normal file
271
Server/Controllers/HallOfFamePDFController.cs
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
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.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Net;
|
||||||
|
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&id=y
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||||
|
public async Task<IActionResult> Get(string moduleid, bool download = false, int? id = null)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
// If a specific entry ID is provided, filter to just that entry
|
||||||
|
if (id.HasValue)
|
||||||
|
{
|
||||||
|
publishedEntries = publishedEntries.Where(e => e.HallOfFameId == id.Value).ToList();
|
||||||
|
if (!publishedEntries.Any())
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 sections = ConvertHtmlToLines(entry.Description ?? "");
|
||||||
|
|
||||||
|
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.Count > 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts HTML content (from Quill.js rich text editor) to a list of plain text lines
|
||||||
|
/// suitable for rendering in QuestPDF.
|
||||||
|
/// Handles: ol/ul lists → numbered/bulleted lines, p → paragraphs, br → newlines,
|
||||||
|
/// strips all other tags and decodes HTML entities.
|
||||||
|
/// </summary>
|
||||||
|
private static List<string> ConvertHtmlToLines(string html)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(html))
|
||||||
|
return new List<string>();
|
||||||
|
|
||||||
|
var lines = new List<string>();
|
||||||
|
|
||||||
|
// Process ordered lists: <ol>...</ol>
|
||||||
|
html = Regex.Replace(html, @"<ol[^>]*>(.*?)</ol>", match =>
|
||||||
|
{
|
||||||
|
var listContent = match.Groups[1].Value;
|
||||||
|
var items = Regex.Matches(listContent, @"<li[^>]*>(.*?)</li>", RegexOptions.Singleline);
|
||||||
|
int counter = 1;
|
||||||
|
var result = "";
|
||||||
|
foreach (Match item in items)
|
||||||
|
{
|
||||||
|
var text = StripHtmlTags(item.Groups[1].Value).Trim();
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
result += $"\n{counter}. {text}";
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}, RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
// Process unordered lists: <ul>...</ul>
|
||||||
|
html = Regex.Replace(html, @"<ul[^>]*>(.*?)</ul>", match =>
|
||||||
|
{
|
||||||
|
var listContent = match.Groups[1].Value;
|
||||||
|
var items = Regex.Matches(listContent, @"<li[^>]*>(.*?)</li>", RegexOptions.Singleline);
|
||||||
|
var result = "";
|
||||||
|
foreach (Match item in items)
|
||||||
|
{
|
||||||
|
var text = StripHtmlTags(item.Groups[1].Value).Trim();
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
result += $"\n• {text}";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}, RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
// Replace <br>, <br/>, <br /> with newline
|
||||||
|
html = Regex.Replace(html, @"<br\s*/?>", "\n", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
// Replace </p>, </div>, </h1>-</h6> with newline
|
||||||
|
html = Regex.Replace(html, @"</(?:p|div|h[1-6])>", "\n", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
// Strip all remaining HTML tags
|
||||||
|
html = StripHtmlTags(html);
|
||||||
|
|
||||||
|
// Decode HTML entities ( & etc.)
|
||||||
|
html = WebUtility.HtmlDecode(html);
|
||||||
|
|
||||||
|
// Split into lines, trim, filter empty
|
||||||
|
var rawLines = html.Split('\n')
|
||||||
|
.Select(s => s.Trim())
|
||||||
|
.Where(s => !string.IsNullOrEmpty(s))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return rawLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Strips all HTML tags from a string, leaving only the text content.
|
||||||
|
/// </summary>
|
||||||
|
private static string StripHtmlTags(string html)
|
||||||
|
{
|
||||||
|
return Regex.Replace(html, @"<[^>]+>", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
30
Server/Migrations/01000003_AddReportTable.cs
Normal file
30
Server/Migrations/01000003_AddReportTable.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,15 +22,15 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Migrations.EntityBuilders
|
|||||||
|
|
||||||
protected override HallOfFameEntityBuilder BuildTable(ColumnsBuilder table)
|
protected override HallOfFameEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
{
|
{
|
||||||
HallOfFameId = AddAutoIncrementColumn(table,"HallOfFameId");
|
HallOfFameId = AddAutoIncrementColumn(table, "HallOfFameId");
|
||||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
ModuleId = AddIntegerColumn(table, "ModuleId");
|
||||||
Name = AddMaxStringColumn(table,"Name");
|
Name = AddMaxStringColumn(table, "Name");
|
||||||
Year = AddIntegerColumn(table,"Year");
|
Year = AddIntegerColumn(table, "Year");
|
||||||
Description = AddMaxStringColumn(table,"Description");
|
Description = AddMaxStringColumn(table, "Description");
|
||||||
Image = AddMaxStringColumn(table,"Image");
|
Image = AddMaxStringColumn(table, "Image");
|
||||||
Link = AddMaxStringColumn(table,"Link");
|
Link = AddMaxStringColumn(table, "Link");
|
||||||
Status = AddStringColumn(table,"Status", 50);
|
Status = AddStringColumn(table, "Status", 50);
|
||||||
UserId = AddIntegerColumn(table,"UserId");
|
UserId = AddIntegerColumn(table, "UserId");
|
||||||
AddAuditableColumns(table);
|
AddAuditableColumns(table);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
public class HallOfFameContext : DBContextBase, ITransientService, IMultiDatabase
|
public class HallOfFameContext : DBContextBase, ITransientService, IMultiDatabase
|
||||||
{
|
{
|
||||||
public virtual DbSet<Models.HallOfFame> HallOfFame { get; set; }
|
public virtual DbSet<Models.HallOfFame> HallOfFame { get; set; }
|
||||||
|
public virtual DbSet<Models.HallOfFameReport> HallOfFameReport { get; set; }
|
||||||
|
|
||||||
public HallOfFameContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
public HallOfFameContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
||||||
{
|
{
|
||||||
@@ -21,6 +22,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
base.OnModelCreating(builder);
|
base.OnModelCreating(builder);
|
||||||
|
|
||||||
builder.Entity<Models.HallOfFame>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinHallOfFame"));
|
builder.Entity<Models.HallOfFame>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinHallOfFame"));
|
||||||
|
builder.Entity<Models.HallOfFameReport>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinHallOfFameReport"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
Models.HallOfFame AddHallOfFame(Models.HallOfFame HallOfFame);
|
Models.HallOfFame AddHallOfFame(Models.HallOfFame HallOfFame);
|
||||||
Models.HallOfFame UpdateHallOfFame(Models.HallOfFame HallOfFame);
|
Models.HallOfFame UpdateHallOfFame(Models.HallOfFame HallOfFame);
|
||||||
void DeleteHallOfFame(int HallOfFameId);
|
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
|
public class HallOfFameRepository : IHallOfFameRepository, ITransientService
|
||||||
@@ -27,7 +32,14 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
public IEnumerable<Models.HallOfFame> GetHallOfFames(int ModuleId)
|
public IEnumerable<Models.HallOfFame> GetHallOfFames(int ModuleId)
|
||||||
{
|
{
|
||||||
using var db = _factory.CreateDbContext();
|
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)
|
public Models.HallOfFame GetHallOfFame(int HallOfFameId)
|
||||||
@@ -38,19 +50,28 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
public Models.HallOfFame GetHallOfFame(int HallOfFameId, bool tracking)
|
public Models.HallOfFame GetHallOfFame(int HallOfFameId, bool tracking)
|
||||||
{
|
{
|
||||||
using var db = _factory.CreateDbContext();
|
using var db = _factory.CreateDbContext();
|
||||||
|
Models.HallOfFame item;
|
||||||
if (tracking)
|
if (tracking)
|
||||||
{
|
{
|
||||||
return db.HallOfFame.Find(HallOfFameId);
|
item = db.HallOfFame.Find(HallOfFameId);
|
||||||
}
|
}
|
||||||
else
|
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)
|
public Models.HallOfFame AddHallOfFame(Models.HallOfFame HallOfFame)
|
||||||
{
|
{
|
||||||
using var db = _factory.CreateDbContext();
|
using var db = _factory.CreateDbContext();
|
||||||
|
HallOfFame.Description = HallOfFame.Description?.Replace("\t", " ");
|
||||||
|
HallOfFame.Image ??= "";
|
||||||
|
HallOfFame.Link ??= "";
|
||||||
db.HallOfFame.Add(HallOfFame);
|
db.HallOfFame.Add(HallOfFame);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
return HallOfFame;
|
return HallOfFame;
|
||||||
@@ -59,6 +80,9 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
public Models.HallOfFame UpdateHallOfFame(Models.HallOfFame HallOfFame)
|
public Models.HallOfFame UpdateHallOfFame(Models.HallOfFame HallOfFame)
|
||||||
{
|
{
|
||||||
using var db = _factory.CreateDbContext();
|
using var db = _factory.CreateDbContext();
|
||||||
|
HallOfFame.Description = HallOfFame.Description?.Replace("\t", " ");
|
||||||
|
HallOfFame.Image ??= "";
|
||||||
|
HallOfFame.Link ??= "";
|
||||||
db.Entry(HallOfFame).State = EntityState.Modified;
|
db.Entry(HallOfFame).State = EntityState.Modified;
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
return HallOfFame;
|
return HallOfFame;
|
||||||
@@ -66,10 +90,64 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Repository
|
|||||||
|
|
||||||
public void DeleteHallOfFame(int HallOfFameId)
|
public void DeleteHallOfFame(int HallOfFameId)
|
||||||
{
|
{
|
||||||
using var db = _factory.CreateDbContext();
|
// First transaction: Delete all associated reports
|
||||||
Models.HallOfFame HallOfFame = db.HallOfFame.Find(HallOfFameId);
|
using (var db = _factory.CreateDbContext())
|
||||||
db.HallOfFame.Remove(HallOfFame);
|
{
|
||||||
|
var reports = db.HallOfFameReport.Where(item => item.HallOfFameId == HallOfFameId).ToList();
|
||||||
|
if (reports.Any())
|
||||||
|
{
|
||||||
|
db.HallOfFameReport.RemoveRange(reports);
|
||||||
db.SaveChanges();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="10.0.1" />
|
||||||
|
<PackageReference Include="QuestPDF" Version="2026.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -34,4 +35,16 @@
|
|||||||
<Reference Include="Oqtane.Server"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Server.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>
|
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
|
||||||
</ItemGroup>
|
</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>
|
</Project>
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.Net.Http;
|
||||||
using Oqtane.Enums;
|
using Oqtane.Enums;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Security;
|
using Oqtane.Security;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
using SZUAbsolventenverein.Module.HallOfFame.Repository;
|
using SZUAbsolventenverein.Module.HallOfFame.Repository;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
||||||
{
|
{
|
||||||
@@ -18,14 +22,16 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
|||||||
private readonly ILogManager _logger;
|
private readonly ILogManager _logger;
|
||||||
private readonly IHttpContextAccessor _accessor;
|
private readonly IHttpContextAccessor _accessor;
|
||||||
private readonly Alias _alias;
|
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;
|
_HallOfFameRepository = HallOfFameRepository;
|
||||||
_userPermissions = userPermissions;
|
_userPermissions = userPermissions;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_accessor = accessor;
|
_accessor = accessor;
|
||||||
_alias = tenantManager.GetAlias();
|
_alias = tenantManager.GetAlias();
|
||||||
|
_environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<Models.HallOfFame>> GetHallOfFamesAsync(int ModuleId)
|
public Task<List<Models.HallOfFame>> GetHallOfFamesAsync(int ModuleId)
|
||||||
@@ -70,7 +76,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
|||||||
|
|
||||||
public Task<Models.HallOfFame> AddHallOfFameAsync(Models.HallOfFame HallOfFame)
|
public Task<Models.HallOfFame> AddHallOfFameAsync(Models.HallOfFame HallOfFame)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, HallOfFame.ModuleId, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, HallOfFame.ModuleId, PermissionNames.View))
|
||||||
{
|
{
|
||||||
HallOfFame = _HallOfFameRepository.AddHallOfFame(HallOfFame);
|
HallOfFame = _HallOfFameRepository.AddHallOfFame(HallOfFame);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "HallOfFame Added {HallOfFame}", HallOfFame);
|
_logger.Log(LogLevel.Information, this, LogFunction.Create, "HallOfFame Added {HallOfFame}", HallOfFame);
|
||||||
@@ -85,7 +91,7 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
|||||||
|
|
||||||
public Task<Models.HallOfFame> UpdateHallOfFameAsync(Models.HallOfFame HallOfFame)
|
public Task<Models.HallOfFame> UpdateHallOfFameAsync(Models.HallOfFame HallOfFame)
|
||||||
{
|
{
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, HallOfFame.ModuleId, PermissionNames.Edit))
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, HallOfFame.ModuleId, PermissionNames.View))
|
||||||
{
|
{
|
||||||
HallOfFame = _HallOfFameRepository.UpdateHallOfFame(HallOfFame);
|
HallOfFame = _HallOfFameRepository.UpdateHallOfFame(HallOfFame);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "HallOfFame Updated {HallOfFame}", HallOfFame);
|
_logger.Log(LogLevel.Information, this, LogFunction.Update, "HallOfFame Updated {HallOfFame}", HallOfFame);
|
||||||
@@ -111,5 +117,104 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Services
|
|||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
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.View))
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Startup
|
|||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
// QuestPDF Lizenz konfigurieren
|
||||||
|
QuestPDF.Settings.License = QuestPDF.Infrastructure.LicenseType.Community;
|
||||||
|
|
||||||
services.AddTransient<IHallOfFameService, ServerHallOfFameService>();
|
services.AddTransient<IHallOfFameService, ServerHallOfFameService>();
|
||||||
services.AddDbContextFactory<HallOfFameContext>(opt => { }, ServiceLifetime.Transient);
|
services.AddDbContextFactory<HallOfFameContext>(opt => { }, ServiceLifetime.Transient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,17 @@
|
|||||||
/* Module Custom Styles */
|
/* 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;
|
||||||
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Interfaces;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.HallOfFame.Models
|
namespace SZUAbsolventenverein.Module.HallOfFame.Models
|
||||||
{
|
{
|
||||||
[Table("SZUAbsolventenvereinHallOfFame")]
|
[Table("SZUAbsolventenvereinHallOfFame")]
|
||||||
public class HallOfFame : IAuditable
|
public class HallOfFame : IAuditable, IReportable
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int HallOfFameId { get; set; }
|
public int HallOfFameId { get; set; }
|
||||||
@@ -19,8 +20,21 @@ namespace SZUAbsolventenverein.Module.HallOfFame.Models
|
|||||||
public string Link { get; set; }
|
public string Link { get; set; }
|
||||||
public string Status { get; set; } // "Draft" or "Published"
|
public string Status { get; set; } // "Draft" or "Published"
|
||||||
public int UserId { get; set; } // Owner
|
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 string CreatedBy { get; set; }
|
||||||
public DateTime CreatedOn { get; set; }
|
public DateTime CreatedOn { get; set; }
|
||||||
public string ModifiedBy { get; set; }
|
public string ModifiedBy { get; set; }
|
||||||
|
|||||||
21
Shared/Models/HallOfFameReport.cs
Normal file
21
Shared/Models/HallOfFameReport.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Interfaces" Version="0.0.0-12" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user