#123 displaying next unsynched image
This commit is contained in:
parent
0dcc3062c9
commit
f649341222
24
GanjooRazor/Areas/User/Pages/FinalizeImages.cshtml
Normal file
24
GanjooRazor/Areas/User/Pages/FinalizeImages.cshtml
Normal file
@ -0,0 +1,24 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.User.Pages.FinalizeImagesModel
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
ViewData["Title"] = "نهاییسازی تصاویر پیشنهادی";
|
||||
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
@if (Model.LastError != "")
|
||||
{
|
||||
<h2>@Model.LastError</h2>
|
||||
}
|
||||
|
||||
@if (Model.MainImage != null)
|
||||
{
|
||||
<img src="https://ganjgah.ir/api/images/thumb/@(Model.MainImage.EntityImageId).jpg" />
|
||||
}
|
||||
|
||||
@if (Model.PreviouslyLinkedImage != null)
|
||||
{
|
||||
<img src="https://ganjgah.ir/api/images/thumb/@(Model.PreviouslyLinkedImage.EntityImageId).jpg" />
|
||||
}
|
||||
83
GanjooRazor/Areas/User/Pages/FinalizeImages.cshtml.cs
Normal file
83
GanjooRazor/Areas/User/Pages/FinalizeImages.cshtml.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.GanjoorIntegration.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class FinalizeImagesModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// skip
|
||||
/// </summary>
|
||||
public int Skip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// total count
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public GanjoorLinkViewModel MainImage { get; set; }
|
||||
|
||||
public GanjoorLinkViewModel PreviouslyLinkedImage { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
MainImage = null;
|
||||
PreviouslyLinkedImage = null;
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var imageResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/artifacts/ganjoor/nextunsychedimage?skip={Skip}");
|
||||
if (!imageResponse.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = await imageResponse.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
string paginnationMetadata = imageResponse.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
TotalCount = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata).totalCount;
|
||||
}
|
||||
|
||||
var images = JsonConvert.DeserializeObject<GanjoorLinkViewModel[]>(await imageResponse.Content.ReadAsStringAsync());
|
||||
|
||||
if(images != null)
|
||||
{
|
||||
if(images.Length >= 1)
|
||||
{
|
||||
MainImage = images[0];
|
||||
}
|
||||
|
||||
if (images.Length >= 2)
|
||||
{
|
||||
PreviouslyLinkedImage = images[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,9 +84,6 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
if (poemResponse.IsSuccessStatusCode)
|
||||
{
|
||||
Poem = JsonConvert.DeserializeObject<GanjoorPoemCompleteViewModel>(await poemResponse.Content.ReadAsStringAsync());
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -169,6 +169,13 @@
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/ReportedComments">حاشیههای گزارش شده</a>
|
||||
</li>
|
||||
}
|
||||
|
||||
@if (ViewData.ContainsKey($"{RMuseum.Models.Auth.Memory.RMuseumSecurableItem.ArtifactEntityShortName}-{RMuseum.Models.Auth.Memory.RMuseumSecurableItem.ReviewGanjoorLinksOperationShortName}"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/FinalizeImages">نهاییسازی تصاویر</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -8,6 +8,6 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"GoogleAnalyticsCode": "",
|
||||
"APIRoot": "http://localhost:3439",
|
||||
"GlobalAPIRoot": "http://localhost:3439"
|
||||
"APIRoot": "https://ganjgah.ir",
|
||||
"GlobalAPIRoot": "https://ganjgah.ir"
|
||||
}
|
||||
|
||||
@ -1667,7 +1667,25 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// finds next unsynchronized suggested link with an aleady synched one from the artificat if exists,
|
||||
/// return value might be null or an array with length 1 or 2
|
||||
/// </summary>
|
||||
/// <param name="skip"></param>
|
||||
/// <returns> return value might be null or an array with length 1 or 2</returns>
|
||||
[HttpGet]
|
||||
[Route("ganjoor/nextunsychedimage")]
|
||||
[Authorize]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorLinkViewModel[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetNextUnsynchronizedSuggestedLinkWithAlreadySynchedOneForPoem(int skip)
|
||||
{
|
||||
RServiceResult<GanjoorLinkViewModel[]> res = await _artifactService.GetNextUnsynchronizedSuggestedLinkWithAlreadySynchedOneForPoem(skip);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// review suggested ganjoor link
|
||||
/// </summary>
|
||||
@ -1692,15 +1710,16 @@ namespace RMuseum.Controllers
|
||||
/// mark suggested ganjoor link as synchronized
|
||||
/// </summary>
|
||||
/// <param name="linkId"></param>
|
||||
/// <param name="displayOnPage">display ogn page</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("ganjoor/sync/{linkId}")]
|
||||
[Route("ganjoor/sync/{linkId}/{displayOnPage}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + RMuseumSecurableItem.ReviewGanjoorLinksOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> SynchronizeGanjoorLink(Guid linkId)
|
||||
public async Task<IActionResult> SynchronizeGanjoorLink(Guid linkId, bool displayOnPage)
|
||||
{
|
||||
RServiceResult<bool> suggestion = await _artifactService.SynchronizeSuggestedLink(linkId);
|
||||
RServiceResult<bool> suggestion = await _artifactService.SynchronizeSuggestedLink(linkId, displayOnPage);
|
||||
if (!string.IsNullOrEmpty(suggestion.ExceptionString))
|
||||
return BadRequest(suggestion.ExceptionString);
|
||||
return Ok();
|
||||
|
||||
@ -478,6 +478,14 @@
|
||||
<param name="notSynced"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.GetNextUnsynchronizedSuggestedLinkWithAlreadySynchedOneForPoem(System.Int32)">
|
||||
<summary>
|
||||
finds next unsynchronized suggested link with an aleady synched one from the artificat if exists,
|
||||
return value might be null or an array with length 1 or 2
|
||||
</summary>
|
||||
<param name="skip"></param>
|
||||
<returns> return value might be null or an array with length 1 or 2</returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.ReviewGanjoorLink(System.Guid,RMuseum.Models.GanjoorIntegration.ReviewResult)">
|
||||
<summary>
|
||||
review suggested ganjoor link
|
||||
@ -486,11 +494,12 @@
|
||||
<param name="result"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.SynchronizeGanjoorLink(System.Guid)">
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.SynchronizeGanjoorLink(System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
mark suggested ganjoor link as synchronized
|
||||
</summary>
|
||||
<param name="linkId"></param>
|
||||
<param name="displayOnPage">display ogn page</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.AddTOCForSuggestedLinks">
|
||||
@ -6485,11 +6494,12 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IArtifactService.SynchronizeSuggestedLink(System.Guid)">
|
||||
<member name="M:RMuseum.Services.IArtifactService.SynchronizeSuggestedLink(System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
Synchronize suggested link
|
||||
</summary>
|
||||
<param name="linkId"></param>
|
||||
<param name="displayOnPage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IArtifactService.GetSuggestedPinterestLinks(RMuseum.Models.GanjoorIntegration.ReviewResult,System.Boolean)">
|
||||
@ -7449,11 +7459,12 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.SynchronizeSuggestedLink(System.Guid)">
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.SynchronizeSuggestedLink(System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
Synchronize suggested link
|
||||
</summary>
|
||||
<param name="linkId"></param>
|
||||
<param name="displayOnPage"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.GetSuggestedPinterestLinks(RMuseum.Models.GanjoorIntegration.ReviewResult,System.Boolean)">
|
||||
|
||||
@ -467,8 +467,9 @@ namespace RMuseum.Services
|
||||
/// Synchronize suggested link
|
||||
/// </summary>
|
||||
/// <param name="linkId"></param>
|
||||
/// <param name="displayOnPage"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> SynchronizeSuggestedLink(Guid linkId);
|
||||
Task<RServiceResult<bool>> SynchronizeSuggestedLink(Guid linkId, bool displayOnPage);
|
||||
|
||||
/// <summary>
|
||||
/// get suggested pinterest links
|
||||
|
||||
@ -3007,8 +3007,9 @@ namespace RMuseum.Services.Implementation
|
||||
/// Synchronize suggested link
|
||||
/// </summary>
|
||||
/// <param name="linkId"></param>
|
||||
/// <param name="displayOnPage"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> SynchronizeSuggestedLink(Guid linkId)
|
||||
public async Task<RServiceResult<bool>> SynchronizeSuggestedLink(Guid linkId, bool displayOnPage)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -3018,6 +3019,7 @@ namespace RMuseum.Services.Implementation
|
||||
.SingleOrDefaultAsync();
|
||||
|
||||
link.Synchronized = true;
|
||||
link.DisplayOnPage = displayOnPage;
|
||||
|
||||
_context.GanjoorLinks.Update(link);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user