#173 deleting old long-running-jobd
This commit is contained in:
parent
e0988bf10d
commit
a0a22be220
@ -29,3 +29,5 @@
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
<a role="button" onclick="cleanUpJobs()" class="actionlink" title="حذف کارهای قدیمی">حذف کارهای قدیمی 🗑</a>
|
||||
|
||||
@ -8,6 +8,7 @@ using RSecurityBackend.Models.Generic.Db;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class LongRunningJobsModel : PageModel
|
||||
{
|
||||
public RLongRunningJobStatus[] Jobs { get; set; }
|
||||
@ -25,8 +26,20 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostCleanupJobsAsync()
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/rjobs/cleanup");
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
return new JsonResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,6 +269,24 @@
|
||||
});
|
||||
}
|
||||
|
||||
function cleanUpJobs() {
|
||||
|
||||
if (!confirm('آیا از حذف همهٔ کارهای موفق و ناموفق تکمیل شده اطمینان دارید؟'))
|
||||
return;
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '?handler=CleanupJobs',
|
||||
error: function () {
|
||||
alert('خطا رخ داد.')
|
||||
},
|
||||
success: function () {
|
||||
alert('انجام شد.')
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@ -34,6 +34,22 @@ namespace RSecurityBackend.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// clean up old jobs
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("cleanup")]
|
||||
[Authorize(Policy = SecurableItem.AuditLogEntityShortName + ":" + SecurableItem.ViewOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<RLongRunningJobStatus>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> CleanUp()
|
||||
{
|
||||
var res = await _jobService.CleanUp(true, true);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
|
||||
@ -440,6 +440,12 @@
|
||||
<param name="failed"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RSecurityBackend.Controllers.RLongRunningJobsControllerBase.CleanUp">
|
||||
<summary>
|
||||
clean up old jobs
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RSecurityBackend.Controllers.RLongRunningJobsControllerBase.#ctor(RSecurityBackend.Services.ILongRunningJobProgressService)">
|
||||
<summary>
|
||||
constructor
|
||||
|
||||
Loading…
Reference in New Issue
Block a user