Admin suite: monitoring dashboard, user management/ban, broadcast, reports, SMS test
- /Admin/Overview: platform monitoring stats (users by role, facilities, listings, applies, push subs, queue, reports, bans) - /Admin/Users: search/filter + ban/unban (User.IsBanned + reason); banned users blocked at login - /Admin/Broadcast: send announcement (in-app + web push) to all / staff / employers via NotificationService - Reports: report button on shift/job detail → /report endpoint → /Admin/Reports (resolve/dismiss) - Settings: 'send test SMS' button; admin cross-nav links; SMS API config already in place - migration AdminBanReports; verified overview/users/broadcast/report persist Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using JobsMedical.Web.Data;
|
||||
using JobsMedical.Web.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace JobsMedical.Web.Pages.Admin;
|
||||
|
||||
[Authorize(Roles = "Admin")]
|
||||
public class ReportsModel : PageModel
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
public ReportsModel(AppDbContext db) => _db = db;
|
||||
|
||||
public List<Report> Reports { get; private set; } = new();
|
||||
|
||||
public async Task OnGetAsync() =>
|
||||
Reports = await _db.Reports
|
||||
.OrderBy(r => r.Status).ThenByDescending(r => r.CreatedAt)
|
||||
.Take(200).ToListAsync();
|
||||
|
||||
public async Task<IActionResult> OnPostResolveAsync(int id) => await SetStatus(id, ReportStatus.Resolved);
|
||||
public async Task<IActionResult> OnPostDismissAsync(int id) => await SetStatus(id, ReportStatus.Dismissed);
|
||||
|
||||
private async Task<IActionResult> SetStatus(int id, ReportStatus st)
|
||||
{
|
||||
var r = await _db.Reports.FindAsync(id);
|
||||
if (r is null) return NotFound();
|
||||
r.Status = st;
|
||||
await _db.SaveChangesAsync();
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
public static string TargetUrl(Report r) => r.TargetType switch
|
||||
{
|
||||
ReportTargetType.Shift => $"/Shifts/Details/{r.TargetId}",
|
||||
ReportTargetType.Job => $"/Jobs/Details/{r.TargetId}",
|
||||
ReportTargetType.Facility => "/Admin/Facilities",
|
||||
_ => "/Admin/Users",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user