Reporting: Add UserName
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
@inherits ComponentBase
|
||||
@inherits LocalizableComponent
|
||||
@using Interfaces
|
||||
@implements Interfaces.IReportUI
|
||||
@inject IReportingHandler ReportingHandler
|
||||
|
||||
<button class="btn btn-warning btn-lg px-4" @onclick="ShowReportModal">
|
||||
<button type="button" class="btn btn-warning btn-lg px-4" @onclick="ShowReportModal">
|
||||
<i class="oi oi-warning me-2"></i> Melden
|
||||
</button>
|
||||
|
||||
@@ -29,63 +29,6 @@
|
||||
</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);
|
||||
|
||||
@@ -95,23 +38,11 @@
|
||||
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()
|
||||
private Task ShowReportModal()
|
||||
{
|
||||
_reportReason = "";
|
||||
_showReportModal = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void CloseReportModal()
|
||||
@@ -119,21 +50,39 @@
|
||||
_showReportModal = false;
|
||||
}
|
||||
|
||||
private void ReportEntry()
|
||||
private async Task 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)
|
||||
// Basic null checks to avoid runtime NREs
|
||||
if (ReportingHandler == null)
|
||||
{
|
||||
Console.WriteLine(parameter.Name + "name - value" + parameter.Value);
|
||||
Console.WriteLine("ReportingHandler is not available (null). Ensure it is registered and injected.");
|
||||
CloseReportModal();
|
||||
return;
|
||||
}
|
||||
return base.SetParametersAsync(parameters);
|
||||
}
|
||||
|
||||
if (ReportableEntity == null)
|
||||
{
|
||||
Console.WriteLine("ReportableEntity is null. Cannot report.");
|
||||
CloseReportModal();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// If the handler exposes an async API use it instead. We run the synchronous call off the UI thread to avoid blocking.
|
||||
await Task.Run(() => ReportingHandler.Report(ReportableEntity, _reportReason));
|
||||
Console.WriteLine($"Eintrag gemeldet mit Grund: {_reportReason}");
|
||||
AddModuleMessage($"Eintrag mit Grund {_reportReason} gemeldet.", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Reporting failed: {ex.Message}");
|
||||
AddModuleMessage($"Eintrag konnte nicht gemeldet werden, bitte melden sie sich direkt beim Absolventenverein: ({ex.StackTrace}).", MessageType.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
CloseReportModal();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user