mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-08-07 10:23:12 -04:00
Refactor
This commit is contained in:
1 parent
e2098d34e0
commit
6801f89883
7 files changed
+102
-14
No files matched your search
@@ -104,8 +104,8 @@ window.RequestarrRequests = {
|
||||
<button class="reqrequests-action-btn reqrequests-action-deny" onclick="RequestarrRequests.denyRequest(${req.id}, this)"><i class="fas fa-times"></i> Deny</button>
|
||||
<button class="reqrequests-action-btn reqrequests-action-blacklist" onclick="RequestarrRequests.blacklistRequest(${req.id})" title="Blacklist"><i class="fas fa-ban"></i> Blacklist</button>`;
|
||||
}
|
||||
if (isOwner) {
|
||||
actions += `<button class="reqrequests-action-btn reqrequests-action-delete" onclick="RequestarrRequests.deleteRequest(${req.id})" title="Delete"><i class="fas fa-trash-alt"></i></button>`;
|
||||
if (req.status === 'pending' && !isOwner) {
|
||||
actions = `<button class="reqrequests-action-btn reqrequests-action-withdraw" onclick="RequestarrRequests.withdrawRequest(${req.id}, this)"><i class="fas fa-undo"></i> Withdraw</button>`;
|
||||
}
|
||||
|
||||
return `<div class="reqrequests-card" data-request-id="${req.id}">
|
||||
@@ -242,6 +242,29 @@ window.RequestarrRequests = {
|
||||
}
|
||||
},
|
||||
|
||||
async withdrawRequest(requestId, btn) {
|
||||
const card = document.querySelector(`.reqrequests-card[data-request-id="${requestId}"]`);
|
||||
if (btn) { btn.disabled = true; btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Withdrawing...'; }
|
||||
if (card) card.classList.add('reqrequests-card-processing');
|
||||
try {
|
||||
const resp = await fetch(`./api/requestarr/requests/${requestId}/withdraw`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({})
|
||||
});
|
||||
const data = await resp.json();
|
||||
if (data.success) {
|
||||
if (window.HuntarrNotifications) window.HuntarrNotifications.showNotification('Request withdrawn', 'success');
|
||||
await this.loadRequests();
|
||||
this._refreshBadge();
|
||||
} else {
|
||||
if (window.HuntarrNotifications) window.HuntarrNotifications.showNotification(data.error || 'Failed', 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[RequestarrRequests] Withdraw error:', e);
|
||||
}
|
||||
},
|
||||
|
||||
async deleteRequest(requestId) {
|
||||
if (window.HuntarrConfirmModal && typeof window.HuntarrConfirmModal.show === 'function') {
|
||||
window.HuntarrConfirmModal.show({
|
||||
|
||||
Reference in new issue
Block a user