#152 tagging cat rhymes in UI

This commit is contained in:
Hamid Reza Mohammadi 2021-06-17 14:14:04 +04:30
parent c962386334
commit b8f65f965a
3 changed files with 44 additions and 3 deletions

View File

@ -65,7 +65,11 @@
}
</table>
<a href="/Admin/ModifyPage?id=@Model.PageInformation.Id">ویرایش صفحهٔ متناظر</a>
<p><a href="/Admin/ModifyPage?id=@Model.PageInformation.Id">ویرایش صفحهٔ متناظر</a></p>
<p><a role="button" onclick="tagCatWithPoems(@Model.Cat.Cat.Id)" class="actionlink">شروع قافیه‌یابی</a></p>
<table>
<tr>

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using GanjooRazor.Utils;
@ -13,6 +12,7 @@ using RMuseum.Models.Ganjoor.ViewModels;
namespace GanjooRazor.Areas.Admin.Pages
{
[IgnoreAntiforgeryToken(Order = 1001)]
public class CatUtilsModel : PageModel
{
// <summary>
@ -116,5 +116,19 @@ namespace GanjooRazor.Areas.Admin.Pages
return Page();
}
public async Task<IActionResult> OnPostStartRhymeAnalysisAsync(int id)
{
using (HttpClient secureClient = new HttpClient())
{
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
{
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/startassigningrhymes/{id}/{false}", null);
response.EnsureSuccessStatusCode();
return new OkObjectResult(true);
}
}
return new OkObjectResult(false);
}
}
}

View File

@ -76,6 +76,29 @@
});
}
function tagCatWithPoems(catId) {
if (!confirm('آیا از شروع کار قافیه‌یابی اطمینان دارید؟'))
return;
var url = '?handler=StartRhymeAnalysis';
$.ajax({
type: "POST",
url: url,
data: {
id: catId
},
error: function () {
alert('خطا رخ داد.')
},
success: function () {
alert('کار قافیه‌یابی بخش شروع شد.')
},
});
}
function deleteItem(itemId, itemName) {
if (!confirm('آیا از حذف این ' + itemName+' اطمینان دارید؟'))