mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
delete playlist buttons to frontend
This commit is contained in:
parent
b292a5e309
commit
220d020c76
@ -31,12 +31,19 @@
|
|||||||
false
|
false
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
<button onclick="deleteConfirm()" id="delete-item">Delete Playlist</button>
|
||||||
|
<div class="delete-confirm" id="delete-button">
|
||||||
|
<span>Delete {{ playlist_info.playlist_name }}?</span>
|
||||||
|
<button onclick="deletePlaylist(this)" data-action="metadata" data-id="{{ playlist_info.playlist_id }}">Delete metadata</button>
|
||||||
|
<button onclick="deletePlaylist(this)" data-action="all" class="danger-button" data-id="{{ playlist_info.playlist_id }}">Delete all</button><br>
|
||||||
|
<button onclick="cancelDelete()">Cancel</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-box-item">
|
<div class="info-box-item">
|
||||||
<div>
|
<div>
|
||||||
{% if max_hits %}
|
{% if max_hits %}
|
||||||
<p>Total Videos archived: {{ playlist_info.playlist_entries|length }}/{{ max_hits }}</p>
|
<p>Total Videos archived: {{ max_hits }}/{{ playlist_info.playlist_entries|length }}</p>
|
||||||
<p>Watched: <button title="Mark all videos from {{ playlist_info.playlist_name }} as watched" type="button" id="watched-button" data-id="{{ playlist_info.playlist_id }}" onclick="isWatchedButton(this)">Mark as watched</button></p>
|
<p>Watched: <button title="Mark all videos from {{ playlist_info.playlist_name }} as watched" type="button" id="watched-button" data-id="{{ playlist_info.playlist_id }}" onclick="isWatchedButton(this)">Mark as watched</button></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1009,6 +1009,7 @@ class PostData:
|
|||||||
"channel-search": self.channel_search,
|
"channel-search": self.channel_search,
|
||||||
"delete-video": self.delete_video,
|
"delete-video": self.delete_video,
|
||||||
"delete-channel": self.delete_channel,
|
"delete-channel": self.delete_channel,
|
||||||
|
"delete-playlist": self.delete_playlist,
|
||||||
"find-playlists": self.find_playlists,
|
"find-playlists": self.find_playlists,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,6 +1203,19 @@ class PostData:
|
|||||||
YoutubeChannel(channel_id).delete_channel()
|
YoutubeChannel(channel_id).delete_channel()
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
|
|
||||||
|
def delete_playlist(self):
|
||||||
|
"""delete playlist, only metadata or incl all videos"""
|
||||||
|
playlist_dict = self.exec_val
|
||||||
|
playlist_id = playlist_dict["playlist-id"]
|
||||||
|
playlist_action = playlist_dict["playlist-action"]
|
||||||
|
print(f"delete {playlist_action} from playlist {playlist_id}")
|
||||||
|
if playlist_action == "metadata":
|
||||||
|
YoutubePlaylist(playlist_id).delete_metadata()
|
||||||
|
elif playlist_action == "all":
|
||||||
|
YoutubePlaylist(playlist_id).delete_videos_playlist()
|
||||||
|
|
||||||
|
return {"success": True}
|
||||||
|
|
||||||
def find_playlists(self):
|
def find_playlists(self):
|
||||||
"""add all playlists of a channel"""
|
"""add all playlists of a channel"""
|
||||||
channel_id = self.exec_val
|
channel_id = self.exec_val
|
||||||
|
@ -209,6 +209,10 @@ button:hover {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.delete-confirm button {
|
||||||
|
margin: 3px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.danger-button {
|
.danger-button {
|
||||||
background-color: var(--highlight-error);
|
background-color: var(--highlight-error);
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,23 @@ function deleteChannel(button) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deletePlaylist(button) {
|
||||||
|
var playlist_id = button.getAttribute("data-id");
|
||||||
|
var playlist_action = button.getAttribute("data-action");
|
||||||
|
var payload = JSON.stringify({
|
||||||
|
"delete-playlist": {
|
||||||
|
"playlist-id": playlist_id,
|
||||||
|
"playlist-action": playlist_action
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(payload);
|
||||||
|
sendPost(payload);
|
||||||
|
setTimeout(function(){
|
||||||
|
window.location.replace("/playlist/");
|
||||||
|
return false;
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
function cancelDelete() {
|
function cancelDelete() {
|
||||||
document.getElementById("delete-button").style.display = 'none';
|
document.getElementById("delete-button").style.display = 'none';
|
||||||
document.getElementById("delete-item").style.display = 'block';
|
document.getElementById("delete-item").style.display = 'block';
|
||||||
|
Loading…
Reference in New Issue
Block a user