#478 contribs page
This commit is contained in:
parent
b5f060cc7f
commit
d83510fe3e
@ -151,6 +151,7 @@
|
||||
document.getElementById("remove-days-placeholder").remove();
|
||||
$(data).appendTo(divParent);
|
||||
plotChart('grouped-by-date');
|
||||
plotChart('grouped-by-user');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@ -138,16 +138,28 @@ namespace GanjooRazor.Pages
|
||||
|
||||
public async Task<ActionResult> 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<string>(await responseDays.Content.ReadAsStringAsync()));
|
||||
}
|
||||
var days = JArray.Parse(await responseDays.Content.ReadAsStringAsync()).ToObject<List<GroupedByDateViewModel>>();
|
||||
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<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
var result = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GroupedByDateViewModel>>();
|
||||
if (result == null)
|
||||
var users = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GroupedByUserViewModel>>();
|
||||
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(),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,3 +37,37 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@if (Model.Users == null || Model.Users.Length == 0) return;
|
||||
|
||||
<table class="stats" id="grouped-by-user">
|
||||
<thead>
|
||||
<tr class="h">
|
||||
<td class="c1">ردیف</td>
|
||||
<td class="c2">کاربر</td>
|
||||
<td class="c3">تعداد</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (int i = 0; i < Model.Users.Length; i++)
|
||||
{
|
||||
@if (i % 2 == 0)
|
||||
{
|
||||
<tr class="e">
|
||||
<td class="c1">@((i + 1).ToPersianNumbers())</td>
|
||||
<td class="c2"><a href="/hashieha/?userid=@Model.Users[i].UserId">@Model.Users[i].UserName</a></td>
|
||||
<td class="c3">@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.Users[i].Number)</td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<tr>
|
||||
<td class="c1">@((i + 1).ToPersianNumbers())</td>
|
||||
<td class="c2"><a href="/hashieha/?userid=@Model.Users[i].UserId">@Model.Users[i].UserName</a></td>
|
||||
<td class="c3">@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.Users[i].Number)</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@ -6,5 +6,7 @@ namespace GanjooRazor.Pages
|
||||
public class _GroupedByDateViewTablePartialModel : PageModel
|
||||
{
|
||||
public GroupedByDateViewModel[] Days { get; set; }
|
||||
|
||||
public GroupedByUserViewModel[] Users { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user