mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
add subscribe and unsubscribe buttons for channels and playlists, #81
This commit is contained in:
parent
bad129d630
commit
39304ff2bd
@ -86,7 +86,7 @@
|
|||||||
{% if channel.source.channel_subscribed %}
|
{% if channel.source.channel_subscribed %}
|
||||||
<button type="button" id="{{ channel.source.channel_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ channel.source.channel_name }}">Unsubscribe</button>
|
<button type="button" id="{{ channel.source.channel_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ channel.source.channel_name }}">Unsubscribe</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
false
|
<button type="button" id="{{ channel.source.channel_id }}" onclick="subscribe(this.id)" title="Subscribe to {{ channel.source.channel_name }}">Subscribe</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
{% if channel_info.channel_subscribed %}
|
{% if channel_info.channel_subscribed %}
|
||||||
<button type="button" id="{{ channel_info.channel_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ channel_info.channel_name }}">Unsubscribe</button>
|
<button type="button" id="{{ channel_info.channel_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ channel_info.channel_name }}">Unsubscribe</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
false
|
<button type="button" id="{{ channel_info.channel_id }}" onclick="subscribe(this.id)" title="Subscribe to {{ channel_info.channel_name }}">Subscribe</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% if channel_info.channel_active %}
|
{% if channel_info.channel_active %}
|
||||||
|
@ -62,6 +62,14 @@
|
|||||||
<div class="playlist-desc {{ view_style }}">
|
<div class="playlist-desc {{ view_style }}">
|
||||||
<a href="{% url 'channel_id' playlist.source.playlist_channel_id %}"><h3>{{ playlist.source.playlist_channel }}</h3></a>
|
<a href="{% url 'channel_id' playlist.source.playlist_channel_id %}"><h3>{{ playlist.source.playlist_channel }}</h3></a>
|
||||||
<a href="{% url 'playlist_id' playlist.source.playlist_id %}"><h2>{{ playlist.source.playlist_name }}</h2></a>
|
<a href="{% url 'playlist_id' playlist.source.playlist_id %}"><h2>{{ playlist.source.playlist_name }}</h2></a>
|
||||||
|
<p>Last refreshed: {{ playlist.source.playlist_last_refresh }}</p>
|
||||||
|
<p>Subscribed:
|
||||||
|
{% if playlist.source.playlist_subscribed %}
|
||||||
|
<button type="button" id="{{ playlist.source.playlist_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ playlist.source.playlist_name }}">Unsubscribe</button>
|
||||||
|
{% else %}
|
||||||
|
<button type="button" id="{{ playlist.source.playlist_id }}" onclick="subscribe(this.id)" title="Subscribe to {{ playlist.source.playlist_name }}">Subscribe</button>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
{% if playlist_info.playlist_subscribed %}
|
{% if playlist_info.playlist_subscribed %}
|
||||||
<button type="button" id="{{ playlist_info.playlist_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ playlist_info.playlist_name }}">Unsubscribe</button>
|
<button type="button" id="{{ playlist_info.playlist_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ playlist_info.playlist_name }}">Unsubscribe</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
false
|
<button type="button" id="{{ playlist_info.playlist_id }}" onclick="subscribe(this.id)" title="Subscribe to {{ playlist_info.playlist_name }}">Subscribe</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% if playlist_info.playlist_active %}
|
{% if playlist_info.playlist_active %}
|
||||||
|
@ -997,6 +997,7 @@ class PostData:
|
|||||||
"dl_pending": self.dl_pending,
|
"dl_pending": self.dl_pending,
|
||||||
"queue": self.queue_handler,
|
"queue": self.queue_handler,
|
||||||
"unsubscribe": self.unsubscribe,
|
"unsubscribe": self.unsubscribe,
|
||||||
|
"subscribe": self.subscribe,
|
||||||
"sort_order": self.sort_order,
|
"sort_order": self.sort_order,
|
||||||
"hide_watched": self.hide_watched,
|
"hide_watched": self.hide_watched,
|
||||||
"show_subed_only": self.show_subed_only,
|
"show_subed_only": self.show_subed_only,
|
||||||
@ -1100,6 +1101,13 @@ class PostData:
|
|||||||
|
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
|
|
||||||
|
def subscribe(self):
|
||||||
|
"""subscribe to channel or playlist, called from js buttons"""
|
||||||
|
id_sub = self.exec_val
|
||||||
|
print("subscribe to " + id_sub)
|
||||||
|
subscribe_to.delay(id_sub)
|
||||||
|
return {"success": True}
|
||||||
|
|
||||||
def sort_order(self):
|
def sort_order(self):
|
||||||
"""change the sort between published to downloaded"""
|
"""change the sort between published to downloaded"""
|
||||||
sort_order = {"status": self.exec_val}
|
sort_order = {"status": self.exec_val}
|
||||||
|
@ -717,7 +717,7 @@ button:hover {
|
|||||||
height: unset;
|
height: unset;
|
||||||
background-color: var(--highlight-bg);
|
background-color: var(--highlight-bg);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap-reverse;
|
flex-wrap: wrap;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +46,17 @@ function isUnwatched(youtube_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unsubscribe(id_unsub) {
|
function unsubscribe(id_unsub) {
|
||||||
|
console.log(payload);
|
||||||
var payload = JSON.stringify({'unsubscribe': id_unsub});
|
var payload = JSON.stringify({'unsubscribe': id_unsub});
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById(id_unsub).remove();
|
document.getElementById(id_unsub).replaceWith("You are unsubscribed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribe(id_sub) {
|
||||||
|
var payload = JSON.stringify({'subscribe': id_sub});
|
||||||
|
console.log(payload);
|
||||||
|
sendPost(payload);
|
||||||
|
document.getElementById(id_sub).replaceWith("You are subscribed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeView(image) {
|
function changeView(image) {
|
||||||
|
Loading…
Reference in New Issue
Block a user