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

@ -54,6 +54,7 @@ div#middle_section {
border: 0px;
border-radius: 6px;
background-color: var(--secondary-background);
color: var(--primary-text)
}
#content{
background-color: var(--main-background);
@ -132,7 +133,7 @@ div#middle_section {
margin: 0px;
margin-bottom: 4px;
}
.top_result > .info_box > p.subtitle, .release > p.subtitle {
.secondary-text {
opacity: 0.75;
font-size: 14px;
}
@ -154,6 +155,14 @@ div#middle_section {
display: inline-block;
width: 156px;
}
.release > img{
width: 156px;
height: 156px;
}
.track_row > td > img{
width: 32px;
height: 32px;
}
/* Download tab section */
div#download_tab_container{
@ -181,14 +190,59 @@ div#download_tab{
font-size: 24px;
margin: 4px;
}
.release > img{
width: 156px;
height: 156px;
#download_list{
margin: 0px 8px;
}
.track_row > td > img{
width: 32px;
height: 32px;
#download_list > .download_object{
padding-bottom: 8px;
}
#download_list > .download_object .download_info{
display: flex;
align-items: center;
}
#download_list > .download_object .download_info img{
width: 75px;
height: 75px;
display: inline-block;
}
#download_list > .download_object .download_info .download_line{
display: block;
}
#download_list > .download_object .download_info .download_slim_separator{
display: none;
}
#download_list > .download_object .download_info_data{
width: calc(100% - 83px);
padding-left: 8px;
}
#download_list > .download_object .download_info_status{
width: 80px;
}
#download_list.slim > .download_object .download_info img{
display: none;
}
#download_list.slim > .download_object .download_info .download_line{
display: inline-block;
}
#download_list.slim > .download_object .download_info .download_slim_separator{
display: inline-block;
}
#download_list.slim > .download_object .download_info_data{
width: auto;
display: inline-block;
padding-left: 0px;
}
#download_list.slim > .download_object .download_info_status{
width: auto;
display: inline-block;
float: right;
}
#download_list.slim > .download_object .download_info{
display: block;
}
/* Global stuff */
img.rounded {
border-radius: 5px;
@ -196,7 +250,6 @@ img.rounded {
img.circle {
border-radius: 50%;
}
.coverart{
background-color: var(--secondary-background);
}
@ -208,7 +261,9 @@ span.tag {
font-size: 10px;
padding: 3px 6px;
}
.tracks_table{
width: 100%;
}
.clickable{
cursor: pointer;
}

View file

@ -49,8 +49,8 @@
<img v-bind:src="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'https://e-cdns-images.dzcdn.net/images/artist/' + results.TOP_RESULT[0].ART_PICTURE : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'https://e-cdns-images.dzcdn.net/images/cover/' + results.TOP_RESULT[0].ALB_PICTURE : results.TOP_RESULT[0].__TYPE__ == 'playlist' ? 'https://e-cdns-images.dzcdn.net/images/'+ results.TOP_RESULT[0].PICTURE_TYPE +'/' + results.TOP_RESULT[0].PLAYLIST_PICTURE :'https://e-cdns-images.dzcdn.net/images/cover/') + '/156x156-000000-80-0-0.jpg'"
v-bind:class="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'circle' : 'rounded') + ' coverart'"></img>
<div class="info_box">
<p class="title">{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].ART_NAME : results.TOP_RESULT[0].__TYPE__ == 'album' ? results.TOP_RESULT[0].ALB_TITLE : results.TOP_RESULT[0].__TYPE__ == 'playlist' ? results.TOP_RESULT[0].TITLE : '' }}</p>
<p class="subtitle">{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? numberWithDots(results.TOP_RESULT[0].NB_FAN) + ' fans' : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'by '+results.TOP_RESULT[0].ART_NAME+' - '+results.TOP_RESULT[0].NUMBER_TRACK+' tracks' : results.TOP_RESULT[0].__TYPE__ == 'playlist' ? 'by '+results.TOP_RESULT[0].PARENT_USERNAME+' - '+results.TOP_RESULT[0].NB_SONG+' tracks' : '' }}</p>
<p class="primary-text">{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].ART_NAME : results.TOP_RESULT[0].__TYPE__ == 'album' ? results.TOP_RESULT[0].ALB_TITLE : results.TOP_RESULT[0].__TYPE__ == 'playlist' ? results.TOP_RESULT[0].TITLE : '' }}</p>
<p class="secondary-text">{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? numberWithDots(results.TOP_RESULT[0].NB_FAN) + ' fans' : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'by '+results.TOP_RESULT[0].ART_NAME+' - '+results.TOP_RESULT[0].NUMBER_TRACK+' tracks' : results.TOP_RESULT[0].__TYPE__ == 'playlist' ? 'by '+results.TOP_RESULT[0].PARENT_USERNAME+' - '+results.TOP_RESULT[0].NB_SONG+' tracks' : '' }}</p>
<span class="tag">{{ results.TOP_RESULT[0].__TYPE__.charAt(0).toUpperCase() + results.TOP_RESULT[0].__TYPE__.substring(1)}}</span>
</div>
</div>
@ -62,15 +62,15 @@
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</td>
<td style="width: 56px;"><i class="material-icons">get_app</i></td>
<td v-on:click="addToQueue('https://www.deezer.com/track/'+track.SNG_ID)" style="width: 56px;" class="clickable"100%><i class="material-icons">get_app</i></td>
</tr>
</table>
</div>
<div v-if="section != 'TRACK' && section != 'TOP_RESULT'" class="release_grid firstrow_only">
<div v-for="release in results[section].data.slice(0, 10)" class="release">
<img v-bind:class="(section == 'ARTIST' ? 'circle' : 'rounded') + ' coverart'" v-bind:src="(section == 'ARTIST' ? 'https://e-cdns-images.dzcdn.net/images/artist/' + release.ART_PICTURE : section == 'ALBUM' ? 'https://e-cdns-images.dzcdn.net/images/cover/' + release.ALB_PICTURE : section == 'PLAYLIST' ? 'https://e-cdns-images.dzcdn.net/images/'+ release.PICTURE_TYPE +'/' + release.PLAYLIST_PICTURE : 'https://e-cdns-images.dzcdn.net/images/cover/' ) + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ section == 'ARTIST' ? release.ART_NAME : section == 'ALBUM' ? release.ALB_TITLE : section == 'PLAYLIST' ? release.TITLE : '' }}</p>
<p class="subtitle">{{ section == 'ARTIST' ? numberWithDots(release.NB_FAN) + ' fans' : section == 'ALBUM' ? release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' : section == 'PLAYLIST' ? release.NB_SONG+' tracks' : '' }}</p>
<p class="primary-text">{{ section == 'ARTIST' ? release.ART_NAME : section == 'ALBUM' ? release.ALB_TITLE : section == 'PLAYLIST' ? release.TITLE : '' }}</p>
<p class="secondary-text">{{ section == 'ARTIST' ? numberWithDots(release.NB_FAN) + ' fans' : section == 'ALBUM' ? release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' : section == 'PLAYLIST' ? release.NB_SONG+' tracks' : '' }}</p>
</div>
</div>
</div>
@ -94,12 +94,12 @@
<th style="width: 56px;"></th>
</tr>
<tr v-for="track in results.data" class="track_row">
<td><img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/'+track.ALB_PICTURE+'/32x32-000000-80-0-0.jpg'"></td>
<td style="width: 48px;"><img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/'+track.ALB_PICTURE+'/32x32-000000-80-0-0.jpg'"></td>
<td>{{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}}</td>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</td>
<td><i class="material-icons">get_app</i></td>
<td v-on:click="addToQueue('https://www.deezer.com/track/'+track.SNG_ID)" style="width: 56px;" class="clickable"><i class="material-icons">get_app</i></td>
</tr>
</table>
</div>
@ -111,8 +111,8 @@
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/' + release.ALB_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.ALB_TITLE }}</p>
<p class="subtitle">{{ 'by '+release.ART_NAME }}</p>
<p class="primary-text">{{ release.ALB_TITLE }}</p>
<p class="secondary-text">{{ 'by '+release.ART_NAME }}</p>
</div>
</div>
</div>
@ -124,8 +124,8 @@
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="circle coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/artist/' + release.ART_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.ART_NAME }}</p>
<p class="subtitle">{{ numberWithDots(release.NB_FAN) + ' fans' }}</p>
<p class="primary-text">{{ release.ART_NAME }}</p>
<p class="secondary-text">{{ numberWithDots(release.NB_FAN) + ' fans' }}</p>
</div>
</div>
</div>
@ -137,8 +137,8 @@
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/'+ release.PICTURE_TYPE +'/' + release.PLAYLIST_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.TITLE }}</p>
<p class="subtitle">{{ release.NB_SONG+' tracks' }}</p>
<p class="primary-text">{{ release.TITLE }}</p>
<p class="secondary-text">{{ release.NB_SONG+' tracks' }}</p>
</div>
</div>
</div>
@ -159,10 +159,8 @@
</div>
<div id="download_tab">
<i id="hide_download_tab" class="material-icons download_bar_icon">chevron_right</i>
<div id="download_list">
<div v-for="item in queue">
{{ item.artist }} - {{ item.title }} | {{ item.downloaded }} {{ item.size }}
</div>
<div id="download_list" class="">
</div>
</div>
</div>

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
}
}
})