console.log('Version 1:20:2');
const appModal = $('#modalDownloadQueue');
const loader = $("#loader-wrapper");
let ArtistTable = {}; // Initialized for ajax reload
function requestQueue() {
$.ajax({
url: '/api/queue/albums',
success: (response) => {
Alpine.store('app').Queue = JSON.parse(response);
}
})
}
function template_artist_result(element) {
return `
${element.name}
`
}
function construct_artist_result_html(artist_list) {
let html = '
Found Artist
';
let index = 0;
if (artist_list.length > 1) {
artist_list.forEach((element) => {
index += 1;
html += template_artist_result(element);
if (index === 1 && artist_list.length > 1) {
html += '';
html += '
Suggested Artists
'
html += '';
}
})
} else {
html += template_artist_result(artist_list);
}
return html
}
function proc_notification(icon, title, html) {
Swal.fire({
icon: icon,
title: title,
html: html
})
}
function artist_queue_toggle(element) {
let self = $(element);
let artist_name = self.data('artist_name');
self.prop('disabled', true)
$.ajax({
url: `/api/queue/artist/${self.data('artist_id')}`,
success: () => {
proc_notification('success', 'Queued Download', `Artist ${artist_name} Queued for Download!`);
ArtistTable.ajax.reload();
},
error: (response) => {
console.log(response);
proc_notification('error', 'What the flip?!', `Failed to queue artist ${artist_name}