[backend/razor] Require confirmation of queue job abandon/deschedule action
This commit is contained in:
parent
ade4593260
commit
ccf1e60ad4
2 changed files with 14 additions and 3 deletions
|
@ -56,7 +56,7 @@
|
|||
<tr>
|
||||
<td>Actions</td>
|
||||
<td>
|
||||
<a class="fake-link" onclick="abandon('@Model.Job.Id.ToStringLower()')">@abandonName</a>
|
||||
<a class="fake-link" onclick="abandon('@Model.Job.Id.ToStringLower()', event)">@abandonName</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
|
|
@ -34,6 +34,17 @@ function getCookie(key) {
|
|||
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? (result[1]) : null;
|
||||
}
|
||||
|
||||
async function confirm(target, action) {
|
||||
const match = " (confirm)";
|
||||
if (!target.innerText.endsWith(match)) {
|
||||
target.innerText += match;
|
||||
}
|
||||
else {
|
||||
await action();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function callApiMethod(route) {
|
||||
const cookie = getCookie('admin_session');
|
||||
if (cookie == null) throw new Error('Failed to get admin_session cookie');
|
||||
|
@ -64,7 +75,7 @@ async function retryAllOnPage(queue) {
|
|||
window.location.reload();
|
||||
}
|
||||
|
||||
async function abandon(id) {
|
||||
await callApiMethod(`/api/iceshrimp/admin/queue/jobs/${id}/abandon`);
|
||||
async function abandon(id, target) {
|
||||
await confirm(target, () => callApiMethod(`/api/iceshrimp/admin/queue/jobs/${id}/abandon`));
|
||||
window.location.reload();
|
||||
}
|
Loading…
Add table
Reference in a new issue