180 lines
7.9 KiB
Plaintext
180 lines
7.9 KiB
Plaintext
@using SZUAbsolventenverein.Module.PremiumArea.Services
|
|
@using SZUAbsolventenverein.Module.PremiumArea.Models
|
|
@namespace SZUAbsolventenverein.Module.PremiumArea
|
|
@inherits ModuleBase
|
|
@inject IEngineerApplicationService ApplicationService
|
|
@inject NavigationManager NavManager
|
|
|
|
<h3>Ingenieur-Anträge Prüfen</h3>
|
|
|
|
@if (_applications == null)
|
|
{
|
|
<p>Laden...</p>
|
|
}
|
|
else
|
|
{
|
|
<div class="row">
|
|
<div class="col-md-7">
|
|
<div class="mb-3">
|
|
<div class="btn-group" role="group">
|
|
<input type="radio" class="btn-check" name="statusfilter" id="filterValidation" autocomplete="off" checked="@(_filterStatus == "Validation")" @onchange="@(() => _filterStatus = "Validation")">
|
|
<label class="btn btn-outline-primary" for="filterValidation">Validierung (Entwurf/Eingereicht)</label>
|
|
|
|
<input type="radio" class="btn-check" name="statusfilter" id="filterApproved" autocomplete="off" checked="@(_filterStatus == "Approved")" @onchange="@(() => _filterStatus = "Approved")">
|
|
<label class="btn btn-outline-success" for="filterApproved">Genehmigt</label>
|
|
|
|
<input type="radio" class="btn-check" name="statusfilter" id="filterRejected" autocomplete="off" checked="@(_filterStatus == "Rejected")" @onchange="@(() => _filterStatus = "Rejected")">
|
|
<label class="btn btn-outline-danger" for="filterRejected">Abgelehnt</label>
|
|
|
|
<input type="radio" class="btn-check" name="statusfilter" id="filterReported" autocomplete="off" checked="@(_filterStatus == "Reported")" @onchange="@(() => _filterStatus = "Reported")">
|
|
<label class="btn btn-outline-warning" for="filterReported">Gemeldet</label>
|
|
</div>
|
|
</div>
|
|
|
|
@if (FilteredApplications.Count == 0)
|
|
{
|
|
<p>Keine Anträge gefunden.</p>
|
|
}
|
|
else
|
|
{
|
|
<table class="table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Benutzer ID</th>
|
|
<th>Dateiname</th>
|
|
<th>Datum</th>
|
|
<th>Status</th>
|
|
@if (_filterStatus == "Reported")
|
|
{
|
|
<th>Meldegrund</th>
|
|
}
|
|
<th>Aktionen</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var app in FilteredApplications)
|
|
{
|
|
<tr @onclick="@(() => SelectApp(app))" style="cursor: pointer;" class="@(_selectedApp == app ? "table-active" : "")">
|
|
<td>@app.UserId</td>
|
|
<td>@app.PdfFileName</td>
|
|
<td>@(app.SubmittedOn?.ToShortDateString() ?? app.CreatedOn.ToShortDateString())</td>
|
|
<td>
|
|
@app.Status
|
|
@if(app.IsReported) { <span class="badge bg-warning text-dark">Gemeldet</span> }
|
|
</td>
|
|
@if (_filterStatus == "Reported")
|
|
{
|
|
<td class="text-danger">@app.ReportReason</td>
|
|
}
|
|
<td>
|
|
<button class="btn btn-sm btn-primary" @onclick="@((e) => SelectApp(app))">Prüfen</button>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
</div>
|
|
<div class="col-md-5">
|
|
@if (_selectedApp != null)
|
|
{
|
|
<div class="card">
|
|
<div class="card-header">
|
|
Antragsdetails
|
|
</div>
|
|
<div class="card-body">
|
|
<dl class="row">
|
|
<dt class="col-sm-4">Benutzer ID</dt>
|
|
<dd class="col-sm-8">@_selectedApp.UserId</dd>
|
|
<dt class="col-sm-4">Datei</dt>
|
|
<dd class="col-sm-8">@_selectedApp.PdfFileName</dd>
|
|
<dt class="col-sm-4">Status</dt>
|
|
<dd class="col-sm-8">@_selectedApp.Status</dd>
|
|
@if (_selectedApp.IsReported)
|
|
{
|
|
<dt class="col-sm-4 text-danger">Meldegrund</dt>
|
|
<dd class="col-sm-8 text-danger">@_selectedApp.ReportReason (Anzahl: @_selectedApp.ReportCount)</dd>
|
|
}
|
|
</dl>
|
|
|
|
<div class="mb-3">
|
|
<div class="ratio ratio-16x9">
|
|
<iframe src="@((NavManager.BaseUri + "api/engineerapplication") + "/download/" + _selectedApp.ApplicationId + "?moduleid=" + ModuleState.ModuleId)" allowfullscreen></iframe>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-grid gap-2">
|
|
@if (_selectedApp.Status != "Approved" || _selectedApp.IsReported)
|
|
{
|
|
<button class="btn @(_selectedApp.IsReported ? "btn-warning" : "btn-success")" @onclick="ApproveApp">
|
|
@(_selectedApp.IsReported ? "Meldung verwerfen / Behalten" : "Genehmigen & Premium gewähren")
|
|
</button>
|
|
}
|
|
@if (_selectedApp.Status != "Rejected")
|
|
{
|
|
<button class="btn btn-danger" @onclick="RejectApp">Ablehnen / Löschen</button>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; // Admin Only
|
|
|
|
private List<EngineerApplication> _applications;
|
|
private EngineerApplication _selectedApp;
|
|
private string _filterStatus = "Validation";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadApps();
|
|
}
|
|
|
|
private async Task LoadApps()
|
|
{
|
|
// Load All applications
|
|
_applications = await ApplicationService.GetApplicationsAsync(ModuleState.ModuleId);
|
|
}
|
|
|
|
private List<EngineerApplication> FilteredApplications
|
|
{
|
|
get
|
|
{
|
|
if (_applications == null) return new List<EngineerApplication>();
|
|
if (_filterStatus == "Validation")
|
|
return _applications.Where(a => a.Status == "Draft" || a.Status == "Submitted" || a.Status == "Published").ToList();
|
|
|
|
if (_filterStatus == "Reported")
|
|
return _applications.Where(a => a.IsReported).ToList();
|
|
|
|
return _applications.Where(a => a.Status == _filterStatus).ToList();
|
|
}
|
|
}
|
|
|
|
private void SelectApp(EngineerApplication app)
|
|
{
|
|
_selectedApp = app;
|
|
}
|
|
|
|
private async Task ApproveApp()
|
|
{
|
|
if (_selectedApp == null) return;
|
|
await ApplicationService.ApproveApplicationAsync(_selectedApp.ApplicationId, ModuleState.ModuleId);
|
|
await LoadApps();
|
|
_selectedApp = null;
|
|
}
|
|
|
|
private async Task RejectApp()
|
|
{
|
|
if (_selectedApp == null) return;
|
|
// Basic rejection without custom reason for now since UI input was removed
|
|
await ApplicationService.RejectApplicationAsync(_selectedApp.ApplicationId, ModuleState.ModuleId, "Abgelehnt durch Admin");
|
|
await LoadApps();
|
|
_selectedApp = null;
|
|
}
|
|
}
|