Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aae330f46a | |||
| 694d521698 | |||
| 279624971b | |||
| 7610235e63 | |||
| d9fa550304 |
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 System.Linq;
|
||||
using Interfaces;
|
||||
using Oqtane.Services;
|
||||
using SZUAbsolventenverein.Module.AdminModules.Client.Components;
|
||||
using SZUAbsolventenverein.Module.AdminModules.Services;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
||||
|
||||
@@ -20,10 +22,16 @@ namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
||||
{
|
||||
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
|
||||
}
|
||||
|
||||
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
|
||||
{
|
||||
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
|
||||
}
|
||||
|
||||
if (!services.Any(s => s.ServiceType == typeof(IReportUI)))
|
||||
{
|
||||
services.AddScoped<IReportUI, ReportComponent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fkocoder_002Falumnihub_005F10_002E0_005Famd64_002Finterfaces_002FInterfaces_002Fbin_002FDebug_002Fnet10_002E0_002FInterfaces_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=_002Fhome_002Fkocoder_002Falumnihub_005F10_002E0_005Famd64_002FSZUAbsolventenverein_002FInterfaces_002Fbin_002FDebug_002Fnet10_002E0_002FInterfaces_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AComponentBase_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa1ecd5c0c773451bb67865cbd48f5976e4e00_003F15_003F972ec13f_003FComponentBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AComponentBase_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc79a534484f3c079e696a1b8489d234b7066e25afd8a9b4bd1be4257d3167_003FComponentBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||
<Assembly Path="/home/kocoder/alumnihub_10.0_amd64/SZUAbsolventenverein/Interfaces/bin/Debug/net10.0/Interfaces.dll" />
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository.Databases.Interfaces;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
||||
{
|
||||
public class AdminModulesContext : DBContextBase, ITransientService, IMultiDatabase
|
||||
{
|
||||
public virtual DbSet<Models.AdminModules> AdminModules { get; set; }
|
||||
|
||||
public AdminModulesContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<Models.AdminModules>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinAdminModules"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
||||
{
|
||||
public interface IAdminModulesRepository
|
||||
{
|
||||
IEnumerable<Models.AdminModules> GetAdminModuless(int ModuleId);
|
||||
Models.AdminModules GetAdminModules(int AdminModulesId);
|
||||
Models.AdminModules GetAdminModules(int AdminModulesId, bool tracking);
|
||||
Models.AdminModules AddAdminModules(Models.AdminModules AdminModules);
|
||||
Models.AdminModules UpdateAdminModules(Models.AdminModules AdminModules);
|
||||
void DeleteAdminModules(int AdminModulesId);
|
||||
}
|
||||
|
||||
public class AdminModulesRepository : IAdminModulesRepository, ITransientService
|
||||
{
|
||||
private readonly IDbContextFactory<AdminModulesContext> _factory;
|
||||
|
||||
public AdminModulesRepository(IDbContextFactory<AdminModulesContext> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
public IEnumerable<Models.AdminModules> GetAdminModuless(int ModuleId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
return db.AdminModules.Where(item => item.ModuleId == ModuleId).ToList();
|
||||
}
|
||||
|
||||
public Models.AdminModules GetAdminModules(int AdminModulesId)
|
||||
{
|
||||
return GetAdminModules(AdminModulesId, true);
|
||||
}
|
||||
|
||||
public Models.AdminModules GetAdminModules(int AdminModulesId, bool tracking)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
if (tracking)
|
||||
{
|
||||
return db.AdminModules.Find(AdminModulesId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.AdminModules.AsNoTracking().FirstOrDefault(item => item.AdminModulesId == AdminModulesId);
|
||||
}
|
||||
}
|
||||
|
||||
public Models.AdminModules AddAdminModules(Models.AdminModules AdminModules)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.AdminModules.Add(AdminModules);
|
||||
db.SaveChanges();
|
||||
return AdminModules;
|
||||
}
|
||||
|
||||
public Models.AdminModules UpdateAdminModules(Models.AdminModules AdminModules)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
db.Entry(AdminModules).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return AdminModules;
|
||||
}
|
||||
|
||||
public void DeleteAdminModules(int AdminModulesId)
|
||||
{
|
||||
using var db = _factory.CreateDbContext();
|
||||
Models.AdminModules AdminModules = db.AdminModules.Find(AdminModulesId);
|
||||
db.AdminModules.Remove(AdminModules);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,42 +7,55 @@ using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
using Oqtane.Shared;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Permissions;
|
||||
using SZUAbsolventenverein.Module.ReportSystem.Repository;
|
||||
|
||||
namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
||||
{
|
||||
public class ServerReportSystemReportingService : IReportSystemReportingService, IReportingHandler
|
||||
{
|
||||
private readonly IModuleDefinitionRepository _moduleDefinitionRepository;
|
||||
private readonly IReportingRepository _reportSystemRepository;
|
||||
private readonly IUserPermissions _userPermissions;
|
||||
private readonly ILogManager _logger;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly Alias _alias;
|
||||
private readonly int _moduleDefinitionId;
|
||||
|
||||
public ServerReportSystemReportingService(IReportingRepository reportSystemRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
public ServerReportSystemReportingService(IModuleDefinitionRepository moduleDefinitionRepository, IReportingRepository reportSystemRepository, IUserPermissions userPermissions, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||
{
|
||||
_moduleDefinitionRepository = moduleDefinitionRepository;
|
||||
_reportSystemRepository = reportSystemRepository;
|
||||
_userPermissions = userPermissions;
|
||||
_logger = logger;
|
||||
_accessor = accessor;
|
||||
_alias = tenantManager.GetAlias();
|
||||
|
||||
ModuleDefinition md = moduleDefinitionRepository.GetModuleDefinitions(_alias.SiteId).ToList().Find(md => md.IsEnabled && md.Name == new ModuleInfo().ModuleDefinition.Name);
|
||||
if (md == null)
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Reporting Module Not Found {ModuleName}", new ModuleInfo().ModuleDefinition.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_moduleDefinitionId = md.ModuleDefinitionId;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<Reporting> CreateReportAsync(Reporting Reporting)
|
||||
{
|
||||
// true ||
|
||||
Console.WriteLine("HELP");
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.ModuleDefinition, 53, PermissionNames.Utilize))
|
||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.ModuleDefinition, _moduleDefinitionId, PermissionNames.Utilize))
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Reporting Updated {Reporting}", Reporting);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Reporting created {Reporting}", Reporting);
|
||||
return Task.FromResult(_reportSystemRepository.AddReporting(Reporting));
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Update Attempt {Reporting}", Reporting);
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting create attempt {Reporting}", Reporting);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +121,10 @@ namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
||||
// if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
Reporting reporting = await CreateReportAsync(new Reporting {ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, Note = note, Reason = "Default Reason"});
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Reporting recieved {ReportingId}", reporting.ReportingID);
|
||||
if (reporting != null)
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Reporting recieved {ReportingId}", reporting.ReportingID);
|
||||
}
|
||||
}
|
||||
// else
|
||||
{
|
||||
|
||||
8
Shared/Permissions/ReportSystemPermissionNames.cs
Normal file
8
Shared/Permissions/ReportSystemPermissionNames.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SZUAbsolventenverein.Module.ReportSystem.Permissions
|
||||
{
|
||||
public class ReportSystemPermissionNames
|
||||
{
|
||||
public const string Report = "Report";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user