From ef75f6dd16d5af928c0d30552f1d6ce76f8a715d Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 9 Oct 2021 20:33:32 +0700 Subject: [PATCH] add delete channel to frontend --- .../home/templates/home/channel_id.html | 14 +++++++++----- tubearchivist/home/templates/home/video.html | 2 +- tubearchivist/static/script.js | 16 +++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/tubearchivist/home/templates/home/channel_id.html b/tubearchivist/home/templates/home/channel_id.html index d17423c..5fc417b 100644 --- a/tubearchivist/home/templates/home/channel_id.html +++ b/tubearchivist/home/templates/home/channel_id.html @@ -38,20 +38,24 @@

- {% if videos %}
{% if channel_info.channel_views >= 1000000 %}

Channel views: {{ channel_info.channel_views|intword }}

- {% else %} + {% elif channel_info.channel_views > 0 %}

Channel views: {{ channel_info.channel_views|intcomma }}

{% endif %} -

Total Videos archived: {{ max_hits }}

-

Watched:

+ {% if max_hits %} +

Total Videos archived: {{ max_hits }}

+

Watched:

+ {% endif %}

Channel id: {{ channel_info.channel_id }}

+ +
+ Delete {{ channel_info.channel_name }} including all videos? +
- {% endif %} {% if channel_info.channel_description %}
diff --git a/tubearchivist/home/templates/home/video.html b/tubearchivist/home/templates/home/video.html index f4fa7c8..0a70ae2 100644 --- a/tubearchivist/home/templates/home/video.html +++ b/tubearchivist/home/templates/home/video.html @@ -47,7 +47,7 @@

Video ID: {{ video.youtube_id }}

- Are you sure? + Are you sure?
diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index 636de79..efeed9d 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -178,18 +178,15 @@ function fsRescan() { // delete from file system function deleteConfirm() { - console.log("confirm delete"); to_show = document.getElementById("delete-button"); document.getElementById("delete-item").style.display = 'none'; to_show.style.display = "block"; } -function deleteItem(button) { +function deleteVideo(button) { var to_delete = button.getAttribute("data-id"); var to_redirect = button.getAttribute("data-redirect"); var payload = JSON.stringify({"delete-video": to_delete}); - console.log(payload); - console.log(to_redirect); sendPost(payload); setTimeout(function(){ var redirect = "/channel/" + to_redirect; @@ -198,8 +195,17 @@ function deleteItem(button) { }, 1000); } +function deleteChannel(button) { + var to_delete = button.getAttribute("data-id"); + var payload = JSON.stringify({"delete-channel": to_delete}); + sendPost(payload); + setTimeout(function(){ + window.location.replace("/channel/"); + return false; + }, 1000); +} + function cancelDelete() { - console.log("cancel delete"); document.getElementById("delete-button").style.display = 'none'; document.getElementById("delete-item").style.display = 'block'; }