#444 word summaries in UI
This commit is contained in:
parent
cfac26c22d
commit
2f0774fb84
@ -1285,6 +1285,17 @@ namespace GanjooRazor.Pages
|
||||
|
||||
public async Task<ActionResult> OnGetCategoryWordCountsAsync(int catId, int poetId)
|
||||
{
|
||||
var wordSumsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/audio/wordsums/{catId}");
|
||||
|
||||
if (!wordSumsResponse.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await wordSumsResponse.Content.ReadAsStringAsync()));
|
||||
}
|
||||
var wordSums = JsonConvert.DeserializeObject<CategoryWordCountSummary>(await wordSumsResponse.Content.ReadAsStringAsync());
|
||||
if(wordSums.TotalWordCount == 0)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>("شمارش واژگان انجام نشده."));
|
||||
}
|
||||
var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/{catId}?PageNumber=1&PageSize=100");
|
||||
|
||||
if (!wordCountsResponse.IsSuccessStatusCode)
|
||||
@ -1302,13 +1313,15 @@ namespace GanjooRazor.Pages
|
||||
{
|
||||
CatId = catId,
|
||||
PoetId = poetId,
|
||||
WordCounts = wordCounts
|
||||
WordCounts = wordCounts,
|
||||
UniqueWordCount = wordSums.UniqueWordCount,
|
||||
TotalWordCount = wordSums.TotalWordCount,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ActionResult> OnGetSearchCategoryWordCountsAsync(int catId, int poetId, string term)
|
||||
public async Task<ActionResult> OnGetSearchCategoryWordCountsAsync(int catId, int poetId, string term, int totalWordCount)
|
||||
{
|
||||
var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/{catId}?PageNumber=1&PageSize=100&term={term}");
|
||||
|
||||
@ -1327,7 +1340,8 @@ namespace GanjooRazor.Pages
|
||||
{
|
||||
CatId = catId,
|
||||
PoetId = poetId,
|
||||
WordCounts = wordCounts
|
||||
WordCounts = wordCounts,
|
||||
TotalWordCount = totalWordCount,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -9,8 +9,11 @@
|
||||
<div class="century" id="wordcounts-section-controller">
|
||||
بسامد واژگان <a role="button" class="w3tooltip cursor-pointer" onclick="switch_section('wordcounts-section', 'wordcounts-section-collapse-button')"><i class="info-buttons expand_circle_down" id="wordcounts-section-collapse-button"></i><span class="w3tooltiptext">جمع شود / باز شود</span></a>
|
||||
</div>
|
||||
<p>
|
||||
@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.TotalWordCount) واژهٔ این بخش از @RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.UniqueWordCount) تشکیل شده است.
|
||||
</p>
|
||||
<div class="clear-both">
|
||||
<input type="text" id="wordcountterm" placeholder="جستجوی واژه" value="" onkeyup="onSearchWordCounts(@Model.CatId, @Model.PoetId)">
|
||||
<input type="text" id="wordcountterm" placeholder="جستجوی واژه" value="" onkeyup="onSearchWordCounts(@Model.CatId, @Model.PoetId, @Model.TotalWordCount)">
|
||||
</div>
|
||||
<div id="wordcounts-section">
|
||||
<partial name="_CategoryWordsCountTablePartial" model="Model.TableModel">
|
||||
|
||||
@ -15,6 +15,16 @@ namespace GanjooRazor.Pages
|
||||
/// </summary>
|
||||
public int PoetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// unique word count
|
||||
/// </summary>
|
||||
public int UniqueWordCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// total word count
|
||||
/// </summary>
|
||||
public int TotalWordCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// words counts
|
||||
/// </summary>
|
||||
|
||||
@ -3,11 +3,14 @@
|
||||
@{
|
||||
}
|
||||
|
||||
@if (Model.TotalWordCount == 0) return;
|
||||
|
||||
<table>
|
||||
<tr class="h">
|
||||
<td class="c1">ردیف</td>
|
||||
<td class="c2">واژه</td>
|
||||
<td class="c3">شمار</td>
|
||||
<td class="c4">درصد از کل</td>
|
||||
</tr>
|
||||
@for (int i = 0; i < Model.WordCounts.Length; i++)
|
||||
{
|
||||
@ -17,6 +20,7 @@
|
||||
<td class="c1">@Model.WordCounts[i].RowNmbrInCat.ToPersianNumbers()</td>
|
||||
<td class="c2"><a href="/search?s=@Model.WordCounts[i].Word&author=@Model.PoetId&cat=@Model.CatId">@Model.WordCounts[i].Word</a></td>
|
||||
<td class="c3">@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordCounts[i].Count)</td>
|
||||
<td class="c4">@(Model.WordCounts[i].Count * 100.0 / Model.TotalWordCount).ToString("N4", new CultureInfo("fa-IR")).ToPersianNumbers())</td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
@ -26,6 +30,7 @@
|
||||
<td class="c1">@Model.WordCounts[i].RowNmbrInCat.ToPersianNumbers()</td>
|
||||
<td class="c2"><a href="/search?s=@Model.WordCounts[i].Word&author=@Model.PoetId&cat=@Model.CatId">@Model.WordCounts[i].Word</a></td>
|
||||
<td class="c3">@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordCounts[i].Count)</td>
|
||||
<td class="c4">@(Model.WordCounts[i].Count * 100.0 / Model.TotalWordCount).ToString("N4", new CultureInfo("fa-IR")).ToPersianNumbers())</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
|
||||
@ -16,6 +15,11 @@ namespace GanjooRazor.Pages
|
||||
/// </summary>
|
||||
public int PoetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// total word count
|
||||
/// </summary>
|
||||
public int TotalWordCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// words counts
|
||||
/// </summary>
|
||||
|
||||
@ -1534,7 +1534,7 @@ function loadWordCounts(catId, poetId) {
|
||||
});
|
||||
}
|
||||
|
||||
function onSearchWordCounts(catId, poetId) {
|
||||
function onSearchWordCounts(catId, poetId, totalWordCount) {
|
||||
setTimeout(function () {
|
||||
var value = document.getElementById('wordcountterm').value;
|
||||
var divParent = document.getElementById('wordcounts-section');
|
||||
@ -1542,7 +1542,7 @@ function onSearchWordCounts(catId, poetId) {
|
||||
divParent.innerHTML = '<div class="bnumdiv" id="remove-this-wordcounts"><img id="' + imgElementId + '" src="/image/loading.gif" alt="بارگذاری"/></div>';
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '?Handler=SearchCategoryWordCounts&catId=' + String(catId) + '&poetId=' + String(poetId) + '&term=' + value,
|
||||
url: '?Handler=SearchCategoryWordCounts&catId=' + String(catId) + '&poetId=' + String(poetId) + '&totalWordCount' + String(totalWordCount) + '&term=' + value,
|
||||
error: function () {
|
||||
document.getElementById("remove-this-wordcounts").remove();
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user