mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Mark read and unread
This commit is contained in:
parent
654bb0c8ca
commit
359e761922
3 changed files with 32 additions and 4 deletions
|
@ -74,5 +74,20 @@ namespace BTCPayServer.Controllers
|
|||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> FlipRead(string id)
|
||||
{
|
||||
// TODO: Refactor
|
||||
var claimWithId = User.Claims.SingleOrDefault(a => a.Type == ClaimTypes.NameIdentifier);
|
||||
if (claimWithId == null)
|
||||
return RedirectToAction("Index", "Home");
|
||||
|
||||
var notif = _db.Notifications.SingleOrDefault(a => a.Id == id && a.ApplicationUserId == claimWithId.Value);
|
||||
notif.Seen = !notif.Seen;
|
||||
await _db.SaveChangesAsync();
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace BTCPayServer.Models.NotificationViewModels
|
|||
public DateTimeOffset Created { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string ActionLink { get; set; }
|
||||
public bool Seen { get; set; }
|
||||
}
|
||||
|
||||
public static class NotificationViewModelExt
|
||||
|
@ -36,7 +37,8 @@ namespace BTCPayServer.Models.NotificationViewModels
|
|||
Id = data.Id,
|
||||
Created = data.Created,
|
||||
Body = $"New version {casted.Version} released!",
|
||||
ActionLink = "https://github.com/btcpayserver/btcpayserver/releases/tag/v" + casted.Version
|
||||
ActionLink = "https://github.com/btcpayserver/btcpayserver/releases/tag/v" + casted.Version,
|
||||
Seen = data.Seen
|
||||
};
|
||||
|
||||
return obj;
|
||||
|
|
|
@ -40,9 +40,11 @@
|
|||
<tbody>
|
||||
@foreach (var item in Model.Items)
|
||||
{
|
||||
@* TODO: Click on td to mark notification read through JavaScript magic *@
|
||||
@* TODO: Multiselect akin to Gmail *@
|
||||
<tr>
|
||||
<td>@item.Created.ToBrowserDate()</td>
|
||||
<td>@item.Body</td>
|
||||
<td class="cursor-pointer @(item.Seen ? "": "font-weight-bold")">@item.Created.ToBrowserDate()</td>
|
||||
<td class="cursor-pointer @(item.Seen ? "": "font-weight-bold")">@item.Body</td>
|
||||
<td>
|
||||
@if (!String.IsNullOrEmpty(item.ActionLink))
|
||||
{
|
||||
|
@ -54,7 +56,16 @@
|
|||
}
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Delete" asp-route-id="@item.Id"><span class="fa fa-trash"></span></a>
|
||||
@if (item.Seen)
|
||||
{
|
||||
<a asp-action="FlipRead" asp-route-id="@item.Id"><span class="fa fa-envelope-o" title="Mark Unread"></span></a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a asp-action="FlipRead" asp-route-id="@item.Id"><span class="fa fa-envelope-open-o" title="Mark Read"></span></a>
|
||||
}
|
||||
|
||||
<a asp-action="Delete" asp-route-id="@item.Id"><span class="fa fa-trash-o" title="Delete"></span></a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue