#444 UI
This commit is contained in:
parent
d30cf39478
commit
84f2d07b88
@ -1308,5 +1308,31 @@ namespace GanjooRazor.Pages
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ActionResult> OnGetSearchCategoryWordCountsAsync(int catId, int poetId, string term)
|
||||
{
|
||||
var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/{catId}?PageNumber=1&PageSize=100&term={term}");
|
||||
|
||||
if (!wordCountsResponse.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await wordCountsResponse.Content.ReadAsStringAsync()));
|
||||
}
|
||||
var wordCounts = JsonConvert.DeserializeObject<CategoryWordCount[]>(await wordCountsResponse.Content.ReadAsStringAsync());
|
||||
|
||||
return new PartialViewResult()
|
||||
{
|
||||
ViewName = "_CategoryWordsCountTablePartial",
|
||||
ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary())
|
||||
{
|
||||
Model = new _CategoryWordsCountTablePartialModel()
|
||||
{
|
||||
CatId = catId,
|
||||
PoetId = poetId,
|
||||
WordCounts = wordCounts
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -9,34 +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>
|
||||
<div class="clear-both">
|
||||
<input type="text" id="wordcountterm" placeholder="جستجوی واژه" value="" onkeyup="onSearchWordCounts(@Model.CatId, @Model.PoetId)">
|
||||
</div>
|
||||
<div id="wordcounts-section">
|
||||
<table>
|
||||
<tr class="h">
|
||||
<td class="c1">ردیف</td>
|
||||
<td class="c2">واژه</td>
|
||||
<td class="c3">شمار</td>
|
||||
</tr>
|
||||
@for (int i = 0; i < Model.WordCounts.Length; i++)
|
||||
{
|
||||
@if (i % 2 == 0)
|
||||
{
|
||||
<tr class="e">
|
||||
<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>
|
||||
</tr>
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
<partial name="_CategoryWordsCountTablePartial" model="Model.TableModel">
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@ -19,5 +19,18 @@ namespace GanjooRazor.Pages
|
||||
/// words counts
|
||||
/// </summary>
|
||||
public CategoryWordCount[] WordCounts { get; set; }
|
||||
|
||||
public _CategoryWordsCountTablePartialModel TableModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return new _CategoryWordsCountTablePartialModel()
|
||||
{
|
||||
CatId = CatId,
|
||||
PoetId = PoetId,
|
||||
WordCounts = WordCounts
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml
Normal file
32
GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@model GanjooRazor.Pages._CategoryWordsCountTablePartialModel
|
||||
@using DNTPersianUtils.Core
|
||||
@{
|
||||
}
|
||||
|
||||
<table>
|
||||
<tr class="h">
|
||||
<td class="c1">ردیف</td>
|
||||
<td class="c2">واژه</td>
|
||||
<td class="c3">شمار</td>
|
||||
</tr>
|
||||
@for (int i = 0; i < Model.WordCounts.Length; i++)
|
||||
{
|
||||
@if (i % 2 == 0)
|
||||
{
|
||||
<tr class="e">
|
||||
<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>
|
||||
</tr>
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
</table>
|
||||
24
GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml.cs
Normal file
24
GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
|
||||
namespace GanjooRazor.Pages
|
||||
{
|
||||
public class _CategoryWordsCountTablePartialModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Cat Id
|
||||
/// </summary>
|
||||
public int CatId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PoetId
|
||||
/// </summary>
|
||||
public int PoetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// words counts
|
||||
/// </summary>
|
||||
public CategoryWordCount[] WordCounts { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1534,3 +1534,25 @@ function loadWordCounts(catId, poetId) {
|
||||
});
|
||||
}
|
||||
|
||||
function onSearchWordCounts(catId, poetId) {
|
||||
setTimeout(function () {
|
||||
var value = document.getElementById('wordcountterm').value;
|
||||
var divParent = document.getElementById('wordcounts-section');
|
||||
var imgElementId = 'loadingwordcountsimg';
|
||||
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,
|
||||
error: function () {
|
||||
document.getElementById("remove-this-wordcounts").remove();
|
||||
},
|
||||
success: function (data) {
|
||||
document.getElementById("remove-this-wordcounts").remove();
|
||||
$(data).appendTo(divParent);
|
||||
},
|
||||
});
|
||||
|
||||
}, 500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user