divan/GanjooRazor/Areas/User/Pages/Notifications.cshtml
2022-02-15 20:07:12 +03:30

171 lines
5.6 KiB
Plaintext

@page
@model GanjooRazor.Areas.User.Pages.NotificationsModel
@using DNTPersianUtils.Core
@{
Layout = "_UserPanelLayout";
ViewData["Title"] = "اعلان‌های من";
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
string color = "gray";
}
<h1>@ViewData["Title"]</h1>
@if (Model.LastError != "")
{
<h2>@Model.LastError</h2>
}
else
{
<script>
function deleteNotification(notificationId) {
if (!confirm('آیا از حذف این اعلان اطمینان دارید؟'))
return;
var url = '?handler=Notification';
$.ajax({
type: "DELETE",
url: url,
data: {
id: notificationId
},
success: function () {
var notificationBlockId = '#notification-' + notificationId;
$(notificationBlockId).remove();
},
});
}
function markReadNotification(notificationId) {
var url = '?handler=MarkRead';
$.ajax({
type: "PUT",
url: url,
data: {
id: notificationId
},
success: function () {
var notificationBlockId = '#unread-' + notificationId;
$(notificationBlockId).remove();
},
});
}
function markAllRead() {
if (!confirm('آیا از علامتگذاری همهٔ اعلانها به عنوان خوانده شده اطمینان دارید؟'))
return;
var url = '?handler=MarkAllRead';
$.ajax({
type: "PUT",
url: url,
error: function (e) {
if (e.responseText == null)
alert(e);
else
alert(e.responseText);
},
success: function () {
location.reload();
},
});
}
function deleteAllRead() {
if (!confirm('آیا از حذف همهٔ اعلانهای خوانده شده اطمینان دارید؟'))
return;
var url = '?handler=AllRead';
$.ajax({
type: "DELETE",
url: url,
error: function (e) {
if (e.responseText == null)
alert(e);
else
alert(e.responseText);
},
success: function () {
location.reload();
},
});
}
</script>
<p style="text-align:center">
@foreach (var paginationLink in Model.PaginationLinks)
{
if (!string.IsNullOrEmpty(paginationLink.Url))
{
<a href="@paginationLink.Url">@paginationLink.Name</a>
}
else
{
@paginationLink.Name
}
}
</p>
@if (Model.Notifications.Count == 0)
{
<p>
در حال حاضر اعلانی وجود ندارد. در صورتی که کاربری با زدن دکمهٔ «پاسخگویی» برای حاشیهٔ شما پاسخی بنویسد یا شما با پیشنهاد آهنگ مرتبط با شعر یا روش دیگری در گنجور مشارکت کنید و مشارکت شما بررسی شود در قسمت «اعلان‌های من» با دریافت یک اعلان از این رویدادها مطلع می شوید.
</p>
}
else
{
<p>
<a role="button" onclick="markAllRead()" class="pagebutton">همه را خواندم</a>
</p>
<p>
<a role="button" onclick="deleteAllRead()" class="pagebutton">حذف همهٔ خوانده شده‌ها</a>
</p>
}
@foreach (var notification in Model.Notifications)
{
if (color == "gray")
color = "white";
else
color = "gray";
<div style="background-color:@color" id="notification-@notification.Id">
<blockquote>
<p>
@notification.Subject <small>در @notification.DateTime.ToFriendlyPersianDateTextify()</small>
</p>
<div id="notification-text-@notification.Id">
@Html.Raw(notification.HtmlText)
</div>
</blockquote>
<p>
<a role="button" onclick="deleteNotification('@notification.Id')" class="actionlink" title="حذف"><i class="noindent-info-button delete-icon"></i></a>
@if (notification.Status == RSecurityBackend.Models.Notification.NotificationStatus.Unread)
{
<a role="button" onclick="markReadNotification('@notification.Id')" class="actionlink" title="خواندم" id="unread-@notification.Id"><i class="noindent-info-button done-icon"></i></a>
}
</p>
</div>
<hr />
}
<p style="text-align:center">
@foreach (var paginationLink in Model.PaginationLinks)
{
if (!string.IsNullOrEmpty(paginationLink.Url))
{
<a href="@paginationLink.Url">@paginationLink.Name</a>
}
else
{
@paginationLink.Name
}
}
</p>
}