add download now to form

This commit is contained in:
simon 2023-04-29 14:17:36 +07:00
parent efca460e9d
commit 280c773441
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
4 changed files with 15 additions and 6 deletions

View File

@ -273,7 +273,7 @@ class PendingList(PendingIndex):
# add last newline # add last newline
bulk_list.append("\n") bulk_list.append("\n")
query_str = "\n".join(bulk_list) 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): def _notify_add(self, idx, total):
"""send notification for adding videos to download queue""" """send notification for adding videos to download queue"""

View File

@ -20,11 +20,12 @@
<img id="animate-icon" onclick="showForm()" src="{% static 'img/icon-add.svg' %}" alt="add-icon"> <img id="animate-icon" onclick="showForm()" src="{% static 'img/icon-add.svg' %}" alt="add-icon">
<p>Add to download queue</p> <p>Add to download queue</p>
<div class="show-form"> <div class="show-form">
<form id='hidden-form'> <div id='hidden-form' novalidate>
{% csrf_token %} {% csrf_token %}
{{ add_form }} {{ add_form }}
<button onclick="addToQueue()">Add to download queue</button> <button onclick="addToQueue()">Add to queue</button>
</form> <button onclick="addToQueue(true)">Download now</button>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -369,6 +369,10 @@ button:hover {
display: none; display: none;
} }
#hidden-form button {
margin-right: 1rem;
}
#text-reveal { #text-reveal {
height: 0; height: 0;
overflow: hidden; overflow: hidden;

View File

@ -160,18 +160,22 @@ function dlPending() {
}, 500); }, 500);
} }
function addToQueue() { function addToQueue(autostart=false) {
let textArea = document.getElementById('id_vid_url'); let textArea = document.getElementById('id_vid_url');
if (textArea.value === '') { if (textArea.value === '') {
return return
} }
let toPost = {data: [{youtube_id: textArea.value, status: 'pending'}]}; let toPost = {data: [{youtube_id: textArea.value, status: 'pending'}]};
let apiEndpoint = '/api/download/'; let apiEndpoint = '/api/download/';
if (autostart) {
apiEndpoint = `${apiEndpoint}?autostart=true`;
}
apiRequest(apiEndpoint, 'POST', toPost); apiRequest(apiEndpoint, 'POST', toPost);
textArea.value = ""; textArea.value = '';
setTimeout(function () { setTimeout(function () {
checkMessages(); checkMessages();
}, 500); }, 500);
showForm();
} }
function toIgnore(button) { function toIgnore(button) {