#392 UI for filtering a user edits

This commit is contained in:
Hamid Reza Mohammadi 2023-07-07 18:28:23 +03:30
parent 985f2f89ad
commit 6120cd883f
3 changed files with 55 additions and 7 deletions

View File

@ -184,7 +184,7 @@ else
پیشنهاد دهنده:
</td>
<td>
<a href="/hashieha/?userid=@Model.Correction.UserId" target="_blank">@Model.Correction.UserNickname</a>
<a href="/user/edits/?allusers=1&userid=@Model.Correction.UserId" target="_blank">@Model.Correction.UserNickname</a>
</td>
</tr>
<tr>

View File

@ -18,11 +18,37 @@ else
if (@Model.CanEdit)
{
<div class="clear-both">
<p>
<a role="button" href="/User/Edits?AllUsers=1" class="pagebutton">ویرایش‌های همه</a>
</p>
</div>
@if (Model.Profile != null)
{
<div id="profile">
<p>
<a href="/hashieha?userId=@Model.Profile.Id">@Model.Profile.NickName</a>
@if (!string.IsNullOrEmpty(Model.Profile.Website))
{
<a href="@Model.Profile.Website">🌐</a>
}
</p>
@if (!string.IsNullOrEmpty(Model.Profile.Bio))
{
@Html.Raw(Model.Profile.Bio)
}
</div>
<hr />
}
else
{
<div class="clear-both">
<p>
<a role="button" href="/User/Edits?AllUsers=1" class="pagebutton">ویرایش‌های همه</a>
</p>
</div>
}
}
@if (Model.Corrections.Count == 0)

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
@ -9,6 +10,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RMuseum.Models.Auth.ViewModel;
using RMuseum.Models.Ganjoor;
using RMuseum.Models.Ganjoor.ViewModels;
using RSecurityBackend.Models.Generic;
@ -38,6 +40,13 @@ namespace GanjooRazor.Areas.User.Pages
/// </summary>
public bool AllUsersEdits { get; set; }
/// <summary>
/// filteredUserId
/// </summary>
public Guid? filteredUserId { get; set; }
public GanjoorUserPublicProfile Profile { get; set; }
/// <summary>
/// Corrections
/// </summary>
@ -80,6 +89,19 @@ namespace GanjooRazor.Areas.User.Pages
{
url = $"{APIRoot.Url}/api/ganjoor/corrections/all?PageNumber={pageNumber}&PageSize=20";
}
filteredUserId = string.IsNullOrEmpty(Request.Query["UserId"]) ? null : Guid.Parse(Request.Query["UserId"]);
if (filteredUserId != null)
{
url += $"&userId={filteredUserId}";
var responseUserProfile = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/user/profile/{filteredUserId}");
if (!responseUserProfile.IsSuccessStatusCode)
{
LastError = JsonConvert.DeserializeObject<string>(await responseUserProfile.Content.ReadAsStringAsync());
return Page();
}
Profile = JsonConvert.DeserializeObject<GanjoorUserPublicProfile>(await responseUserProfile.Content.ReadAsStringAsync());
}
}
var response = await secureClient.GetAsync(url);
if (!response.IsSuccessStatusCode)