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:
@@ -1,4 +1,5 @@
|
||||
using JobsMedical.Web.Models;
|
||||
using JobsMedical.Web.Services;
|
||||
using JobsMedical.Web.Services.Scraping;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -10,7 +11,12 @@ namespace JobsMedical.Web.Pages.Admin;
|
||||
public class SettingsModel : PageModel
|
||||
{
|
||||
private readonly SettingsService _settings;
|
||||
public SettingsModel(SettingsService settings) => _settings = settings;
|
||||
private readonly ISmsSender _sms;
|
||||
public SettingsModel(SettingsService settings, ISmsSender sms)
|
||||
{
|
||||
_settings = settings;
|
||||
_sms = sms;
|
||||
}
|
||||
|
||||
[BindProperty] public IngestionMode Mode { get; set; }
|
||||
[BindProperty] public int AutoPublishMinConfidence { get; set; }
|
||||
@@ -41,7 +47,9 @@ public class SettingsModel : PageModel
|
||||
[BindProperty] public string? VapidPublicKey { get; set; }
|
||||
[BindProperty] public string? VapidPrivateKey { get; set; }
|
||||
[BindProperty] public string? VapidSubject { get; set; }
|
||||
[BindProperty] public string? TestPhone { get; set; }
|
||||
[TempData] public string? Saved { get; set; }
|
||||
[TempData] public string? SmsTest { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
@@ -112,4 +120,19 @@ public class SettingsModel : PageModel
|
||||
Saved = "تنظیمات ذخیره شد.";
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostTestSmsAsync()
|
||||
{
|
||||
var s = await _settings.GetAsync();
|
||||
var phone = OtpService.Normalize(TestPhone ?? "");
|
||||
if (phone.Length < 10) { SmsTest = "شماره معتبر وارد کنید."; return RedirectToPage(); }
|
||||
if (!s.SmsEnabled) { SmsTest = "ابتدا SMS را فعال و ذخیره کنید."; return RedirectToPage(); }
|
||||
try
|
||||
{
|
||||
var ok = await _sms.SendOtpAsync(phone, Random.Shared.Next(10000, 100000).ToString(), s);
|
||||
SmsTest = ok ? $"پیامک آزمایشی به {phone} ارسال شد." : "ارسال ناموفق بود (پاسخ منفی از سرویس).";
|
||||
}
|
||||
catch (Exception ex) { SmsTest = "خطا در ارسال: " + ex.Message; }
|
||||
return RedirectToPage();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user