From 84f2d07b883e9bad320495612a1fbfd3f26f8fdc Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Wed, 26 Jun 2024 11:50:05 +0330 Subject: [PATCH] #444 UI --- GanjooRazor/Pages/Index.cshtml.cs | 26 +++++++++++++++ .../Pages/_CategoryWordsCountPartial.cshtml | 31 +++--------------- .../_CategoryWordsCountPartial.cshtml.cs | 13 ++++++++ .../_CategoryWordsCountTablePartial.cshtml | 32 +++++++++++++++++++ .../_CategoryWordsCountTablePartial.cshtml.cs | 24 ++++++++++++++ GanjooRazor/wwwroot/js/bk.js | 22 +++++++++++++ 6 files changed, 121 insertions(+), 27 deletions(-) create mode 100644 GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml create mode 100644 GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml.cs diff --git a/GanjooRazor/Pages/Index.cshtml.cs b/GanjooRazor/Pages/Index.cshtml.cs index 9bca118f..b823bd86 100644 --- a/GanjooRazor/Pages/Index.cshtml.cs +++ b/GanjooRazor/Pages/Index.cshtml.cs @@ -1308,5 +1308,31 @@ namespace GanjooRazor.Pages }; } + public async Task 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(await wordCountsResponse.Content.ReadAsStringAsync())); + } + var wordCounts = JsonConvert.DeserializeObject(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 + } + } + }; + } + + } } \ No newline at end of file diff --git a/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml b/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml index 6e095797..61d17000 100644 --- a/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml +++ b/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml @@ -9,34 +9,11 @@
بسامد واژگان جمع شود / باز شود
+
+ +
- - - - - - - @for (int i = 0; i < Model.WordCounts.Length; i++) - { - @if (i % 2 == 0) - { - - - - - - - } - else - { - - - - - - } - } -
ردیفواژهشمار
@Model.WordCounts[i].RowNmbrInCat.ToPersianNumbers()@Model.WordCounts[i].Word@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordCounts[i].Count)
@Model.WordCounts[i].RowNmbrInCat.ToPersianNumbers()@Model.WordCounts[i].Word@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordCounts[i].Count)
+
} \ No newline at end of file diff --git a/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml.cs b/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml.cs index d7381c38..3030cc63 100644 --- a/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml.cs +++ b/GanjooRazor/Pages/_CategoryWordsCountPartial.cshtml.cs @@ -19,5 +19,18 @@ namespace GanjooRazor.Pages /// words counts /// public CategoryWordCount[] WordCounts { get; set; } + + public _CategoryWordsCountTablePartialModel TableModel + { + get + { + return new _CategoryWordsCountTablePartialModel() + { + CatId = CatId, + PoetId = PoetId, + WordCounts = WordCounts + }; + } + } } } diff --git a/GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml b/GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml new file mode 100644 index 00000000..067f1fc6 --- /dev/null +++ b/GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml @@ -0,0 +1,32 @@ +@model GanjooRazor.Pages._CategoryWordsCountTablePartialModel +@using DNTPersianUtils.Core +@{ +} + + + + + + + + @for (int i = 0; i < Model.WordCounts.Length; i++) + { + @if (i % 2 == 0) + { + + + + + + + } + else + { + + + + + + } + } +
ردیفواژهشمار
@Model.WordCounts[i].RowNmbrInCat.ToPersianNumbers()@Model.WordCounts[i].Word@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordCounts[i].Count)
@Model.WordCounts[i].RowNmbrInCat.ToPersianNumbers()@Model.WordCounts[i].Word@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordCounts[i].Count)
diff --git a/GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml.cs b/GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml.cs new file mode 100644 index 00000000..ffb8563e --- /dev/null +++ b/GanjooRazor/Pages/_CategoryWordsCountTablePartial.cshtml.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using RMuseum.Models.Ganjoor; + +namespace GanjooRazor.Pages +{ + public class _CategoryWordsCountTablePartialModel : PageModel + { + /// + /// Cat Id + /// + public int CatId { get; set; } + + /// + /// PoetId + /// + public int PoetId { get; set; } + + /// + /// words counts + /// + public CategoryWordCount[] WordCounts { get; set; } + } +} diff --git a/GanjooRazor/wwwroot/js/bk.js b/GanjooRazor/wwwroot/js/bk.js index c07fd733..ad1beb3c 100644 --- a/GanjooRazor/wwwroot/js/bk.js +++ b/GanjooRazor/wwwroot/js/bk.js @@ -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 = '
بارگذاری
'; + $.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); +} + +