mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-12-23 02:10:15 +00:00
add delete download queue pending or ignored, #85
This commit is contained in:
parent
408b0a0c34
commit
3f31e50b69
@ -225,6 +225,18 @@ class PendingList:
|
||||
if not response.ok:
|
||||
print(response.text)
|
||||
|
||||
def delete_pending(self, status):
|
||||
"""delete download queue based on status value"""
|
||||
data = {"query": {"term": {"status": {"value": status}}}}
|
||||
payload = json.dumps(data)
|
||||
url = self.ES_URL + "/ta_download/_delete_by_query"
|
||||
headers = {"Content-type": "application/json"}
|
||||
response = requests.post(
|
||||
url, data=payload, headers=headers, auth=self.ES_AUTH
|
||||
)
|
||||
if not response.ok:
|
||||
print(response.text)
|
||||
|
||||
def ignore_from_pending(self, ignore_list):
|
||||
"""build the bulk query string"""
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
<div class="show-form">
|
||||
<form id='hidden-form' action="/downloads/" method="post">
|
||||
{% csrf_token %}
|
||||
<!-- <textarea rows="4" placeholder="Enter Video Urls or IDs here..." id="vid-url" name="vid-url"></textarea> -->
|
||||
{{ add_form }}
|
||||
<button type="submit">Add to download queue</button>
|
||||
</form>
|
||||
@ -47,11 +46,15 @@
|
||||
<img src="{% static 'img/icon-listview.svg' %}" onclick="changeView(this)" data-origin="downloads" data-value="list" alt="list view">
|
||||
</div>
|
||||
</div>
|
||||
{% if show_ignored_only %}
|
||||
<h2>Ignored from download</h2>
|
||||
{% else %}
|
||||
<h2>Download queue</h2>
|
||||
{% endif %}
|
||||
<div class="title-split">
|
||||
{% if show_ignored_only %}
|
||||
<h2>Ignored from download</h2>
|
||||
<button onclick="deleteQueue(this)" data-id="ignore" title="Delete all previously ignored videos from the queue">Delete all ignored</button>
|
||||
{% else %}
|
||||
<h2>Download queue</h2>
|
||||
<button onclick="deleteQueue(this)" data-id="pending" title="Delete all pending videos from the queue">Delete all queued</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h3>Total videos: {{ max_hits }}</h3>
|
||||
<div class="dl-list {{ view_style }}">
|
||||
{% if all_video_hits %}
|
||||
|
@ -1005,6 +1005,7 @@ class PostData:
|
||||
"show_ignored_only": self.show_ignored_only,
|
||||
"forgetIgnore": self.forget_ignore,
|
||||
"addSingle": self.add_single,
|
||||
"deleteQueue": self.delete_queue,
|
||||
"manual-import": self.manual_import,
|
||||
"re-embed": self.re_embed,
|
||||
"db-backup": self.db_backup,
|
||||
@ -1172,6 +1173,16 @@ class PostData:
|
||||
extrac_dl.delay(youtube_ids)
|
||||
return {"success": True}
|
||||
|
||||
def delete_queue(self):
|
||||
"""delete download queue"""
|
||||
status = self.exec_val
|
||||
print("deleting from download queue: " + status)
|
||||
if status == "pending":
|
||||
PendingList().delete_pending("pending")
|
||||
elif status == "ignore":
|
||||
PendingList().delete_pending("ignore")
|
||||
return {"success": True}
|
||||
|
||||
@staticmethod
|
||||
def manual_import():
|
||||
"""run manual import from settings page"""
|
||||
|
@ -824,6 +824,11 @@ button:hover {
|
||||
filter: var(--img-filter-error);
|
||||
}
|
||||
|
||||
.title-split {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* status message */
|
||||
.download-progress {
|
||||
background-color: var(--highlight-bg);
|
||||
|
@ -138,6 +138,17 @@ function addSingle(button) {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function deleteQueue(button) {
|
||||
var to_delete = button.getAttribute('data-id');
|
||||
var payload = JSON.stringify({'deleteQueue': to_delete});
|
||||
console.log(payload);
|
||||
sendPost(payload);
|
||||
setTimeout(function(){
|
||||
location.reload();
|
||||
return false;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function stopQueue() {
|
||||
var payload = JSON.stringify({'queue': 'stop'});
|
||||
sendPost(payload);
|
||||
|
Loading…
Reference in New Issue
Block a user