#152 finding or tagging category poems with prosody information

This commit is contained in:
Hamid Reza Mohammadi 2021-06-17 17:06:34 +04:30
parent a949113d3f
commit 496b55c73f
4 changed files with 71 additions and 7 deletions

View File

@ -67,11 +67,22 @@
<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>
<p><a role="button" onclick="tagCatWithRhymes(@Model.Cat.Cat.Id)" class="actionlink">شروع قافیه‌یابی</a></p>
<table>
<tr>
<td colspan="2">
<input type="text" name="rhythm" id="rhythm" list="rythms" size="50" />
<datalist id="rythms">
@if (Model.Rhythms != null)
@foreach (var rhythm in Model.Rhythms)
{
<option value="@rhythm.Rhythm">@rhythm.Rhythm</option>
}
</datalist>
<p><a role="button" onclick="tagCatWithRhythms(@Model.Cat.Cat.Id)" class="actionlink">شروع وزن‌یابی یا وزن‌گذاری</a></p>
</td>
</tr>
<tr>
<td>شناسه:</td>
<td>@Model.Cat.Cat.Id</td>

View File

@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RMuseum.Models.Ganjoor;
using RMuseum.Models.Ganjoor.ViewModels;
namespace GanjooRazor.Areas.Admin.Pages
@ -50,6 +51,12 @@ namespace GanjooRazor.Areas.Admin.Pages
public GanjoorBatchNamingModel NamingModel { get; set; }
/// <summary>
/// rythm
/// </summary>
public GanjoorMetre[] Rhythms { get; set; }
/// <summary>
/// last message
/// </summary>
@ -74,6 +81,12 @@ namespace GanjooRazor.Areas.Admin.Pages
pageQuery.EnsureSuccessStatusCode();
PageInformation = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPageCompleteViewModel>();
var rhythmResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/rhythms");
rhythmResponse.EnsureSuccessStatusCode();
Rhythms = JsonConvert.DeserializeObject<GanjoorMetre[]>(await rhythmResponse.Content.ReadAsStringAsync());
}
public async Task<IActionResult> OnGetAsync()
@ -130,5 +143,21 @@ namespace GanjooRazor.Areas.Admin.Pages
}
return new OkObjectResult(false);
}
public async Task<IActionResult> OnPostStartRhythmAnalysisAsync(int id, string rhythm)
{
using (HttpClient secureClient = new HttpClient())
{
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
{
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/startassigningrhythms/{id}/{false}?rhythm={rhythm}", null);
response.EnsureSuccessStatusCode();
return new OkObjectResult(true);
}
}
return new OkObjectResult(false);
}
}
}

View File

@ -81,12 +81,12 @@
<span class="inputlabel">وزن (شعر): </span>
</td>
<td>
<input asp-for="ModifyModel.Rhythm" list="rythms" />
<input asp-for="ModifyModel.Rhythm" size="50" list="rythms" />
<datalist id="rythms">
@if (Model.Rhythms != null)
@foreach (var rythm in Model.Rhythms)
@foreach (var rhythm in Model.Rhythms)
{
<option value="@rythm.Rhythm">@rythm.Rhythm</option>
<option value="@rhythm.Rhythm">@rhythm.Rhythm</option>
}
</datalist>

View File

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