[Admin] Notification channel toggles (web/SMS/push active-deactive)
Add a 'notification channels' card at the top of admin Settings with three master on/off checkboxes: web/in-app (new WebNotificationsEnabled, default true), SMS (existing SmsEnabled), and Web Push (existing PushEnabled). Removed the duplicate enable checkboxes from the SMS and Push sections so each binds once. NotificationService now gates the in-app + live SSE channel on WebNotificationsEnabled; push self-gates on PushEnabled. Migration defaults the new column to true so existing installs keep web notifications on. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,32 @@
|
||||
<div class="alert alert-success">✓ @Model.Saved</div>
|
||||
}
|
||||
<form method="post" class="card card-pad">
|
||||
<h3 style="margin-top:0;">کانالهای اعلان (فعال / غیرفعال)</h3>
|
||||
<p class="muted" style="font-size:12px; margin-top:0;">روشن/خاموشکردن هر کانال ارسال اعلان به کاربران. کلیدها و تنظیمات هر کانال در بخشهای پایینتر.</p>
|
||||
<div class="filter-group">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
|
||||
<input type="checkbox" name="WebNotificationsEnabled" value="true" style="width:auto;" checked="@Model.WebNotificationsEnabled" />
|
||||
اعلانهای وب / درونبرنامهای (زنگوله + نوتیف زنده) — توصیهشده برای ایران
|
||||
</label>
|
||||
<p class="muted" style="font-size:12px; margin:4px 0 0;">از طریق سرور خودمان ارسال میشود؛ نیازی به سرویسهای گوگل ندارد و در ایران کار میکند.</p>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
|
||||
<input type="checkbox" name="SmsEnabled" value="true" style="width:auto;" checked="@Model.SmsEnabled" />
|
||||
پیامک (SMS) — کاوهنگار
|
||||
</label>
|
||||
<p class="muted" style="font-size:12px; margin:4px 0 0;">برای کد ورود و اعلانهای مهم. کلید و تمپلیت را در بخش «پیامک ورود» پایین وارد کن.</p>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
|
||||
<input type="checkbox" name="PushEnabled" value="true" style="width:auto;" checked="@Model.PushEnabled" />
|
||||
پوش مرورگر (Web Push) — بهترین تلاش
|
||||
</label>
|
||||
<p class="muted" style="font-size:12px; margin:4px 0 0;">برای اعلان هنگام بستهبودن برنامه؛ ولی از سرویس مرورگر (گوگل) عبور میکند که در ایران اغلب فیلتر است.</p>
|
||||
</div>
|
||||
|
||||
<hr style="border:none; border-top:1px solid var(--line); margin:18px 0;" />
|
||||
|
||||
<h3 style="margin-top:0;">حالت انتشار</h3>
|
||||
<div class="filter-group">
|
||||
<label>نحوه افزودن آگهیها به سایت</label>
|
||||
@@ -156,12 +182,7 @@
|
||||
<hr style="border:none; border-top:1px solid var(--line); margin:18px 0;" />
|
||||
|
||||
<h3 style="margin-top:0;">پیامک ورود (OTP) — کاوهنگار</h3>
|
||||
<div class="filter-group">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
|
||||
<input type="checkbox" name="SmsEnabled" value="true" style="width:auto;" checked="@Model.SmsEnabled" />
|
||||
ارسال کد ورود با پیامک (در صورت خاموش بودن، کد روی صفحه نمایش داده میشود)
|
||||
</label>
|
||||
</div>
|
||||
<p class="muted" style="font-size:12px; margin-top:0;">روشن/خاموشکردن این کانال در بخش «کانالهای اعلان» بالا. (در صورت خاموش بودن، کد ورود روی صفحه نمایش داده میشود.)</p>
|
||||
<div class="filter-group">
|
||||
<label>کلید API کاوهنگار</label>
|
||||
<input type="password" name="SmsApiKey" value="@Model.SmsApiKey" dir="ltr" />
|
||||
@@ -182,12 +203,7 @@
|
||||
|
||||
<hr style="border:none; border-top:1px solid var(--line); margin:18px 0;" />
|
||||
<h3 style="margin-top:0;">اعلانها (Web Push / PWA)</h3>
|
||||
<div class="filter-group">
|
||||
<label style="display:flex; align-items:center; gap:8px; font-weight:700;">
|
||||
<input type="checkbox" name="PushEnabled" value="true" style="width:auto;" checked="@Model.PushEnabled" />
|
||||
فعالسازی اشتراک اعلان مرورگری
|
||||
</label>
|
||||
</div>
|
||||
<p class="muted" style="font-size:12px; margin-top:0;">روشن/خاموشکردن این کانال در بخش «کانالهای اعلان» بالا. اینجا فقط کلیدهای VAPID را وارد کن.</p>
|
||||
<div class="filter-group">
|
||||
<label>VAPID Public Key</label>
|
||||
<input type="text" name="VapidPublicKey" value="@Model.VapidPublicKey" dir="ltr" />
|
||||
|
||||
@@ -46,6 +46,7 @@ public class SettingsModel : PageModel
|
||||
[BindProperty] public string? SmsTemplate { get; set; }
|
||||
[BindProperty] public string? SmsSender { get; set; }
|
||||
[BindProperty] public string? NeshanMapKey { get; set; }
|
||||
[BindProperty] public bool WebNotificationsEnabled { get; set; }
|
||||
[BindProperty] public bool PushEnabled { get; set; }
|
||||
[BindProperty] public string? VapidPublicKey { get; set; }
|
||||
[BindProperty] public string? VapidPrivateKey { get; set; }
|
||||
@@ -88,6 +89,7 @@ public class SettingsModel : PageModel
|
||||
DemoMode = s.DemoMode;
|
||||
WebsitesEnabled = s.WebsitesEnabled;
|
||||
WebsiteUrls = s.WebsiteUrls;
|
||||
WebNotificationsEnabled = s.WebNotificationsEnabled;
|
||||
PushEnabled = s.PushEnabled;
|
||||
VapidPublicKey = s.VapidPublicKey;
|
||||
VapidPrivateKey = s.VapidPrivateKey;
|
||||
@@ -125,6 +127,7 @@ public class SettingsModel : PageModel
|
||||
DemoMode = DemoMode,
|
||||
WebsitesEnabled = WebsitesEnabled,
|
||||
WebsiteUrls = WebsiteUrls,
|
||||
WebNotificationsEnabled = WebNotificationsEnabled,
|
||||
PushEnabled = PushEnabled,
|
||||
VapidPublicKey = VapidPublicKey,
|
||||
VapidPrivateKey = VapidPrivateKey,
|
||||
|
||||
Reference in New Issue
Block a user