From 51ec765433eff97d42ebf9fd45d54268327965e9 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 25 Sep 2021 15:35:36 +0700 Subject: [PATCH] add kill queue function to frontend --- tubearchivist/home/views.py | 13 ++++--------- tubearchivist/static/css/dark.css | 1 + tubearchivist/static/css/light.css | 1 + tubearchivist/static/css/style.css | 10 +++++++++- tubearchivist/static/progress.js | 9 +++++++++ tubearchivist/static/script.js | 5 +++++ 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 9e061d5..633dd03 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -482,7 +482,6 @@ class PostData: "ignore": self.ignore, "dl_pending": self.dl_pending, "queue": self.queue_handler, - "kill_queue": self.kill_queue, "unsubscribe": self.unsubscribe, "sort_order": self.sort_order, "hide_watched": self.hide_watched, @@ -534,17 +533,13 @@ class PostData: if to_execute == "stop": print("stopping download queue") RedisQueue("dl_queue").clear() + elif to_execute == "kill": + task_id = get_message("dl_queue_id") + print("brutally killing " + task_id) + kill_dl(task_id) return {"success": True} - @staticmethod - def kill_queue(): - """brutally murder the celery task""" - task_id = get_message("dl_queue_id") - print("brutally killing " + task_id) - kill_dl(task_id) - return {"success": True} - def unsubscribe(self): """unsubscribe from channel""" channel_id_unsub = self.exec_val diff --git a/tubearchivist/static/css/dark.css b/tubearchivist/static/css/dark.css index 0b5a95d..a2669b9 100644 --- a/tubearchivist/static/css/dark.css +++ b/tubearchivist/static/css/dark.css @@ -7,4 +7,5 @@ --accent-font-dark: #259485; --accent-font-light: #97d4c8; --img-filter: invert(50%) sepia(9%) saturate(2940%) hue-rotate(122deg) brightness(94%) contrast(90%); + --img-filter-error: invert(16%) sepia(60%) saturate(3717%) hue-rotate(349deg) brightness(86%) contrast(120%); } diff --git a/tubearchivist/static/css/light.css b/tubearchivist/static/css/light.css index 05cfd9e..e2a85d0 100644 --- a/tubearchivist/static/css/light.css +++ b/tubearchivist/static/css/light.css @@ -7,4 +7,5 @@ --accent-font-dark: #259485; --accent-font-light: #35b399; --img-filter: invert(50%) sepia(9%) saturate(2940%) hue-rotate(122deg) brightness(94%) contrast(90%); + --img-filter-error: invert(83%) sepia(35%) saturate(1238%) hue-rotate(297deg) brightness(103%) contrast(97%); } diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index ebc0f68..b2c3572 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -470,8 +470,16 @@ button:hover { .dl-control-icons img { width: 30px; - filter: var(--img-filter); cursor: pointer; + margin: 5px; +} + +#stop-icon { + filter: var(--img-filter); +} + +#kill-icon { + filter: var(--img-filter-error); } /* status message */ diff --git a/tubearchivist/static/progress.js b/tubearchivist/static/progress.js index da12385..10115ba 100644 --- a/tubearchivist/static/progress.js +++ b/tubearchivist/static/progress.js @@ -82,13 +82,22 @@ function buildDownloadIcons() { var box = document.getElementById('downloadControl'); var iconBox = document.createElement('div'); iconBox.classList = 'dl-control-icons'; + // stop icon var stopIcon = document.createElement('img'); stopIcon.setAttribute('id', "stop-icon"); stopIcon.setAttribute('title', "Stop Download Queue"); stopIcon.setAttribute('src', "/static/img/icon-stop.svg"); stopIcon.setAttribute('alt', "stop icon"); stopIcon.setAttribute('onclick', 'stopQueue()'); + // kill icon + var killIcon = document.createElement('img'); + killIcon.setAttribute('id', "kill-icon"); + killIcon.setAttribute('title', "Kill Download Queue"); + killIcon.setAttribute('src', "/static/img/icon-close.svg"); + killIcon.setAttribute('alt', "kill icon"); + killIcon.setAttribute('onclick', 'killQueue()'); // stich together iconBox.appendChild(stopIcon); + iconBox.appendChild(killIcon); box.appendChild(iconBox); } diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index c4939b3..cdc452e 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -85,6 +85,11 @@ function stopQueue() { document.getElementById('stop-icon').remove(); } +function killQueue() { + var payload = JSON.stringify({'queue': 'kill'}); + sendPost(payload); + document.getElementById('kill-icon').remove(); +} // settings page buttons function manualImport() {