diff --git a/GanjooRazor/Areas/User/Pages/Edits.cshtml.cs b/GanjooRazor/Areas/User/Pages/Edits.cshtml.cs index a9339eb1..eb1c1465 100644 --- a/GanjooRazor/Areas/User/Pages/Edits.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/Edits.cshtml.cs @@ -53,11 +53,11 @@ namespace GanjooRazor.Areas.User.Pages { { int pageNumber = 1; - string url = $"{APIRoot.Url}/api/ganjoor/corrections/mine?PageNumber={pageNumber}&PageSize=20"; if (!string.IsNullOrEmpty(Request.Query["page"])) { pageNumber = int.Parse(Request.Query["page"]); } + string url = $"{APIRoot.Url}/api/ganjoor/corrections/mine?PageNumber={pageNumber}&PageSize=20"; if (CanEdit) { AllUsersEdits = Request.Query["AllUsers"] == "1"; diff --git a/GanjooRazor/Areas/User/Pages/SectionEdits.cshtml b/GanjooRazor/Areas/User/Pages/SectionEdits.cshtml new file mode 100644 index 00000000..be269830 --- /dev/null +++ b/GanjooRazor/Areas/User/Pages/SectionEdits.cshtml @@ -0,0 +1,189 @@ +@page +@model GanjooRazor.Areas.User.Pages.SectionEditsModel +@using RMuseum.Models.Ganjoor +@using RMuseum.Services.Implementation +@{ + Layout = "_UserPanelLayout"; + ViewData["Title"] = "ویرایش‌های قطعات من"; + await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData); + string color = "gray"; +} +

@ViewData["Title"]

+@if (Model.LastError != "") +{ +

@Model.LastError

+} +else +{ + + if (@Model.CanEdit) + { +
+

+ ویرایش‌های قطعات همه +

+
+ } + + @if (Model.Corrections.Count == 0) + { +

+ شما هنوز هیچ ویرایشی در گنجور انجام نداده‌اید. برای آشنایی با نحوهٔ ویرایش اشعار اینجا را ببینید. +

+ } + + +

+ @foreach (var paginationLink in Model.PaginationLinks) + { + if (!string.IsNullOrEmpty(paginationLink.Url)) + { + @paginationLink.Name + } + else + { + @paginationLink.Name + } + } +

+ + @foreach (var correction in Model.Corrections) + { + if (color == "gray") + color = "white"; + else + color = "gray"; + +
+ + + + + + @if (Model.AllUsersEdits) + { + + + + } + + + + + + + + @if (correction.Rhythm != null) + { + + + + + + @if (!string.IsNullOrEmpty(correction.ReviewNote)) + { + + + + } + } + + @if ( + correction.BreakFromVerse1VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse2VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse3VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse4VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse5VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse6VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse7VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse8VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse9VOrderResult == CorrectionReviewResult.Approved + || + correction.BreakFromVerse10VOrderResult == CorrectionReviewResult.Approved + ) + { + + + + } + + @if (!string.IsNullOrEmpty(correction.Note)) + { + + + + + } + + + + + +
مشاهدهٔ متن شعر یا بخش
@correction.UserNickname
متن اولیهتغییرات مننتیجهٔ بررسی
+

@correction.OriginalRhythm

+
+

@correction.Rhythm

+
+ @if (correction.RhythmResult == CorrectionReviewResult.Approved) + { +

@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)

+ } + else + @if (correction.RhythmResult == CorrectionReviewResult.Approved) + { +

@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)

+ } + else + { +

@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)

+ } +
+

@correction.ReviewNote

+
+

پیشنهاد شما برای شکستن قطعه تأیید شده است.

+
یادداشت: + @correction.Note +
+ @if (correction.Reviewed) + { + ویرایش مجدد + } + else + { + مشاهده + } +
+ +
+ + +
+ } + +

+ @foreach (var paginationLink in Model.PaginationLinks) + { + if (!string.IsNullOrEmpty(paginationLink.Url)) + { + @paginationLink.Name + } + else + { + @paginationLink.Name + } + } +

+ + + + + +} \ No newline at end of file diff --git a/GanjooRazor/Areas/User/Pages/SectionEdits.cshtml.cs b/GanjooRazor/Areas/User/Pages/SectionEdits.cshtml.cs new file mode 100644 index 00000000..ddae66e4 --- /dev/null +++ b/GanjooRazor/Areas/User/Pages/SectionEdits.cshtml.cs @@ -0,0 +1,158 @@ +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 SectionEditsModel : PageModel + { /// + /// Last Error + /// + public string LastError { get; set; } + + /// + /// pagination links + /// + public List PaginationLinks { get; set; } + + /// + /// can edit + /// + public bool CanEdit { get; set; } + + /// + /// all users edits + /// + public bool AllUsersEdits { get; set; } + + /// + /// Corrections + /// + public List Corrections { get; set; } + public async Task OnGetAsync() + { + if (string.IsNullOrEmpty(Request.Cookies["Token"])) + return Redirect("/"); + CanEdit = Request.Cookies["CanEdit"] == "True"; + AllUsersEdits = false; + 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"]); + } + string url = $"{APIRoot.Url}/api/ganjoor/section/corrections/mine?PageNumber={pageNumber}&PageSize=20"; + + if (CanEdit) + { + AllUsersEdits = Request.Query["AllUsers"] == "1"; + if (AllUsersEdits) + { + url = $"{APIRoot.Url}/api/ganjoor/section/corrections/all?PageNumber={pageNumber}&PageSize=20"; + } + } + var response = await secureClient.GetAsync(url); + if (!response.IsSuccessStatusCode) + { + LastError = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return Page(); + } + + Corrections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); + + string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault(); + if (!string.IsNullOrEmpty(paginnationMetadata)) + { + PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject(paginnationMetadata); + PaginationLinks = new List(); + if (paginationMetadata.totalPages > 1) + { + if (paginationMetadata.currentPage > 3) + { + PaginationLinks.Add + ( + new NameIdUrlImage() + { + Name = "صفحهٔ اول", + Url = AllUsersEdits ? "/User/SectionEdits/?page=1&AllUsers=1" : "/User/SectionEdits/?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 = AllUsersEdits ? $"/User/SectionEdits/?page={i}&AllUsers=1" : $"/User/SectionEdits/?page={i}" + } + ); + } + } + } + if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2)) + { + + PaginationLinks.Add + ( + new NameIdUrlImage() + { + Name = "... ", + } + ); + + PaginationLinks.Add + ( + new NameIdUrlImage() + { + Name = "صفحهٔ آخر", + Url = AllUsersEdits ? $"/User/SectionEdits/?page={paginationMetadata.totalPages}&AllUsers=1" : $"/User/SectionEdits/?page={paginationMetadata.totalPages}" + } + ); + } + } + } + + } + } + else + { + LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید."; + } + return Page(); + } + } +} diff --git a/GanjooRazor/GanjooRazor.csproj b/GanjooRazor/GanjooRazor.csproj index 5e689cfb..2179e6bb 100644 --- a/GanjooRazor/GanjooRazor.csproj +++ b/GanjooRazor/GanjooRazor.csproj @@ -22,4 +22,16 @@ + + + + + + <_ContentIncludedByDefault Remove="Areas\User\Pages\SectionEdits.cshtml" /> + + + + + + diff --git a/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml b/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml index 43b00db3..a3cdb0eb 100644 --- a/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml +++ b/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml @@ -17,17 +17,17 @@ @@ -60,10 +60,6 @@ اعلان‌‌های من - - @@ -76,6 +72,14 @@ آهنگ‌های پیشنهادی من + + + + @if (ViewData.ContainsKey("ganjoor-songrevu")) {