diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-13 15:20:08 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-13 15:20:08 -0500 |
| commit | b3a60dc7f411dc94ef5f06af33f7b4a88011c611 (patch) | |
| tree | 58bd1d1e6dd76e1b0f112e488c901cff14f3bffb /Biz/PodcastItLater/Web.py | |
| parent | 9b9d38440b2390ad8d0ec47dba0891f5ce91565f (diff) | |
Add remove button to queue status items
- Add 'Remove' button for non-pending queue items (error, processing,
cancelled) - Keep 'Cancel' button for pending items - Update
delete_queue_item to check referer and return appropriate response -
Use HX-Trigger for queue updates from user page, HX-Redirect for admin
- Add confirmation dialog for remove action - Allow admins to delete
any job, users can only delete their own
Amp-Thread-ID:
https://ampcode.com/threads/T-8edacbeb-b343-49ca-b524-1c999272acb6
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Biz/PodcastItLater/Web.py')
| -rw-r--r-- | Biz/PodcastItLater/Web.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/Biz/PodcastItLater/Web.py b/Biz/PodcastItLater/Web.py index 71970cd..f4c65b1 100644 --- a/Biz/PodcastItLater/Web.py +++ b/Biz/PodcastItLater/Web.py @@ -433,7 +433,7 @@ class QueueStatus(Component[AnyChildren, QueueStatusAttrs]): if item["error_message"] else [] ), - # Add cancel button for pending jobs + # Add cancel button for pending jobs, remove for others html.div( html.button( html.i(classes=["bi", "bi-x-lg", "me-1"]), @@ -451,11 +451,28 @@ class QueueStatus(Component[AnyChildren, QueueStatusAttrs]): "btn-outline-danger", "mt-2", ], + ) + if item["status"] == "pending" + else html.button( + html.i(classes=["bi", "bi-trash", "me-1"]), + "Remove", + hx_delete=f"/queue/{item['id']}", + hx_trigger="click", + hx_confirm="Remove this item from the queue?", + hx_on=( + "htmx:afterRequest: " + "if(event.detail.successful) " + "htmx.trigger('body', 'queue-updated')" + ), + classes=[ + "btn", + "btn-sm", + "btn-outline-secondary", + "mt-2", + ], ), classes=["mt-2"], - ) - if item["status"] == "pending" - else html.div(), + ), classes=["card-body"], ), classes=["card", "mb-2"], |
