From 280c773441dbd4be3e67b4adf96feb1ad7881ac3 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 29 Apr 2023 14:17:36 +0700 Subject: [PATCH] add download now to form --- tubearchivist/home/src/download/queue.py | 2 +- tubearchivist/home/templates/home/downloads.html | 7 ++++--- tubearchivist/static/css/style.css | 4 ++++ tubearchivist/static/script.js | 8 ++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tubearchivist/home/src/download/queue.py b/tubearchivist/home/src/download/queue.py index 1ff7917..006b7a0 100644 --- a/tubearchivist/home/src/download/queue.py +++ b/tubearchivist/home/src/download/queue.py @@ -273,7 +273,7 @@ class PendingList(PendingIndex): # add last newline bulk_list.append("\n") query_str = "\n".join(bulk_list) - _, _ = ElasticWrap("_bulk").post(query_str, ndjson=True) + _, _ = ElasticWrap("_bulk?refresh=true").post(query_str, ndjson=True) def _notify_add(self, idx, total): """send notification for adding videos to download queue""" diff --git a/tubearchivist/home/templates/home/downloads.html b/tubearchivist/home/templates/home/downloads.html index a1d9be2..59f4f03 100644 --- a/tubearchivist/home/templates/home/downloads.html +++ b/tubearchivist/home/templates/home/downloads.html @@ -20,11 +20,12 @@ add-icon

Add to download queue

-
+
{% csrf_token %} {{ add_form }} - - + + +
diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index 07b59c0..9ece987 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -369,6 +369,10 @@ button:hover { display: none; } +#hidden-form button { + margin-right: 1rem; +} + #text-reveal { height: 0; overflow: hidden; diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 5916144..cc77074 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -160,18 +160,22 @@ function dlPending() { }, 500); } -function addToQueue() { +function addToQueue(autostart=false) { let textArea = document.getElementById('id_vid_url'); if (textArea.value === '') { return } let toPost = {data: [{youtube_id: textArea.value, status: 'pending'}]}; let apiEndpoint = '/api/download/'; + if (autostart) { + apiEndpoint = `${apiEndpoint}?autostart=true`; + } apiRequest(apiEndpoint, 'POST', toPost); - textArea.value = ""; + textArea.value = ''; setTimeout(function () { checkMessages(); }, 500); + showForm(); } function toIgnore(button) {