#208 bookmark list UI
This commit is contained in:
parent
a95b2ff7d3
commit
4e9e80db8b
80
GanjooRazor/Areas/User/Pages/MyBookmarks.cshtml
Normal file
80
GanjooRazor/Areas/User/Pages/MyBookmarks.cshtml
Normal file
@ -0,0 +1,80 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.User.Pages.MyBookmarksModel
|
||||
@using DNTPersianUtils.Core
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
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
|
||||
{
|
||||
<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>
|
||||
|
||||
@foreach (var bookmark in Model.Bookmarks)
|
||||
{
|
||||
if (color == "gray")
|
||||
color = "white";
|
||||
else
|
||||
color = "gray";
|
||||
|
||||
<div style="background-color:@color" id="bookmark-@bookmark.Id">
|
||||
<blockquote>
|
||||
<p>
|
||||
<small>در @bookmark.DateTime.ToFriendlyPersianDateTextify()</small>
|
||||
</p>
|
||||
<div id="bookmark-text-@bookmark.Id">
|
||||
<p>
|
||||
@bookmark.VerseText
|
||||
</p>
|
||||
|
||||
@if(!string.IsNullOrEmpty(bookmark.Verse2Text))
|
||||
{
|
||||
<p>
|
||||
@bookmark.Verse2Text
|
||||
</p>
|
||||
}
|
||||
|
||||
</div>
|
||||
</blockquote>
|
||||
|
||||
</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>
|
||||
|
||||
|
||||
}
|
||||
|
||||
133
GanjooRazor/Areas/User/Pages/MyBookmarks.cshtml.cs
Normal file
133
GanjooRazor/Areas/User/Pages/MyBookmarks.cshtml.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using DNTPersianUtils.Core;
|
||||
using GanjooRazor.Utils;
|
||||
using GSpotifyProxy.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class MyBookmarksModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// pagination links
|
||||
/// </summary>
|
||||
public List<NameIdUrlImage> PaginationLinks { get; set; }
|
||||
|
||||
public List<GanjoorUserBookmarkViewModel> Bookmarks { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
{
|
||||
int pageNumber = 1;
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
pageNumber = int.Parse(Request.Query["page"]);
|
||||
}
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/bookmark/?PageNumber={pageNumber}&PageSize=20");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
Bookmarks = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorUserBookmarkViewModel>>();
|
||||
|
||||
string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata);
|
||||
PaginationLinks = new List<NameIdUrlImage>();
|
||||
if (paginationMetadata.totalPages > 1)
|
||||
{
|
||||
if (paginationMetadata.currentPage > 3)
|
||||
{
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ اول",
|
||||
Url = "/User/MyBookmarks/?page=1"
|
||||
}
|
||||
);
|
||||
}
|
||||
for (int i = (paginationMetadata.currentPage - 2); i <= (paginationMetadata.currentPage + 2); i++)
|
||||
{
|
||||
if (i >= 1 && i <= paginationMetadata.totalPages)
|
||||
{
|
||||
if (i == paginationMetadata.currentPage)
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
Url = $"/User/MyBookmarks/?page={i}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "... ",
|
||||
}
|
||||
);
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ آخر",
|
||||
Url = $"/User/MyBookmarks/?page={paginationMetadata.totalPages}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class NotificationsModel : PageModel
|
||||
{
|
||||
// <summary>
|
||||
/// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
@ -332,6 +332,11 @@
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/MyComments">حاشیههای من</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/MyBookmarks">نشانههای من</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/Notifications">اعلانهای من</a>
|
||||
</li>
|
||||
|
||||
@ -1897,6 +1897,8 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> SwitchCoupletBookmark(int poemId, int coupletIndex)
|
||||
{
|
||||
if (ReadOnlyMode)
|
||||
return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید.");
|
||||
Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
RServiceResult<GanjoorUserBookmark> res = await _ganjoorService.SwitchCoupletBookmark(loggedOnUserId, poemId, coupletIndex);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
|
||||
@ -1733,16 +1733,27 @@
|
||||
<param name="translation"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Controllers.TranslationController.ReadOnlyMode">
|
||||
<summary>
|
||||
readonly mode
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Controllers.TranslationController._translationService">
|
||||
<summary>
|
||||
translation service
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.TranslationController.#ctor(RMuseum.Services.IGanjoorTranslationService)">
|
||||
<member name="P:RMuseum.Controllers.TranslationController.Configuration">
|
||||
<summary>
|
||||
Configuration
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.TranslationController.#ctor(RMuseum.Services.IGanjoorTranslationService,Microsoft.Extensions.Configuration.IConfiguration)">
|
||||
<summary>
|
||||
constructor
|
||||
</summary>
|
||||
<param name="translationService"></param>
|
||||
<param name="configuration"></param>
|
||||
</member>
|
||||
<member name="T:RMuseum.DbContext.RMuseumDbContext">
|
||||
<summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user