#186 display corrections for review
This commit is contained in:
parent
ae92256c4f
commit
a0a2598611
@ -6,4 +6,91 @@
|
||||
ViewData["Title"] = "بازبینی ویرایشها";
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@if (!string.IsNullOrEmpty(Model.FatalError))
|
||||
{
|
||||
<p>@Model.FatalError</p>
|
||||
}
|
||||
else if (@Model.Correction == null)
|
||||
{
|
||||
<p>ویرایشی وجود ندارد.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table>
|
||||
|
||||
|
||||
@if (Model.Correction.Title != null)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
عنوان
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>متن اولیه</td>
|
||||
<td>تغییرات</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style="color:red">@Model.Correction.OriginalTitle</p>
|
||||
</td>
|
||||
<td>
|
||||
<p style="color:green">@Model.Correction.Title</p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Correction.Rhythm != null)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
وزن
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>متن اولیه</td>
|
||||
<td>تغییرات</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style="color:red">@Model.Correction.OriginalRhythm</p>
|
||||
</td>
|
||||
<td>
|
||||
<p style="color:green">@Model.Correction.Rhythm</p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Correction.VerseOrderText != null)
|
||||
@foreach (var verse in Model.Correction.VerseOrderText)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
@verse.VORder
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>متن اولیه</td>
|
||||
<td>تغییرات</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style="color:red">@verse.OriginalText</p>
|
||||
</td>
|
||||
<td>
|
||||
<p style="color:green">@verse.Text</p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(Model.Correction.Note))
|
||||
{
|
||||
<tr>
|
||||
<td>یادداشت:</td>
|
||||
<td>
|
||||
@Model.Correction.Note
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
|
||||
</table>
|
||||
}
|
||||
|
||||
@ -1,16 +1,63 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
public class ReviewEditsModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
/// <summary>
|
||||
/// correction
|
||||
/// </summary>
|
||||
public GanjoorPoemCorrectionViewModel Correction { get; set; }
|
||||
/// <summary>
|
||||
/// fatal error
|
||||
/// </summary>
|
||||
public string FatalError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// skip
|
||||
/// </summary>
|
||||
public int Skip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// total count
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
FatalError = "";
|
||||
TotalCount = 0;
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var nextResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/correction/next?skip={Skip}");
|
||||
nextResponse.EnsureSuccessStatusCode();
|
||||
|
||||
string paginnationMetadata = nextResponse.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
TotalCount = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata).totalCount;
|
||||
}
|
||||
Correction = JsonConvert.DeserializeObject<GanjoorPoemCorrectionViewModel>(await nextResponse.Content.ReadAsStringAsync());
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,6 +871,25 @@ namespace RMuseum.Controllers
|
||||
await _ganjoorService.GetNextUnreviewedCorrection(skip);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
|
||||
var resCount = await _ganjoorService.GetUnreviewedCorrectionCount();
|
||||
if (!string.IsNullOrEmpty(resCount.ExceptionString))
|
||||
return BadRequest(resCount.ExceptionString);
|
||||
|
||||
// Paging Header
|
||||
HttpContext.Response.Headers.Add("paging-headers",
|
||||
JsonConvert.SerializeObject(
|
||||
new PaginationMetadata()
|
||||
{
|
||||
totalCount = resCount.Result,
|
||||
pageSize = -1,
|
||||
currentPage = -1,
|
||||
hasNextPage = false,
|
||||
hasPreviousPage = false,
|
||||
totalPages = -1
|
||||
})
|
||||
);
|
||||
|
||||
return Ok(res.Result);//might be null
|
||||
}
|
||||
|
||||
|
||||
@ -7672,6 +7672,12 @@
|
||||
<param name="skip"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetUnreviewedCorrectionCount">
|
||||
<summary>
|
||||
unreview correction count
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetNextUnreviewedSong(System.Int32,System.Guid)">
|
||||
<summary>
|
||||
next unreviewed track
|
||||
@ -9272,6 +9278,12 @@
|
||||
<param name="skip"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetUnreviewedCorrectionCount">
|
||||
<summary>
|
||||
unreview correction count
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.SuggestSong(System.Guid,RMuseum.Models.Ganjoor.ViewModels.PoemMusicTrackViewModel)">
|
||||
<summary>
|
||||
suggest song
|
||||
|
||||
@ -167,6 +167,12 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemCorrectionViewModel>> GetNextUnreviewedCorrection(int skip);
|
||||
|
||||
/// <summary>
|
||||
/// unreview correction count
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<int>> GetUnreviewedCorrectionCount();
|
||||
|
||||
/// <summary>
|
||||
/// next unreviewed track
|
||||
/// </summary>
|
||||
|
||||
@ -1411,7 +1411,7 @@ namespace RMuseum.Services.Implementation
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoemCorrectionViewModel>> GetNextUnreviewedCorrection(int skip)
|
||||
{
|
||||
var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText)
|
||||
var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.User)
|
||||
.Where(c => c.Result == CorrectionReviewResult.NotReviewed)
|
||||
.OrderBy(c => c.Id)
|
||||
.Skip(skip)
|
||||
@ -1440,6 +1440,17 @@ namespace RMuseum.Services.Implementation
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// unreview correction count
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<int>> GetUnreviewedCorrectionCount()
|
||||
{
|
||||
return new RServiceResult<int>(await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText)
|
||||
.Where(c => c.Result == CorrectionReviewResult.NotReviewed)
|
||||
.CountAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// suggest song
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user