#153 long running jobs in UI

This commit is contained in:
Hamid Reza Mohammadi 2021-06-17 14:25:50 +04:30
parent b8f65f965a
commit a949113d3f
3 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,31 @@
@page
@model GanjooRazor.Areas.Admin.Pages.LongRunningJobsModel
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_AdminLayout";
ViewData["Title"] = "کارهای جاری";
}
<h1>@ViewData["Title"]</h1>
<table>
<tr>
<th>کار</th>
<th>شروع</th>
<th>گام</th>
<th>پیشرفت</th>
<th>موفق</th>
<th>خطا</th>
</tr>
@foreach (var job in Model.Jobs)
{
<tr>
<td>@job.Name</td>
<td>@job.StartTime</td>
<td>@job.Step</td>
<td>@job.Progress</td>
<td>@job.Succeeded</td>
<td>@job.Exception</td>
</tr>
}
</table>

View File

@ -0,0 +1,32 @@
using System.Net.Http;
using System.Threading.Tasks;
using GanjooRazor.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using RSecurityBackend.Models.Generic.Db;
namespace GanjooRazor.Areas.Admin.Pages
{
public class LongRunningJobsModel : PageModel
{
public RLongRunningJobStatus[] Jobs { get; set; }
public async Task<IActionResult> OnGetAsync()
{
using (HttpClient secureClient = new HttpClient())
{
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
{
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/rjobs");
response.EnsureSuccessStatusCode();
Jobs = JsonConvert.DeserializeObject<RLongRunningJobStatus[]>(await response.Content.ReadAsStringAsync());
}
}
return Page();
}
}
}

View File

@ -166,6 +166,14 @@
</ul>
</div>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Admin" asp-page="LongRunningJobs">کارها</a>
</li>
</ul>
</div>
</div>
</nav>
</header>