Add seeders, add Remove selected from debrid button

This commit is contained in:
Mukhtar Akere
2025-07-10 15:15:02 +01:00
parent 6fb54d322e
commit b8b9e76753
5 changed files with 27 additions and 9 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+14 -3
View File
@@ -21,6 +21,7 @@ class TorrentDashboard {
sortSelector: document.getElementById('sortSelector'),
selectAll: document.getElementById('selectAll'),
batchDeleteBtn: document.getElementById('batchDeleteBtn'),
batchDeleteDebridBtn: document.getElementById('batchDeleteDebridBtn'),
refreshBtn: document.getElementById('refreshBtn'),
torrentContextMenu: document.getElementById('torrentContextMenu'),
paginationControls: document.getElementById('paginationControls'),
@@ -43,6 +44,7 @@ class TorrentDashboard {
// Batch delete
this.refs.batchDeleteBtn.addEventListener('click', () => this.deleteSelectedTorrents());
this.refs.batchDeleteDebridBtn.addEventListener('click', () => this.deleteSelectedTorrents(true));
// Select all checkbox
this.refs.selectAll.addEventListener('change', (e) => this.toggleSelectAll(e.target.checked));
@@ -260,6 +262,7 @@ class TorrentDashboard {
torrentRowTemplate(torrent) {
const progressPercent = (torrent.progress * 100).toFixed(1);
const isSelected = this.state.selectedTorrents.has(torrent.hash);
let addedOn = new Date(torrent.added_on).toLocaleString();
return `
<tr data-hash="${torrent.hash}"
@@ -305,6 +308,9 @@ class TorrentDashboard {
'<span class="text-base-content/50">None</span>'
}
</td>
<td class="text-nowrap font-mono text-sm">
${torrent.num_seeds || 0}
</td>
<td>
<div class="badge ${this.getStateColor(torrent.state)} badge-sm">
${this.escapeHtml(torrent.state)}
@@ -415,6 +421,7 @@ class TorrentDashboard {
// Update batch delete button
this.refs.batchDeleteBtn.classList.toggle('hidden', this.state.selectedTorrents.size === 0);
this.refs.batchDeleteDebridBtn.classList.toggle('hidden', this.state.selectedTorrents.size === 0);
// Update select all checkbox
const visibleTorrents = this.state.filteredTorrents.slice(
@@ -497,16 +504,20 @@ class TorrentDashboard {
}
}
async deleteSelectedTorrents() {
async deleteSelectedTorrents(removeFromDebrid = false) {
const count = this.state.selectedTorrents.size;
if (!confirm(`Are you sure you want to delete ${count} selected torrent${count > 1 ? 's' : ''}?`)) {
if (count === 0) {
window.decypharrUtils.createToast('No torrents selected for deletion', 'warning');
return;
}
if (!confirm(`Are you sure you want to delete ${count} torrent${count > 1 ? 's' : ''}${removeFromDebrid ? ' from debrid' : ''}?`)) {
return;
}
try {
const hashes = Array.from(this.state.selectedTorrents).join(',');
const response = await window.decypharrUtils.fetcher(
`/api/torrents/?hashes=${encodeURIComponent(hashes)}`,
`/api/torrents/?hashes=${encodeURIComponent(hashes)}&removeFromDebrid=${removeFromDebrid}`,
{ method: 'DELETE' }
);
+10 -3
View File
@@ -7,10 +7,14 @@
<div class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4">
<!-- Batch Actions -->
<div class="flex items-center gap-2">
<button class="btn btn-error btn-sm hidden" id="batchDeleteBtn">
<button class="btn btn-secondary btn-sm hidden" id="batchDeleteBtn">
<i class="bi bi-trash"></i>
<span class="hidden sm:inline">Delete Selected</span>
</button>
<button class="btn btn-error btn-sm hidden" id="batchDeleteDebridBtn">
<i class="bi bi-cloud-fog-fill"></i>
<span class="hidden sm:inline">Remove From Debrid</span>
</button>
<button class="btn btn-outline btn-sm" id="refreshBtn">
<i class="bi bi-arrow-clockwise"></i>
<span class="hidden sm:inline">Refresh</span>
@@ -73,6 +77,9 @@
<th class="font-semibold">
<i class="bi bi-cloud mr-2"></i>Debrid
</th>
<th class="font-semibold">
<i class="bi bi-people mr-2"></i>Seeders
</th>
<th class="font-semibold">
<i class="bi bi-activity mr-2"></i>State
</th>
@@ -115,14 +122,14 @@
<li class="menu-title">
<span class="torrent-name text-sm font-bold truncate max-w-48"></span>
</li>
<li><hr class="my-1"></li>
<hr/>
<li><a class="menu-item text-sm" data-action="copy-magnet">
<i class="bi bi-magnet text-primary"></i>Copy Magnet Link
</a></li>
<li><a class="menu-item text-sm" data-action="copy-name">
<i class="bi bi-clipboard text-info"></i>Copy Name
</a></li>
<li><hr class="my-1"></li>
<hr/>
<li><a class="menu-item text-sm text-error" data-action="delete">
<i class="bi bi-trash"></i>Delete Torrent
</a></li>