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
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"""

View File

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

View File

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

View File

@ -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) {