Skip to content

feat(queue): add bulk clear buttons (All/TV/Movies) and action using …#60

Open
TheMrClaus wants to merge 10 commits intonzbdav-dev:mainfrom
TheMrClaus:feat/queue-bulk-clear
Open

feat(queue): add bulk clear buttons (All/TV/Movies) and action using …#60
TheMrClaus wants to merge 10 commits intonzbdav-dev:mainfrom
TheMrClaus:feat/queue-bulk-clear

Conversation

@TheMrClaus
Copy link

Adds Clear All, Clear TV, and Clear Movies to the Queue page.

  • with three buttons (no new files).
  • Loops over current queue and calls existing removeFromQueue(id) for each match.
  • Filters by slot.cat === "tv" / "movies" (case-insensitive); "all" clears everything.
  • Redirects back to /queue to refresh.

Closes #55

Copilot AI review requested due to automatic review settings August 20, 2025 08:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements bulk clear functionality for the queue page, allowing users to clear all items, only TV shows, or only movies from their download queue with a single action.

  • Adds three new buttons (Clear All, Clear TV, Clear Movies) with confirmation dialogs
  • Implements backend logic to filter queue items by category and remove them in bulk
  • Uses existing removeFromQueue API in a loop to avoid creating new backend endpoints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

console.error("removeFromQueue failed for", id, err);
}
}
}
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a sequential for-loop to remove items one by one can be slow for large queues. Consider implementing a bulk removal API endpoint or using Promise.allSettled() to process removals concurrently.

Suggested change
}
const removalPromises = wanted.map(s => {
const id = s?.nzo_id || s?.nzoId || s?.id; // support slight shape differences
if (!id) return Promise.resolve();
return backendClient.removeFromQueue(id)
.catch(err => {
// Swallow per-item errors so one failure doesn't block the whole clear op
console.error("removeFromQueue failed for", id, err);
});
});
await Promise.allSettled(removalPromises);

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be done in a single database operation, rather than multiple sequential round-trips.

The SABnzbd api spec allows for bulk deletions by passing multiple nzo_id values

But currently nzbdav assumes only a single nzo_id is given. It would need to be updated here to support multiple nzo_ids at once:

Copy link
Owner

@nzbdav-dev nzbdav-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for the PR!

Typically, bulk operations on a table allow for more granular control for which rows will be acted upon, such as with Radarr's checkboxes. The "Select All" checkbox on the Table header can be used in conjunction with Filters to select which rows should be acted upon.

image

That's what I had in mind for Issue #55, but I'll merge this PR as a stop-gap until I can get around to implementing the filters and granular row selection :)

You can ignore most of my comments below, they're all optional. The one thing I will ask is to apply a proper bulk operation in the backend, so that items can be removed in a single call to the database rather than looping through each item and removing them one at a time

Comment on lines +52 to +76
{/* Bulk-clear controls */}
<Form method="post" className="mb-3" onSubmit={(e) => {
const target = e.nativeEvent.submitter as HTMLButtonElement | null;
const action = target?.value ?? "";
const label = action === "all" ? "all items"
: action === "tv" ? "all TV items"
: action === "movies" ? "all Movies items"
: "items";
if (!window.confirm(`Are you sure you want to clear ${label} from the queue?`)) {
e.preventDefault();
}
}}>
<input type="hidden" name="__intent" value="bulk-clear" />
<ButtonGroup>
<Button variant="outline-danger" type="submit" name="clear" value="all">
Clear All
</Button>
<Button variant="outline-warning" type="submit" name="clear" value="tv">
Clear TV
</Button>
<Button variant="outline-primary" type="submit" name="clear" value="movies">
Clear Movies
</Button>
</ButtonGroup>
</Form>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • [required] I think we may need to fix the indenting of these lines here.

image
  • [optional] Since the buttons have different colors, would it make more sense to move them out of the button-group so they can have some spacing between them? The borders colors otherwise overlap each other.
  • [optional] Also, maybe we could hide the buttons until the queue table shows up (until there are items in the queue)
  • [optional] Is there any indication that work is being performed after clicking the button? Is there anything to prevent multiple clicks to the same button before the previous operation has finished?

Let me know your thoughts!

console.error("removeFromQueue failed for", id, err);
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be done in a single database operation, rather than multiple sequential round-trips.

The SABnzbd api spec allows for bulk deletions by passing multiple nzo_id values

But currently nzbdav assumes only a single nzo_id is given. It would need to be updated here to support multiple nzo_ids at once:

TheMrClaus and others added 9 commits August 25, 2025 08:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove duplicate bulk-clear logic
- Fix missing closing braces causing unexpected EOF error
- Restructure action function with proper control flow
- Add error handling for bulk-clear operations
- Separate bulk-clear and NZB upload logic for better organization
…o_id via SAB 'value') in single DB transaction
@TheMrClaus
Copy link
Author

Ty for the PR!

Typically, bulk operations on a table allow for more granular control for which rows will be acted upon, such as with Radarr's checkboxes. The "Select All" checkbox on the Table header can be used in conjunction with Filters to select which rows should be acted upon.

image That's what I had in mind for Issue #55, but I'll merge this PR as a stop-gap until I can get around to implementing the filters and granular row selection :)

You can ignore most of my comments below, they're all optional. The one thing I will ask is to apply a proper bulk operation in the backend, so that items can be removed in a single call to the database rather than looping through each item and removing them one at a time

Very sensible comments, I believe I have now addressed all concerns and pushed my commits. I have implemented a single API call with multiple IDs to the DB. I could not verify with multiple items yet because they go very fast and I can't clear them fast enough. I couldn't get them to pile up like before. Next I will try to implement checkboxes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add Bulk-Actions to queue and history

3 participants