divan/GanjooRazor/Areas/Admin/Pages/LongRunningJobs.cshtml
2026-08-07 08:37:28 +03:30

92 lines
3.0 KiB
Plaintext

@page
@model GanjooRazor.Areas.Admin.Pages.LongRunningJobsModel
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_AdminLayout";
ViewData["Title"] = "کارهای جاری";
}
<div class="up-page-header">
<h1>@ViewData["Title"]</h1>
</div>
@if (!string.IsNullOrEmpty(Model.LastMessage))
{
<div class="up-alert up-alert--info">@Model.LastMessage</div>
}
<script>
async function cleanUpJobs() {
var ok = await upConfirm('آیا از حذف همهٔ کارهای موفق و ناموفق تکمیل شده اطمینان دارید؟');
if (!ok) return;
$.ajax({
type: "POST",
url: '?handler=CleanupJobs',
error: function () {
upToast('خطا رخ داد.', 'error');
},
success: function () {
location.reload();
},
});
}
async function deleteLongRunningJob(id) {
var ok = await upConfirm('آیا از حذف این کار اطمینان دارید؟');
if (!ok) return;
$.ajax({
type: "DELETE",
url: '',
data: { id: id },
error: function (e) {
upToast(e.responseText || 'خطا رخ داد.', 'error');
},
success: function () {
$('#tr-' + id).remove();
},
});
}
</script>
@if (Model.Jobs != null && Model.Jobs.Length > 0)
{
<div class="up-form-actions" style="margin-bottom:var(--up-space-3);">
<a role="button" onclick="cleanUpJobs()" class="up-btn up-btn--ghost" title="حذف کارهای قدیمی">حذف کارهای قدیمی <i class="noindent-info-button delete-icon"></i></a>
</div>
<table>
<tr>
<th>کار</th>
<th>شروع</th>
<th>گام</th>
<th>پیشرفت</th>
<th>به‌روزآوری</th>
<th>موفق</th>
<th>خطا</th>
<th>#</th>
</tr>
@foreach (var job in Model.Jobs)
{
<tr id="tr-@job.Id">
<td>@job.Name</td>
<td>@job.StartTime</td>
<td>@job.Step</td>
<td>@job.Progress</td>
<td>@job.LastUpdate</td>
<td>@job.Succeeded</td>
<td>@job.Exception</td>
<td><a role="button" onclick="deleteLongRunningJob('@job.Id')" class="up-icon-btn" title="حذف" aria-label="حذف این کار"><i class="noindent-info-button delete-icon"></i></a></td>
</tr>
}
</table>
<div class="up-form-actions" style="margin-top:var(--up-space-3);">
<a role="button" onclick="cleanUpJobs()" class="up-btn up-btn--ghost" title="حذف کارهای قدیمی">حذف کارهای قدیمی <i class="noindent-info-button delete-icon"></i></a>
</div>
}
else if (Model.Jobs != null)
{
<partial name="_EmptyState" model="@("در حال حاضر کار جاری یا اخیری وجود ندارد.")" />
}