New: Report Component available via Microsoft Dependency Injection
This commit is contained in:
139
Client/Components/ReportComponent.razor
Normal file
139
Client/Components/ReportComponent.razor
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
@inherits ComponentBase
|
||||||
|
@using Interfaces
|
||||||
|
@implements Interfaces.IReportUI
|
||||||
|
@inject IReportingHandler ReportingHandler
|
||||||
|
|
||||||
|
<button class="btn btn-warning btn-lg px-4" @onclick="ShowReportModal">
|
||||||
|
<i class="oi oi-warning me-2"></i> Melden
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@if (_showReportModal)
|
||||||
|
{
|
||||||
|
<div class="modal fade show" style="display: block; background: rgba(0,0,0,0.5); z-index: 1050;" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Eintrag melden</h5>
|
||||||
|
<button type="button" class="btn-close" @onclick="CloseReportModal"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>Warum möchtest du diesen Eintrag melden?</p>
|
||||||
|
<textarea class="form-control" @bind="_reportReason" rows="3" placeholder="Grund für die Meldung..."></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="CloseReportModal">Abbrechen</button>
|
||||||
|
<button type="button" class="btn btn-danger" @onclick="ReportEntry">Melden</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.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 Type ReportType => typeof(ReportComponent);
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public IReportable ReportableEntity { get; set; }
|
||||||
|
|
||||||
|
private bool _showReportModal = false;
|
||||||
|
private string _reportReason = "";
|
||||||
|
|
||||||
|
private class ReportEntityTest : IReportable
|
||||||
|
{
|
||||||
|
public int EntityID { get; set; }
|
||||||
|
public string ModuleName { get; set; }
|
||||||
|
public int ModuleID { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
ReportableEntity = new ReportEntityTest { EntityID = 1, ModuleID = 2, ModuleName = "TestModule" };
|
||||||
|
return base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowReportModal()
|
||||||
|
{
|
||||||
|
_reportReason = "";
|
||||||
|
_showReportModal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseReportModal()
|
||||||
|
{
|
||||||
|
_showReportModal = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReportEntry()
|
||||||
|
{
|
||||||
|
ReportingHandler.Report(ReportableEntity, _reportReason);
|
||||||
|
Console.WriteLine($"Eintrag gemeldet mit Grund: {_reportReason}");
|
||||||
|
CloseReportModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task SetParametersAsync(ParameterView parameters)
|
||||||
|
{
|
||||||
|
Console.WriteLine("ParameterView received in ReportComponent:");
|
||||||
|
foreach (var parameter in parameters)
|
||||||
|
{
|
||||||
|
Console.WriteLine(parameter.Name + "name - value" + parameter.Value);
|
||||||
|
}
|
||||||
|
return base.SetParametersAsync(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Interfaces;
|
using Interfaces;
|
||||||
using Oqtane.Services;
|
using Oqtane.Services;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Client.Components;
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Services;
|
using SZUAbsolventenverein.Module.AdminModules.Services;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
||||||
|
|
||||||
@@ -20,10 +22,16 @@ namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
|||||||
{
|
{
|
||||||
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
|
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
|
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
|
||||||
{
|
{
|
||||||
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
|
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!services.Any(s => s.ServiceType == typeof(IReportUI)))
|
||||||
|
{
|
||||||
|
services.AddScoped<IReportUI, ReportComponent>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user