Continued work on download list

This commit is contained in:
RemixDev
2020-04-10 18:00:42 +02:00
parent 55268c72b5
commit c9b3588105
4 changed files with 137 additions and 49 deletions

View File

@@ -99,7 +99,7 @@ var mainSearch = new Vue({
"ALBUM": "Albums",
"PLAYLIST": "Playlists"
},
results: {
results: {
QUERY: "",
ORDER: [],
ALBUM: {},
@@ -113,7 +113,9 @@ var mainSearch = new Vue({
changeSearchTab: function (section) {
if (section != "TOP_RESULT")
clickElement('search_'+section.toLowerCase()+'_tab')
}
},
addToQueue: function(url){socket.emit("addToQueue", {url: url})
console.log(url)}
}
})
@@ -123,12 +125,15 @@ var trackSearch = new Vue({
type: "TRACK",
nb: 40,
query: "",
results: {
results: {
data: [],
next: 0,
total: 0
}
}
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
}
})
var albumSearch = new Vue({
@@ -137,12 +142,15 @@ var albumSearch = new Vue({
type: "ALBUM",
nb: 20,
query: "",
results: {
results: {
data: [],
next: 0,
total: 0
}
}
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
}
})
var artistSearch = new Vue({
@@ -151,12 +159,15 @@ var artistSearch = new Vue({
type: "ARTIST",
nb: 20,
query: "",
results: {
results: {
data: [],
next: 0,
total: 0
}
}
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
}
})
var playlistSearch = new Vue({
@@ -165,12 +176,15 @@ var playlistSearch = new Vue({
type: "PLAYLIST",
nb: 20,
query: "",
results: {
results: {
data: [],
next: 0,
total: 0
}
}
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
}
})
// Search section

View File

@@ -1,21 +1,42 @@
var downloadList = new Vue({
el: '#download_list',
data: {
queue: [],
queueList: {}
}
})
var queueList = {}
var queue = []
socket.on("addedToQueue", function(queueItem){
downloadList.queueList[queueItem.uuid] = queueItem
downloadList.queue.push(queueItem)
queueList[queueItem.uuid] = queueItem
queue.push(queueItem.uuid)
$("#download_list").append(
`<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}">
<div class="download_info">
<img width="75px" class="rounded coverart" src="${queueItem.cover}" alt="Cover ${queueItem.title}"/>
<div class="download_info_data">
<span class="download_line">${queueItem.title}</span> <span class="download_slim_separator"> - </span>
<span class="secondary-text">${queueItem.artist}</span>
</div>
<div class="download_info_status">
<span class="download_line"><span class="queue_downloaded">0</span>/${queueItem.size}</span>
</div>
</div>
<div class="download_bar progress" id="bar-uuid"></div>
</div>`)
})
socket.on("updateQueue", function(update){
if (update.uuid && downloadList.queue.indexOf(update.uuid) > -1){
if (update.uuid && queue.indexOf(update.uuid) > -1){
console.log(update)
if (update.downloaded) downloadList.queueList[update.uuid].downloaded++
if (update.failed) downloadList.queueList[update.uuid].failed++
if (update.progress) downloadList.queueList[update.uuid].progress = update.progress
if (update.downloaded){
queueList[update.uuid].downloaded++
$("#download_"+update.uuid+" .queue_downloaded").text(queueList[update.uuid].downloaded)
}
if (update.failed){
queueList[update.uuid].failed++
if (queueList[update.uuid].failed == 1){
$("#download_"+update.uuid+" .download_info_status").append(`<span class="secondary-text"><span class="download_slim_separator">(</span><span class="queue_failed">1</span> Failed<span class="download_slim_separator">)</span></span>`)
}else{
$("#download_"+update.uuid+" .queue_failed").text(queueList[update.uuid].failed)
}
}
if (update.progress){
queueList[update.uuid].progress = update.progress
}
}
})