Compare commits
13 Commits
ReportSyst
...
kh-configu
| Author | SHA1 | Date | |
|---|---|---|---|
| 25b254969b | |||
| 8bc2d08d5b | |||
| 50d961255c | |||
| 6e4b12f1fc | |||
| febd9030eb | |||
| 102d20d64e | |||
| fc92dd48e3 | |||
| f47c8ce1cb | |||
| decb170e7b | |||
| 0b541373c2 | |||
| afc9ba81e3 | |||
| a64bdacbf5 | |||
| bb30c7fb42 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,6 +2,4 @@
|
|||||||
**/bin
|
**/bin
|
||||||
**/obj
|
**/obj
|
||||||
**/obj/**
|
**/obj/**
|
||||||
**/Debug
|
**/Debug
|
||||||
|
|
||||||
.idea/
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
@using SZUAbsolventenverein.Module.AdminModules.Services
|
@using SZUAbsolventenverein.Module.AdminModules.Services
|
||||||
@using SZUAbsolventenverein.Module.AdminModules.Models
|
@using SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
|
|
||||||
@namespace SZUAbsolventenverein.Module.AdminModules
|
@namespace SZUAbsolventenverein.Module.AdminMassMailing
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IAdminModulesService AdminModulesService
|
@inject IAdminModulesService AdminModulesService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
@using SZUAbsolventenverein.Module.AdminModules.Services
|
@using SZUAbsolventenverein.Module.AdminModules.Services
|
||||||
@using SZUAbsolventenverein.Module.AdminModules.Models
|
@using SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
|
|
||||||
@namespace SZUAbsolventenverein.Module.AdminModules
|
@namespace SZUAbsolventenverein.Module.AdminMassMailing
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IAdminModulesService AdminModulesService
|
@inject IAdminModulesService AdminModulesService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Modules;
|
||||||
|
|
||||||
|
namespace SZUAbsolventenverein.Module.AdminMassMailing
|
||||||
|
{
|
||||||
|
public class ModuleInfo : IModule
|
||||||
|
{
|
||||||
|
public ModuleDefinition ModuleDefinition => new ModuleDefinition
|
||||||
|
{
|
||||||
|
Name = "AdminMassMailing",
|
||||||
|
Description = "Mass Mailing Tool",
|
||||||
|
Version = "1.0.7",
|
||||||
|
ServerManagerType = "SZUAbsolventenverein.Module.AdminModules.Manager.AdminModulesManager, SZUAbsolventenverein.Module.AdminModules.Server.Oqtane",
|
||||||
|
ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,1.0.5,1.0.6,1.0.7",
|
||||||
|
Dependencies = "SZUAbsolventenverein.Module.AdminModules.Shared.Oqtane",
|
||||||
|
PackageName = "SZUAbsolventenverein.Module.AdminMassMailing"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
@using SZUAbsolventenverein.Module.AdminModules.Models
|
@using SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
@using Microsoft.AspNetCore.Components.Forms;
|
@using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
|
||||||
@namespace SZUAbsolventenverein.Module.AdminModules
|
@namespace SZUAbsolventenverein.Module.AdminMassMailing
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IAdminModulesService AdminModulesService
|
@inject IAdminModulesService AdminModulesService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@@ -11,12 +11,6 @@
|
|||||||
|
|
||||||
<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-1 align-items-center">
|
|
||||||
<Label Class="col-sm-3" For="name" HelpText="Enter a name" ResourceKey="Name">Name: </Label>
|
|
||||||
<div class="col-sm-9">
|
|
||||||
<input id="name" class="form-control" @bind="@_name" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="role" HelpText="Select a role" ResourceKey="Role">Role: </Label>
|
<Label Class="col-sm-3" For="role" HelpText="Select a role" ResourceKey="Role">Role: </Label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
@@ -40,10 +34,17 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<p></p>
|
<p></p>
|
||||||
<button type="button" class="btn btn-success" @onclick="Save">@Localizer["Save"]</button>
|
@if(userCount != null)
|
||||||
|
{
|
||||||
|
<ActionDialog Header="@(userCount != null ? userCount + " Nachrichten versenden" : "-")"
|
||||||
|
Message="Are You Sure You Wish To Send this Mass Notification?"
|
||||||
|
Action="SendConfirm"
|
||||||
|
Security="SecurityAccessLevel.Edit"
|
||||||
|
Class="btn btn-success"
|
||||||
|
OnClick="@(async () => await Save())"
|
||||||
|
ResourceKey="SendConfirm" />
|
||||||
|
}
|
||||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@Localizer["Cancel"]</NavLink>
|
||||||
<br /><br />
|
|
||||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
@@ -77,13 +78,7 @@
|
|||||||
private bool validated = false;
|
private bool validated = false;
|
||||||
|
|
||||||
private int _id;
|
private int _id;
|
||||||
private string _name;
|
|
||||||
private string _richText;
|
|
||||||
private string _createdby;
|
|
||||||
private DateTime _createdon;
|
|
||||||
private string _modifiedby;
|
|
||||||
private DateTime _modifiedon;
|
|
||||||
|
|
||||||
private async void RefetchUserCount()
|
private async void RefetchUserCount()
|
||||||
{
|
{
|
||||||
EmailFields ef = new EmailFields();
|
EmailFields ef = new EmailFields();
|
||||||
@@ -103,16 +98,6 @@
|
|||||||
if (PageState.Action == "Send")
|
if (PageState.Action == "Send")
|
||||||
{
|
{
|
||||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||||
AdminModules AdminModules = await AdminModulesService.GetAdminModulesAsync(_id, ModuleState.ModuleId);
|
|
||||||
if (AdminModules != null)
|
|
||||||
{
|
|
||||||
_name = AdminModules.Name;
|
|
||||||
_richText = AdminModules.Content;
|
|
||||||
_createdby = AdminModules.CreatedBy;
|
|
||||||
_createdon = AdminModules.CreatedOn;
|
|
||||||
_modifiedby = AdminModules.ModifiedBy;
|
|
||||||
_modifiedon = AdminModules.ModifiedOn;
|
|
||||||
}
|
|
||||||
roles = await AdminModulesService.GetRoles(ModuleState.ModuleId);
|
roles = await AdminModulesService.GetRoles(ModuleState.ModuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@namespace SZUAbsolventenverein.Module.AdminModules
|
@namespace SZUAbsolventenverein.Module.AdminMassMailing
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject ISettingService SettingService
|
@inject ISettingService SettingService
|
||||||
@inject IStringLocalizer<Settings> Localizer
|
@inject IStringLocalizer<Settings> Localizer
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
@using SZUAbsolventenverein.Module.AdminSettings.Services
|
||||||
|
@using SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
|
|
||||||
|
@namespace SZUAbsolventenverein.Module.AdminSettings
|
||||||
|
@inherits ModuleBase
|
||||||
|
@inject IAdminSettingsService AdminSettingsService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
@inject IStringLocalizer<Index> Localizer
|
||||||
|
|
||||||
|
@if (_AdminSetting == null)
|
||||||
|
{
|
||||||
|
<p><em>Loading...</em></p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="container">
|
||||||
|
<div class="row mb-1 align-items-center">
|
||||||
|
<Label Class="col-sm-3" For="tokenLifetime" HelpText="Gib die Lebenszeit von Tokens in Tagen an" ResourceKey="TokenLifetime">TokenLifetime: </Label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<Microsoft.AspNetCore.Components.Forms.InputNumber @bind-Value="_AdminSetting.TokenLifetime" class="form-control" id="tokenLifetime" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary" type="button" @onclick="Save">Save</button>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
public override List<Resource> Resources => new List<Resource>()
|
||||||
|
{
|
||||||
|
new Stylesheet("_content/SZUAbsolventenverein.Module.AdminModules/Module.css"),
|
||||||
|
new Script("_content/SZUAbsolventenverein.Module.AdminModules/Module.js")
|
||||||
|
};
|
||||||
|
|
||||||
|
private AdminSetting _AdminSetting;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_AdminSetting = await AdminSettingsService.GetAdminSettingsAsync(ModuleState.ModuleId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Loading AdminSettings {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Save()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Saving!!!!");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AddModuleMessage("Saved", MessageType.Success);
|
||||||
|
await AdminSettingsService.SetAdminSettingsAsync(_AdminSetting);
|
||||||
|
AddModuleMessage("Saved", MessageType.Success);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await logger.LogError(ex, "Error Saving AdminSettings {Error}", ex.Message);
|
||||||
|
AddModuleMessage(Localizer["Message.LoadError"], MessageType.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Modules;
|
using Oqtane.Modules;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules
|
namespace SZUAbsolventenverein.Module.AdminSettings
|
||||||
{
|
{
|
||||||
public class ModuleInfo : IModule
|
public class ModuleInfo : IModule
|
||||||
{
|
{
|
||||||
public ModuleDefinition ModuleDefinition => new ModuleDefinition
|
public ModuleDefinition ModuleDefinition => new ModuleDefinition
|
||||||
{
|
{
|
||||||
Name = "AdminModules",
|
Name = "Admin - Settings",
|
||||||
Description = "Admin Tools",
|
Description = "Einstellungen in Oqtane",
|
||||||
Version = "1.0.2",
|
Version = "1.0.0",
|
||||||
ServerManagerType = "SZUAbsolventenverein.Module.AdminModules.Manager.AdminModulesManager, SZUAbsolventenverein.Module.AdminModules.Server.Oqtane",
|
ServerManagerType = "SZUAbsolventenverein.Module.AdminModules.Manager.AdminModulesManager, SZUAbsolventenverein.Module.AdminModules.Server.Oqtane",
|
||||||
ReleaseVersions = "1.0.0,1.0.1,1.0.2",
|
ReleaseVersions = "1.0.0",
|
||||||
Dependencies = "SZUAbsolventenverein.Module.AdminModules.Shared.Oqtane",
|
Dependencies = "SZUAbsolventenverein.Module.AdminModules.Shared.Oqtane",
|
||||||
PackageName = "SZUAbsolventenverein.Module.AdminModules"
|
PackageName = "SZUAbsolventenverein.Module.AdminSettings"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,20 @@
|
|||||||
@namespace SZUAbsolventenverein.Module.ReportSystem
|
@namespace SZUAbsolventenverein.Module.AdminSettings
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject ISettingService SettingService
|
@inject ISettingService SettingService
|
||||||
@inject IStringLocalizer<Settings> Localizer
|
@inject IStringLocalizer<Settings> Localizer
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row mb-1 align-items-center">
|
<div class="row mb-1 align-items-center">
|
||||||
<Label Class="col-sm-3" For="value" HelpText="Enter a value" ResourceKey="SettingName"
|
<Label Class="col-sm-3" For="value" HelpText="Enter a value" ResourceKey="SettingName" ResourceType="@resourceType">Name: </Label>
|
||||||
ResourceType="@resourceType">Name: </Label>
|
<div class="col-sm-9">
|
||||||
<div class="col-sm-9">
|
<input id="value" type="text" class="form-control" @bind="@_value" />
|
||||||
<input id="value" type="text" class="form-control" @bind="@_value"/>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string resourceType = "SZUAbsolventenverein.Module.ReportSystem.Settings, SZUAbsolventenverein.Module.AdminModules.Client.Oqtane"; // for localization
|
private string resourceType = "SZUAbsolventenverein.Module.AdminSettings.Settings, SZUAbsolventenverein.Module.AdminSettings.Client.Oqtane"; // for localization
|
||||||
public override string Title => "ReportSystem Settings";
|
public override string Title => "Admin - Settings Settings";
|
||||||
|
|
||||||
string _value;
|
string _value;
|
||||||
|
|
||||||
@@ -45,5 +44,4 @@
|
|||||||
AddModuleMessage(ex.Message, MessageType.Error);
|
AddModuleMessage(ex.Message, MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
@namespace SZUAbsolventenverein.Module.ReportSystem
|
|
||||||
@using Microsoft.VisualBasic.FileIO
|
|
||||||
@using SZUAbsolventenverein.Module.ReportSystem.Models
|
|
||||||
@using SZUAbsolventenverein.Module.ReportSystem.Services
|
|
||||||
|
|
||||||
@inherits ModuleBase
|
|
||||||
@inject NavigationManager NavigationManager
|
|
||||||
@inject IReportSystemReportingService ReportingService
|
|
||||||
@inject IStringLocalizer<Index> Localizer
|
|
||||||
|
|
||||||
@if (reportings == null)
|
|
||||||
{
|
|
||||||
<p><em>Loading...</em></p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
@if (reportings.Count != 0)
|
|
||||||
{
|
|
||||||
<Pager Items="@reportings">
|
|
||||||
<Header>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th style="width: 1px;"> </th>
|
|
||||||
<th>@Localizer["Name"]</th>
|
|
||||||
</Header>
|
|
||||||
<Row>
|
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Edit" /></td>
|
|
||||||
<td><ActionDialog Header="Delete AdminModules" Message="Are You Sure You Wish To Delete This AdminModules?" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" ResourceKey="Delete" Id="@context.ReportingID.ToString()" /></td>
|
|
||||||
<td><ActionLink Action="Send" Parameters="@($"id=" + context.ReportingID)" ResourceKey="Send" /></td>
|
|
||||||
<td>@context.Reason</td>
|
|
||||||
</Row>
|
|
||||||
</Pager>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<p>@Localizer["Message.DisplayNone"]</p>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@code {
|
|
||||||
public override string RenderMode => RenderModes.Interactive;
|
|
||||||
|
|
||||||
public override List<Resource> Resources => new List<Resource>()
|
|
||||||
{
|
|
||||||
new Stylesheet("_content/SZUAbsolventenverein.Module.ReportSystem/Module.css"),
|
|
||||||
new Script("_content/SZUAbsolventenverein.Module.ReportSystem/Module.js")
|
|
||||||
};
|
|
||||||
|
|
||||||
private List<Reporting> reportings = new List<Reporting>();
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
reportings = await ReportingService.GetReportsAsync(ModuleState.ModuleId);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger.LogError("Error fetching reportings: {Message}", ex.Message);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Delete(Reporting reporting)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ReportingService.DeleteReportingAsync(reporting.ReportingID, ModuleState.ModuleId);
|
|
||||||
reportings.Remove(reporting);
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger.LogError("Error deleting reporting: {Message}", ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Oqtane.Models;
|
|
||||||
using Oqtane.Modules;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem
|
|
||||||
{
|
|
||||||
public class ModuleInfo : IModule
|
|
||||||
{
|
|
||||||
public ModuleDefinition ModuleDefinition => new ModuleDefinition
|
|
||||||
{
|
|
||||||
Name = "ReportSystem",
|
|
||||||
Description = "Handle Systemwide Reporting",
|
|
||||||
Version = "1.0.0",
|
|
||||||
ServerManagerType =
|
|
||||||
"SZUAbsolventenverein.Module.ReportSystem.Manager.ReportSystemManager, SZUAbsolventenverein.Module.AdminModules.Server.Oqtane",
|
|
||||||
ReleaseVersions = "1.0.0",
|
|
||||||
Dependencies = "SZUAbsolventenverein.Module.ReportSystem.Shared.Oqtane",
|
|
||||||
PackageName = "SZUAbsolventenverein.Module.ReportSystem",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,18 +25,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Interfaces">
|
|
||||||
<HintPath>..\..\interfaces\Interfaces\bin\Debug\net10.0\Interfaces.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Oqtane.Client"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Client.dll</HintPath></Reference>
|
<Reference Include="Oqtane.Client"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Client.dll</HintPath></Reference>
|
||||||
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
|
<Reference Include="Oqtane.Shared"><HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\net10.0\Oqtane.Shared.dll</HintPath></Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- <ItemGroup>
|
|
||||||
<AdditionalFiles Include="Modules\SZUAbsolventenverein.Module.ReportSystem\Index.razor" />
|
|
||||||
<AdditionalFiles Include="Modules\SZUAbsolventenverein.Module.ReportSystem\Settings.razor" />
|
|
||||||
</ItemGroup> -->
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- there may be other elements here -->
|
<!-- there may be other elements here -->
|
||||||
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
|
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
|
||||||
|
|||||||
37
Client/Services/AdminSettingsService.cs
Normal file
37
Client/Services/AdminSettingsService.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Services;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Models;
|
||||||
|
|
||||||
|
namespace SZUAbsolventenverein.Module.AdminSettings.Services
|
||||||
|
{
|
||||||
|
public interface IAdminSettingsService
|
||||||
|
{
|
||||||
|
Task<AdminSetting> GetAdminSettingsAsync(int ModuleId);
|
||||||
|
|
||||||
|
Task<AdminSetting> SetAdminSettingsAsync(AdminSetting AdminSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AdminSettingsService : ServiceBase, IAdminSettingsService
|
||||||
|
{
|
||||||
|
public AdminSettingsService(HttpClient http, SiteState siteState) : base(http, siteState) { }
|
||||||
|
|
||||||
|
private string Apiurl => CreateApiUrl("AdminSettings");
|
||||||
|
|
||||||
|
public async Task<AdminSetting> GetAdminSettingsAsync(int ModuleId)
|
||||||
|
{
|
||||||
|
return await GetJsonAsync<AdminSetting>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", EntityNames.Module, ModuleId), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AdminSetting> SetAdminSettingsAsync(AdminSetting AdminSettings)
|
||||||
|
{
|
||||||
|
return await PostJsonAsync<AdminSetting>(CreateAuthorizationPolicyUrl($"{Apiurl}", EntityNames.Module, AdminSettings.ModuleId), AdminSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Interfaces;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Services
|
|
||||||
{
|
|
||||||
public interface IReportSystemReportingService
|
|
||||||
{
|
|
||||||
Task<Reporting> CreateReportAsync(Reporting reporting);
|
|
||||||
Task<List<Reporting>> GetReportsAsync(int ModuleId);
|
|
||||||
Task<Reporting> GetReportAsync(int ReportableId, int ModuleId);
|
|
||||||
Task<Reporting> UpdateReport(Reporting reporting);
|
|
||||||
Task DeleteReportingAsync(int ReportingId, int ModuleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ReportSystemReportingService : IReportSystemReportingService, IReportingHandler
|
|
||||||
{
|
|
||||||
public void Report(IReportable reportable, string note)
|
|
||||||
{
|
|
||||||
CreateReportAsync(new Reporting
|
|
||||||
{ ModuleId = reportable.ModuleID, EntityId = reportable.EntityID, Note = note, Reason = "Default Reason" });
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<Reporting> CreateReportAsync(Reporting reporting)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<List<Reporting>> GetReportsAsync(int ModuleId)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<Reporting> GetReportAsync(int ReportableId, int ModuleId)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<Reporting> UpdateReport(Reporting Reporting)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task DeleteReportingAsync(int ReportingId, int ModuleId)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
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.AdminSettings.Services;
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
||||||
{
|
{
|
||||||
@@ -17,20 +14,9 @@ namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
|||||||
{
|
{
|
||||||
services.AddScoped<IAdminModulesService, AdminModulesService>();
|
services.AddScoped<IAdminModulesService, AdminModulesService>();
|
||||||
}
|
}
|
||||||
|
if (!services.Any(s => s.ServiceType == typeof(IAdminSettingsService)))
|
||||||
if (!services.Any(s => s.ServiceType == typeof(IReportingHandler)))
|
|
||||||
{
|
{
|
||||||
services.AddScoped<IReportingHandler, ReportSystemReportingService>();
|
services.AddScoped<IAdminSettingsService, AdminSettingsService>();
|
||||||
}
|
|
||||||
|
|
||||||
if (!services.Any(s => s.ServiceType == typeof(IReportSystemReportingService)))
|
|
||||||
{
|
|
||||||
services.AddScoped<IReportSystemReportingService, ReportSystemReportingService>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!services.Any(s => s.ServiceType == typeof(IReportUI)))
|
|
||||||
{
|
|
||||||
services.AddScoped<IReportUI, ReportComponent>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Package/SZUAbsolventenverein.Module.AdminModules.1.0.6.nupkg
Normal file
BIN
Package/SZUAbsolventenverein.Module.AdminModules.1.0.6.nupkg
Normal file
Binary file not shown.
@@ -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.2</version>
|
<version>1.0.6</version>
|
||||||
<authors>SZUAbsolventenverein</authors>
|
<authors>SZUAbsolventenverein</authors>
|
||||||
<owners>SZUAbsolventenverein</owners>
|
<owners>SZUAbsolventenverein</owners>
|
||||||
<title>AdminModules</title>
|
<title>AdminModules</title>
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ 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/"
|
||||||
cp -rf "../Server/wwwroot/"* "../../oqtane.framework/Oqtane.Server/wwwroot/_content/$ProjectName/"
|
cp -rf "../Server/wwwroot/"* "../../oqtane.framework/Oqtane.Server/wwwroot/"
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<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" />
|
|
||||||
</AssemblyExplorer></s:String></wpf:ResourceDictionary>
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Oqtane.Shared;
|
|
||||||
using Oqtane.Enums;
|
|
||||||
using Oqtane.Infrastructure;
|
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Services;
|
|
||||||
using Oqtane.Controllers;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Models;
|
|
||||||
using Oqtane.Models;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Controllers
|
|
||||||
{
|
|
||||||
[Route(ControllerRoutes.ApiRoute)]
|
|
||||||
public class ReportSystemController : ModuleControllerBase
|
|
||||||
{
|
|
||||||
private readonly IReportSystemReportingService _reportSystemReportingService;
|
|
||||||
|
|
||||||
public ReportSystemController(IReportSystemReportingService reportSystemReportingService, ILogManager logger, IHttpContextAccessor accessor) : base(logger, accessor)
|
|
||||||
{
|
|
||||||
_reportSystemReportingService = reportSystemReportingService;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: api/<controller>?moduleid=x
|
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
|
||||||
public async Task<IEnumerable<Reporting>> Get(string moduleid)
|
|
||||||
{
|
|
||||||
int ModuleId;
|
|
||||||
if (int.TryParse(moduleid, out ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
|
||||||
{
|
|
||||||
return await _reportSystemReportingService.GetReportsAsync(ModuleId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Get Attempt {ModuleId}", moduleid);
|
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET api/<controller>/5
|
|
||||||
[HttpGet("get/{id}/{moduleid}")]
|
|
||||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
|
||||||
public async Task<Reporting> Get(int id, int moduleid)
|
|
||||||
{
|
|
||||||
if (IsAuthorizedEntityId(EntityNames.Module, moduleid))
|
|
||||||
{
|
|
||||||
return await _reportSystemReportingService.GetReportAsync(id, moduleid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Get Attempt {Reporting} {ModuleId}", id, moduleid);
|
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST api/<controller>
|
|
||||||
[HttpPost]
|
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
|
||||||
public async Task<Reporting> Post([FromBody] Reporting Reporting)
|
|
||||||
{
|
|
||||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, Reporting.ModuleId))
|
|
||||||
{
|
|
||||||
Reporting = await _reportSystemReportingService.CreateReportAsync(Reporting);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Post Attempt {Reporting}", Reporting);
|
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
|
||||||
Reporting = null;
|
|
||||||
}
|
|
||||||
return Reporting;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT api/<controller>/5
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
|
||||||
public async Task<Reporting> Put(int id, [FromBody] Reporting Reporting)
|
|
||||||
{
|
|
||||||
if (ModelState.IsValid && Reporting.ReportingID == id && IsAuthorizedEntityId(EntityNames.Module, Reporting.ReportingID))
|
|
||||||
{
|
|
||||||
Reporting = await _reportSystemReportingService.UpdateReport(Reporting);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Put Attempt {Reporting}", Reporting);
|
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
|
||||||
Reporting = null;
|
|
||||||
}
|
|
||||||
return Reporting;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE api/<controller>/5
|
|
||||||
[HttpDelete("{id}/{moduleid}")]
|
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
|
||||||
public async Task Delete(int id, int moduleid)
|
|
||||||
{
|
|
||||||
Reporting Reporting = await _reportSystemReportingService.GetReportAsync(id, moduleid);
|
|
||||||
if (Reporting != null && IsAuthorizedEntityId(EntityNames.Module, Reporting.ReportingID))
|
|
||||||
{
|
|
||||||
await _reportSystemReportingService.DeleteReportingAsync(id, Reporting.ReportingID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Delete Attempt {ReportingID} {ModuleId}", id, moduleid);
|
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,11 +16,13 @@ namespace SZUAbsolventenverein.Module.AdminModules.Manager
|
|||||||
public class AdminModulesManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
public class AdminModulesManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
||||||
{
|
{
|
||||||
private readonly IAdminModulesRepository _AdminModulesRepository;
|
private readonly IAdminModulesRepository _AdminModulesRepository;
|
||||||
|
private readonly IAdminSettingsRepository _AdminSettingsRepository;
|
||||||
private readonly IDBContextDependencies _DBContextDependencies;
|
private readonly IDBContextDependencies _DBContextDependencies;
|
||||||
|
|
||||||
public AdminModulesManager(IAdminModulesRepository AdminModulesRepository, IDBContextDependencies DBContextDependencies)
|
public AdminModulesManager(IAdminModulesRepository AdminModulesRepository, IAdminSettingsRepository AdminSettingsRepository, IDBContextDependencies DBContextDependencies)
|
||||||
{
|
{
|
||||||
_AdminModulesRepository = AdminModulesRepository;
|
_AdminModulesRepository = AdminModulesRepository;
|
||||||
|
_AdminSettingsRepository = AdminSettingsRepository;
|
||||||
_DBContextDependencies = DBContextDependencies;
|
_DBContextDependencies = DBContextDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.Json;
|
|
||||||
using Oqtane.Modules;
|
|
||||||
using Oqtane.Models;
|
|
||||||
using Oqtane.Infrastructure;
|
|
||||||
using Oqtane.Interfaces;
|
|
||||||
using Oqtane.Enums;
|
|
||||||
using Oqtane.Repository;
|
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Repository;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
|
||||||
using Oqtane.Shared;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Manager
|
|
||||||
{
|
|
||||||
public class ReportSystemManager : MigratableModuleBase, IInstallable, IPortable, ISearchable
|
|
||||||
{
|
|
||||||
private readonly IReportingRepository _reportSystemRepository;
|
|
||||||
private readonly IDBContextDependencies _DBContextDependencies;
|
|
||||||
|
|
||||||
public ReportSystemManager(IReportingRepository reportSystemRepository, IDBContextDependencies DBContextDependencies)
|
|
||||||
{
|
|
||||||
_reportSystemRepository = reportSystemRepository;
|
|
||||||
_DBContextDependencies = DBContextDependencies;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Install(Tenant tenant, string version)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Installing ReportSystem module for tenant {TenantId}");
|
|
||||||
return Migrate(new ReportingContext(_DBContextDependencies), tenant, MigrationType.Up);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Uninstall(Tenant tenant)
|
|
||||||
{
|
|
||||||
return Migrate(new ReportingContext(_DBContextDependencies), tenant, MigrationType.Down);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ExportModule(Oqtane.Models.Module module)
|
|
||||||
{
|
|
||||||
string content = "";
|
|
||||||
List<Reporting> reportings = _reportSystemRepository.GetReportings().ToList();
|
|
||||||
if (reportings != null)
|
|
||||||
{
|
|
||||||
content = JsonSerializer.Serialize(reportings);
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ImportModule(Oqtane.Models.Module module, string content, string version)
|
|
||||||
{
|
|
||||||
List<Reporting> reportings = null;
|
|
||||||
if (!string.IsNullOrEmpty(content))
|
|
||||||
{
|
|
||||||
reportings = JsonSerializer.Deserialize<List<Reporting>>(content);
|
|
||||||
}
|
|
||||||
if (reportings != null)
|
|
||||||
{
|
|
||||||
foreach(var reporting in reportings)
|
|
||||||
{
|
|
||||||
_reportSystemRepository.AddReporting(reporting);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<List<SearchContent>> GetSearchContentsAsync(PageModule pageModule, DateTime lastIndexedOn)
|
|
||||||
{
|
|
||||||
var searchContentList = new List<SearchContent>();
|
|
||||||
|
|
||||||
return Task.FromResult(searchContentList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,13 +17,13 @@ namespace SZUAbsolventenverein.Module.AdminModules.Migrations
|
|||||||
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
var entityBuilder = new AdminModulesEntityBuilder(migrationBuilder, ActiveDatabase);
|
var massMailingTemplateEntityBuilder = new MassMailingTemplateEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||||
entityBuilder.Create();
|
massMailingTemplateEntityBuilder.Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
var entityBuilder = new AdminModulesEntityBuilder(migrationBuilder, ActiveDatabase);
|
var entityBuilder = new MassMailingTemplateEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||||
entityBuilder.Drop();
|
entityBuilder.Drop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,20 +7,20 @@ using Oqtane.Migrations.EntityBuilders;
|
|||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Migrations.EntityBuilders
|
namespace SZUAbsolventenverein.Module.AdminModules.Migrations.EntityBuilders
|
||||||
{
|
{
|
||||||
public class AdminModulesEntityBuilder : AuditableBaseEntityBuilder<AdminModulesEntityBuilder>
|
public class MassMailingTemplateEntityBuilder : AuditableBaseEntityBuilder<MassMailingTemplateEntityBuilder>
|
||||||
{
|
{
|
||||||
private const string _entityTableName = "SZUAbsolventenvereinAdminModules";
|
private const string _entityTableName = "SZUAbsolventenvereinAdminModules";
|
||||||
private readonly PrimaryKey<AdminModulesEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinAdminModules", x => x.AdminModulesId);
|
private readonly PrimaryKey<MassMailingTemplateEntityBuilder> _primaryKey = new("PK_SZUAbsolventenvereinAdminModules", x => x.AdminModulesId);
|
||||||
private readonly ForeignKey<AdminModulesEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinAdminModules_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
private readonly ForeignKey<MassMailingTemplateEntityBuilder> _moduleForeignKey = new("FK_SZUAbsolventenvereinAdminModules_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
public AdminModulesEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
public MassMailingTemplateEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||||
{
|
{
|
||||||
EntityTableName = _entityTableName;
|
EntityTableName = _entityTableName;
|
||||||
PrimaryKey = _primaryKey;
|
PrimaryKey = _primaryKey;
|
||||||
ForeignKeys.Add(_moduleForeignKey);
|
ForeignKeys.Add(_moduleForeignKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override AdminModulesEntityBuilder BuildTable(ColumnsBuilder table)
|
protected override MassMailingTemplateEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
{
|
{
|
||||||
AdminModulesId = AddAutoIncrementColumn(table,"AdminModulesId");
|
AdminModulesId = AddAutoIncrementColumn(table,"AdminModulesId");
|
||||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
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.AdminModules.Migrations.EntityBuilders;
|
|
||||||
|
|
||||||
public class ReportingEntityBuilder : AuditableBaseEntityBuilder<ReportingEntityBuilder>
|
|
||||||
{
|
|
||||||
private const string _entityTableName = "SZUAbsolventenvereinReportings";
|
|
||||||
private readonly PrimaryKey<ReportingEntityBuilder> _primaryKey = new ("PK_ReportingEntityBuilder", x => x.ReportingID);
|
|
||||||
|
|
||||||
public ReportingEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
|
||||||
{
|
|
||||||
EntityTableName = _entityTableName;
|
|
||||||
PrimaryKey = _primaryKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ReportingEntityBuilder BuildTable(ColumnsBuilder table)
|
|
||||||
{
|
|
||||||
ReportingID = AddAutoIncrementColumn(table, "ReportingID");
|
|
||||||
ModuleId = AddIntegerColumn(table, "ModuleId");
|
|
||||||
EntityId = AddIntegerColumn(table, "EntityId");
|
|
||||||
Note = AddMaxStringColumn(table, "Note");
|
|
||||||
Reason = AddMaxStringColumn(table, "Reason");
|
|
||||||
AddAuditableColumns(table);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationBuilder<AddColumnOperation> ReportingID { get; set; }
|
|
||||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
|
||||||
public OperationBuilder<AddColumnOperation> EntityId { get; set; }
|
|
||||||
public OperationBuilder<AddColumnOperation> Note { get; set; }
|
|
||||||
public OperationBuilder<AddColumnOperation> Reason { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Oqtane.Databases.Interfaces;
|
|
||||||
using Oqtane.Migrations;
|
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Migrations.EntityBuilders;
|
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ReportingContext))]
|
|
||||||
[Migration("SZUAbsolventenverein.Module.ReportSystem.01.00.00.00")]
|
|
||||||
public class InitializeModule : MultiDatabaseMigration
|
|
||||||
{
|
|
||||||
public InitializeModule(IDatabase database) : base(database)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
var entityBuilder = new ReportingEntityBuilder(migrationBuilder, ActiveDatabase);
|
|
||||||
entityBuilder.Create();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
var entityBuilder = new ReportingEntityBuilder(migrationBuilder, ActiveDatabase);
|
|
||||||
entityBuilder.Drop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@ using Oqtane.Modules;
|
|||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using Oqtane.Repository.Databases.Interfaces;
|
using Oqtane.Repository.Databases.Interfaces;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
||||||
{
|
{
|
||||||
91
Server/Repository/AdminSettingsRepository.cs
Normal file
91
Server/Repository/AdminSettingsRepository.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text.Json;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Models;
|
||||||
|
using Oqtane.Modules;
|
||||||
|
|
||||||
|
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Repository to manage admin settings in the database.
|
||||||
|
/// </summary>
|
||||||
|
public interface IAdminSettingsRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the administrative settings entry from the Database.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="Models.AdminSetting"/> object containing the settings for the specified module. Returns <see
|
||||||
|
/// langword="null"/> if the module is not found.</returns>
|
||||||
|
Models.AdminSetting GetAdminSetting();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the administrative settings with the specified values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="adminSetting">The new administrative settings to apply. Cannot be null.</param>
|
||||||
|
/// <returns>The updated <see cref="Models.AdminSetting"/> object reflecting the applied changes.</returns>
|
||||||
|
Models.AdminSetting SetAdminSettings(Models.AdminSetting adminSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implementation of the <see cref="IAdminSettingsRepository"/> interface for managing admin settings in the database.
|
||||||
|
/// </summary>
|
||||||
|
public class AdminSettingsRepository : IAdminSettingsRepository, ITransientService
|
||||||
|
{
|
||||||
|
public AdminSettingsRepository()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdminSetting GetAdminSetting()
|
||||||
|
{
|
||||||
|
return AdminSettingsExtensions.LoadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdminSetting SetAdminSettings(AdminSetting adminSetting)
|
||||||
|
{
|
||||||
|
return adminSetting.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for saving and loading admin settings to/from a JSON file.
|
||||||
|
/// </summary>
|
||||||
|
public static class AdminSettingsExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Path to the JSON file where admin settings are stored.
|
||||||
|
/// </summary>
|
||||||
|
private static string path = "AdminSettings.json";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the adminSettingsObject to a JSON file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="adminSetting">Settings to save</param>
|
||||||
|
/// <returns>The same AdminSettings object for chaining of Operations</returns>
|
||||||
|
public static AdminSetting SaveChanges(this AdminSetting adminSetting)
|
||||||
|
{
|
||||||
|
string res = JsonSerializer.Serialize(adminSetting);
|
||||||
|
|
||||||
|
File.WriteAllText(path, res);
|
||||||
|
|
||||||
|
return adminSetting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the admin settings from the JSON file. If the file does not exist, returns a new AdminSetting object with default (0) values.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static AdminSetting LoadSettings()
|
||||||
|
{
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(path);
|
||||||
|
return JsonSerializer.Deserialize<AdminSetting>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AdminSetting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Oqtane.Modules;
|
|
||||||
using Oqtane.Repository;
|
|
||||||
using Oqtane.Infrastructure;
|
|
||||||
using Oqtane.Repository.Databases.Interfaces;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Repository
|
|
||||||
{
|
|
||||||
public class ReportingContext : DBContextBase, ITransientService, IMultiDatabase
|
|
||||||
{
|
|
||||||
public virtual DbSet<Reporting> Reportings { get; set; }
|
|
||||||
|
|
||||||
public ReportingContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
|
|
||||||
{}
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
|
||||||
{
|
|
||||||
base.OnModelCreating(builder);
|
|
||||||
builder.Entity<Reporting>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinReportings"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Oqtane.Modules;
|
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Repository
|
|
||||||
{
|
|
||||||
public interface IReportingRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Reporting> GetReportings();
|
|
||||||
Reporting GetReporting(int ReportingID);
|
|
||||||
Reporting GetReporting(int ReportingID, bool tracking);
|
|
||||||
Reporting AddReporting(Reporting Reporting);
|
|
||||||
Reporting UpdateReporting(Reporting Reporting);
|
|
||||||
void DeleteReporting(int ReportingID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ReportingRepository : IReportingRepository, ITransientService
|
|
||||||
{
|
|
||||||
private readonly IDbContextFactory<ReportingContext> _factory;
|
|
||||||
|
|
||||||
public ReportingRepository(IDbContextFactory<ReportingContext> factory)
|
|
||||||
{
|
|
||||||
_factory = factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Reporting> GetReportings()
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
return db.Reportings.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Reporting GetReporting(int ReportingID)
|
|
||||||
{
|
|
||||||
return GetReporting(ReportingID, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Reporting GetReporting(int ReportingID, bool tracking)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
if (tracking)
|
|
||||||
{
|
|
||||||
return db.Reportings.Find(ReportingID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return db.Reportings.AsNoTracking().FirstOrDefault(item => item.ReportingID == ReportingID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Reporting AddReporting(Reporting Reporting)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.Reportings.Add(Reporting);
|
|
||||||
db.SaveChanges();
|
|
||||||
return Reporting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Reporting UpdateReporting(Reporting Reporting)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
db.Entry(Reporting).State = EntityState.Modified;
|
|
||||||
db.SaveChanges();
|
|
||||||
return Reporting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteReporting(int ReportingID)
|
|
||||||
{
|
|
||||||
using var db = _factory.CreateDbContext();
|
|
||||||
var Reporting = db.Reportings.Find(ReportingID);
|
|
||||||
db.Reportings.Remove(Reporting);
|
|
||||||
db.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,9 +31,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Interfaces">
|
|
||||||
<HintPath>..\..\interfaces\Interfaces\bin\Debug\net10.0\Interfaces.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<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>
|
||||||
|
|||||||
@@ -168,8 +168,8 @@ namespace SZUAbsolventenverein.Module.AdminModules.Services
|
|||||||
User user = _userRepository.GetUser(userid);
|
User user = _userRepository.GetUser(userid);
|
||||||
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||||
string body = template.Content;
|
string body = template.Content;
|
||||||
|
|
||||||
// Fields bef<EFBFBD>llen.
|
// Fields befüllen.
|
||||||
string token = await _identityUserManager.GeneratePasswordResetTokenAsync(identityuser);
|
string token = await _identityUserManager.GeneratePasswordResetTokenAsync(identityuser);
|
||||||
string url = _alias.Protocol + _alias.Name + "/reset?name=" + user.Username + "&token=" + WebUtility.UrlEncode(token);
|
string url = _alias.Protocol + _alias.Name + "/reset?name=" + user.Username + "&token=" + WebUtility.UrlEncode(token);
|
||||||
|
|
||||||
|
|||||||
77
Server/Services/AdminSettingsService.cs
Normal file
77
Server/Services/AdminSettingsService.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Oqtane.Enums;
|
||||||
|
using Oqtane.Extensions;
|
||||||
|
using Oqtane.Infrastructure;
|
||||||
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
using Oqtane.Security;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Models;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
||||||
|
using SZUAbsolventenverein.Module.AdminSettings.Services;
|
||||||
|
|
||||||
|
namespace SZUAbsolventenverein.Module.AdminModules.Services
|
||||||
|
{
|
||||||
|
public class ServerAdminSettingsService : IAdminSettingsService
|
||||||
|
{
|
||||||
|
private readonly IAdminSettingsRepository _AdminSettingsRepository;
|
||||||
|
private readonly UserManager<IdentityUser> _identityUserManager;
|
||||||
|
private readonly IUserPermissions _userPermissions;
|
||||||
|
private readonly IRoleRepository _roleRepository;
|
||||||
|
private readonly IUserRepository _userRepository;
|
||||||
|
private readonly IUserRoleRepository _userRoleRepository;
|
||||||
|
private readonly INotificationRepository _notifications;
|
||||||
|
private readonly ILogManager _logger;
|
||||||
|
private readonly IHttpContextAccessor _accessor;
|
||||||
|
private readonly Alias _alias;
|
||||||
|
|
||||||
|
public ServerAdminSettingsService(IAdminSettingsRepository AdminSettingsRepository, UserManager<IdentityUser> identityUserManager, INotificationRepository notifications, IUserPermissions userPermissions, IRoleRepository roleRepository, IUserRepository userRepository, IUserRoleRepository userRoleRepository, ITenantManager tenantManager, ILogManager logger, IHttpContextAccessor accessor)
|
||||||
|
{
|
||||||
|
_AdminSettingsRepository = AdminSettingsRepository;
|
||||||
|
_identityUserManager = identityUserManager;
|
||||||
|
_userPermissions = userPermissions;
|
||||||
|
_roleRepository = roleRepository;
|
||||||
|
_userRepository = userRepository;
|
||||||
|
_userRoleRepository = userRoleRepository;
|
||||||
|
_notifications = notifications;
|
||||||
|
_logger = logger;
|
||||||
|
_accessor = accessor;
|
||||||
|
_alias = tenantManager.GetAlias();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<AdminSetting> GetAdminSettingsAsync(int ModuleId)
|
||||||
|
{
|
||||||
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
||||||
|
{
|
||||||
|
return Task.FromResult(_AdminSettingsRepository.GetAdminSetting());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AdminModules Get Attempt {ModuleId}", ModuleId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<AdminSetting> SetAdminSettingsAsync(AdminSetting AdminSettings)
|
||||||
|
{
|
||||||
|
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, 1, PermissionNames.View))
|
||||||
|
{
|
||||||
|
_logger.Log(LogLevel.Critical, this, LogFunction.Update, "Set AdminSettings");
|
||||||
|
return Task.FromResult(_AdminSettingsRepository.SetAdminSettings(AdminSettings));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized AdminModules Get Attempt {ModuleId}", 1);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Interfaces;
|
|
||||||
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(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)
|
|
||||||
{
|
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.ModuleDefinition, _moduleDefinitionId, PermissionNames.Utilize))
|
|
||||||
{
|
|
||||||
_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 create attempt {Reporting}", Reporting);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<List<Reporting>> GetReportsAsync(int ModuleId)
|
|
||||||
{
|
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
|
||||||
{
|
|
||||||
return Task.FromResult(_reportSystemRepository.GetReportings().ToList());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reportings Get Attempt {ModuleId}", ModuleId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<Reporting> GetReportAsync(int ReportableId, int ModuleId)
|
|
||||||
{
|
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.View))
|
|
||||||
{
|
|
||||||
return Task.FromResult(_reportSystemRepository.GetReporting(ReportableId));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Get Attempt {ModuleId} {ReportableId}", ModuleId, ReportableId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<Reporting> UpdateReport(Reporting Reporting)
|
|
||||||
{
|
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, Reporting.ReportingID, PermissionNames.Edit))
|
|
||||||
{
|
|
||||||
Reporting = _reportSystemRepository.UpdateReporting(Reporting);
|
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Reporting Updated {Reporting}", Reporting);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Update Attempt {Reporting}", Reporting);
|
|
||||||
Reporting = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.FromResult(Reporting);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task DeleteReportingAsync(int ReportingId, int ModuleId)
|
|
||||||
{
|
|
||||||
if (_userPermissions.IsAuthorized(_accessor.HttpContext.User, _alias.SiteId, EntityNames.Module, ModuleId, PermissionNames.Edit))
|
|
||||||
{
|
|
||||||
_reportSystemRepository.DeleteReporting(ReportingId);
|
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Reporting Deleted {ReportingId}", ReportingId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Delete Attempt {ReportingId} {ModuleId}", ReportingId, ModuleId);
|
|
||||||
}
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Report(IReportable reportable, string note)
|
|
||||||
{
|
|
||||||
// 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"});
|
|
||||||
if (reporting != null)
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Reporting recieved {ReportingId}", reporting.ReportingID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// else
|
|
||||||
{
|
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Reporting Delete Attempt {EntityId} {ModuleId}", reportable.EntityID, reportable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using Interfaces;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
|
using System;
|
||||||
|
using SZUAbsolventenverein.Module.AdminModules.Models;
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
||||||
using SZUAbsolventenverein.Module.AdminModules.Services;
|
using SZUAbsolventenverein.Module.AdminModules.Services;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Repository;
|
using SZUAbsolventenverein.Module.AdminSettings.Services;
|
||||||
using SZUAbsolventenverein.Module.ReportSystem.Services;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
||||||
{
|
{
|
||||||
@@ -25,10 +26,28 @@ namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
|||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddTransient<IAdminModulesService, ServerAdminModulesService>();
|
services.AddTransient<IAdminModulesService, ServerAdminModulesService>();
|
||||||
services.AddTransient<IReportSystemReportingService, ServerReportSystemReportingService>();
|
services.AddTransient<IAdminSettingsService, ServerAdminSettingsService>();
|
||||||
services.AddTransient<IReportingHandler, ServerReportSystemReportingService>();
|
services.AddTransient<IAdminSettingsRepository, AdminSettingsRepository>();
|
||||||
services.AddDbContextFactory<AdminModulesContext>(opt => { }, ServiceLifetime.Transient);
|
services.AddDbContextFactory<AdminModulesContext>(opt => { }, ServiceLifetime.Transient);
|
||||||
services.AddDbContextFactory<ReportingContext>(opt => { }, ServiceLifetime.Transient);
|
|
||||||
|
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
||||||
|
{
|
||||||
|
options.TokenLifespan = TimeSpan.FromDays(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AdminSetting settings = AdminSettingsExtensions.LoadSettings();
|
||||||
|
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
||||||
|
{
|
||||||
|
options.TokenLifespan = TimeSpan.FromDays(settings.TokenLifetime);
|
||||||
|
});
|
||||||
|
Console.WriteLine("Saving token lifetime: " + settings.TokenLifetime + " days");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
Shared/Models/AdminSettings.cs
Normal file
17
Shared/Models/AdminSettings.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Oqtane.Models;
|
||||||
|
|
||||||
|
namespace SZUAbsolventenverein.Module.AdminModules.Models
|
||||||
|
{
|
||||||
|
[Table("SZUAbsolventenvereinAdminSettings")]
|
||||||
|
public class AdminSetting
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int AdminSettingsId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public int ModuleId { get; set; }
|
||||||
|
public int TokenLifetime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using Oqtane.Models;
|
|
||||||
|
|
||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Models;
|
|
||||||
|
|
||||||
public class Reporting : IAuditable
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public int ReportingID { get; set; }
|
|
||||||
public int ModuleId { get; set; }
|
|
||||||
public int EntityId { get; set; }
|
|
||||||
public string Note { 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; }
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace SZUAbsolventenverein.Module.ReportSystem.Permissions
|
|
||||||
{
|
|
||||||
public class ReportSystemPermissionNames
|
|
||||||
{
|
|
||||||
public const string Report = "Report";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user