From d83510fe3e0fd61eee7cc4f1d64065faa8253e19 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sat, 29 Mar 2025 15:49:25 +0330 Subject: [PATCH] #478 contribs page --- GanjooRazor/Pages/Contribs.cshtml | 1 + GanjooRazor/Pages/Contribs.cshtml.cs | 23 ++++++++++--- .../Pages/_GroupedByDateViewPartial.cshtml.cs | 5 ++- .../_GroupedByDateViewTablePartial.cshtml | 34 +++++++++++++++++++ .../_GroupedByDateViewTablePartial.cshtml.cs | 2 ++ 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/GanjooRazor/Pages/Contribs.cshtml b/GanjooRazor/Pages/Contribs.cshtml index f14b127b..c04bacaf 100644 --- a/GanjooRazor/Pages/Contribs.cshtml +++ b/GanjooRazor/Pages/Contribs.cshtml @@ -151,6 +151,7 @@ document.getElementById("remove-days-placeholder").remove(); $(data).appendTo(divParent); plotChart('grouped-by-date'); + plotChart('grouped-by-user'); } }, }); diff --git a/GanjooRazor/Pages/Contribs.cshtml.cs b/GanjooRazor/Pages/Contribs.cshtml.cs index 85666f47..7a1e9097 100644 --- a/GanjooRazor/Pages/Contribs.cshtml.cs +++ b/GanjooRazor/Pages/Contribs.cshtml.cs @@ -138,16 +138,28 @@ namespace GanjooRazor.Pages public async Task OnGetGroupedByDateAsync(string dataType) { - var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/contributions/{dataType}/daily?PageNumber=1&PageSize=30"); + var responseDays = await _httpClient.GetAsync($"{APIRoot.Url}/api/contributions/{dataType}/daily?PageNumber=1&PageSize=30"); + + if (!responseDays.IsSuccessStatusCode) + { + return new BadRequestObjectResult(JsonConvert.DeserializeObject(await responseDays.Content.ReadAsStringAsync())); + } + var days = JArray.Parse(await responseDays.Content.ReadAsStringAsync()).ToObject>(); + if (days == null) + { + return new BadRequestObjectResult("خطا در دسترسی به آمار روزانه"); + } + + var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/contributions/{dataType}/by/user?PageNumber=1&PageSize=30"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync())); } - var result = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); - if (result == null) + var users = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); + if (users == null) { - return new BadRequestObjectResult("خطا در دسترسی به آمار ویرایش‌ها"); + return new BadRequestObjectResult("خطا در دسترسی به آمار کاربران"); } return new PartialViewResult() @@ -157,7 +169,8 @@ namespace GanjooRazor.Pages { Model = new _GroupedByDateViewPartialModel() { - Days = result.ToArray() + Days = days.ToArray(), + Users = users.ToArray(), } } }; diff --git a/GanjooRazor/Pages/_GroupedByDateViewPartial.cshtml.cs b/GanjooRazor/Pages/_GroupedByDateViewPartial.cshtml.cs index 7b7bf7c0..ca6ef3fc 100644 --- a/GanjooRazor/Pages/_GroupedByDateViewPartial.cshtml.cs +++ b/GanjooRazor/Pages/_GroupedByDateViewPartial.cshtml.cs @@ -7,13 +7,16 @@ namespace GanjooRazor.Pages { public GroupedByDateViewModel[] Days { get; set; } + public GroupedByUserViewModel[] Users { get; set; } + public _GroupedByDateViewTablePartialModel TableModel { get { return new _GroupedByDateViewTablePartialModel() { - Days = Days + Days = Days, + Users = Users, }; } } diff --git a/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml b/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml index 1db68935..4dfa1046 100644 --- a/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml +++ b/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml @@ -37,3 +37,37 @@ +@if (Model.Users == null || Model.Users.Length == 0) return; + + + + + + + + + + + @for (int i = 0; i < Model.Users.Length; i++) + { + @if (i % 2 == 0) + { + + + + + + + } + else + { + + + + + + } + } + +
ردیفکاربرتعداد
@((i + 1).ToPersianNumbers())@Model.Users[i].UserName@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.Users[i].Number)
@((i + 1).ToPersianNumbers())@Model.Users[i].UserName@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.Users[i].Number)
+ diff --git a/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml.cs b/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml.cs index d5927594..76343e5b 100644 --- a/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml.cs +++ b/GanjooRazor/Pages/_GroupedByDateViewTablePartial.cshtml.cs @@ -6,5 +6,7 @@ namespace GanjooRazor.Pages public class _GroupedByDateViewTablePartialModel : PageModel { public GroupedByDateViewModel[] Days { get; set; } + + public GroupedByUserViewModel[] Users { get; set; } } }