feat: add refresh playlist functionality

This commit is contained in:
Kamil
2024-12-17 17:45:06 +00:00
parent 8c9fb43f01
commit 4d06b257cb
3 changed files with 71 additions and 0 deletions

View File

@@ -9,6 +9,29 @@
<p>{{ item.track_count }} songs, {{ total_duration }}</p>
<p>Last Updated: {{ item.last_updated}} | Last Change: {{ item.last_changed}}</p>
{% include 'partials/_add_remove_button.html' %}
{% if session['is_admin'] and item.jellyfin_id %}
<p>
<button id="refresh-playlist-btn" class="btn btn-primary mt-2">Refresh Playlist in Jellyfin</button>
<script>
document.getElementById('refresh-playlist-btn').addEventListener('click', function() {
fetch(`/refresh_playlist/{{item.jellyfin_id}}`)
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Playlist refreshed successfully');
} else {
alert('Failed to refresh playlist');
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while refreshing the playlist');
});
});
</script>
</p>
{% endif %}
</div>
</div>
</div>