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: 0px;
border-radius: 6px; border-radius: 6px;
background-color: var(--secondary-background); background-color: var(--secondary-background);
color: var(--primary-text)
} }
#content{ #content{
background-color: var(--main-background); background-color: var(--main-background);
@ -132,7 +133,7 @@ div#middle_section {
margin: 0px; margin: 0px;
margin-bottom: 4px; margin-bottom: 4px;
} }
.top_result > .info_box > p.subtitle, .release > p.subtitle { .secondary-text {
opacity: 0.75; opacity: 0.75;
font-size: 14px; font-size: 14px;
} }
@ -154,6 +155,14 @@ div#middle_section {
display: inline-block; display: inline-block;
width: 156px; width: 156px;
} }
.release > img{
width: 156px;
height: 156px;
}
.track_row > td > img{
width: 32px;
height: 32px;
}
/* Download tab section */ /* Download tab section */
div#download_tab_container{ div#download_tab_container{
@ -181,14 +190,59 @@ div#download_tab{
font-size: 24px; font-size: 24px;
margin: 4px; margin: 4px;
} }
.release > img{
width: 156px; #download_list{
height: 156px; margin: 0px 8px;
} }
.track_row > td > img{ #download_list > .download_object{
width: 32px; padding-bottom: 8px;
height: 32px;
} }
#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 */ /* Global stuff */
img.rounded { img.rounded {
border-radius: 5px; border-radius: 5px;
@ -196,7 +250,6 @@ img.rounded {
img.circle { img.circle {
border-radius: 50%; border-radius: 50%;
} }
.coverart{ .coverart{
background-color: var(--secondary-background); background-color: var(--secondary-background);
} }
@ -208,7 +261,9 @@ span.tag {
font-size: 10px; font-size: 10px;
padding: 3px 6px; padding: 3px 6px;
} }
.tracks_table{ .tracks_table{
width: 100%; width: 100%;
} }
.clickable{
cursor: pointer;
}

View File

@ -49,8 +49,8 @@ <h1 v-on:click="changeSearchTab(section)">{{ names[section] }}</h1>
<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'" <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> v-bind:class="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'circle' : 'rounded') + ' coverart'"></img>
<div class="info_box"> <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="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="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="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> <span class="tag">{{ results.TOP_RESULT[0].__TYPE__.charAt(0).toUpperCase() + results.TOP_RESULT[0].__TYPE__.substring(1)}}</span>
</div> </div>
</div> </div>
@ -62,15 +62,15 @@ <h1 v-on:click="changeSearchTab(section)">{{ names[section] }}</h1>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td> <td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td> <td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</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> </tr>
</table> </table>
</div> </div>
<div v-if="section != 'TRACK' && section != 'TOP_RESULT'" class="release_grid firstrow_only"> <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"> <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'"> <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="primary-text">{{ 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="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> </div>
</div> </div>
@ -94,12 +94,12 @@ <h1>No Tracks found</h1>
<th style="width: 56px;"></th> <th style="width: 56px;"></th>
</tr> </tr>
<tr v-for="track in results.data" class="track_row"> <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>{{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}}</td>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td> <td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td> <td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</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> </tr>
</table> </table>
</div> </div>
@ -111,8 +111,8 @@ <h1>No Albums found</h1>
<div class="release_grid" v-if="results.data.length > 0"> <div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release"> <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'"> <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="primary-text">{{ release.ALB_TITLE }}</p>
<p class="subtitle">{{ 'by '+release.ART_NAME }}</p> <p class="secondary-text">{{ 'by '+release.ART_NAME }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -124,8 +124,8 @@ <h1>No Artists found</h1>
<div class="release_grid" v-if="results.data.length > 0"> <div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release"> <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'"> <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="primary-text">{{ release.ART_NAME }}</p>
<p class="subtitle">{{ numberWithDots(release.NB_FAN) + ' fans' }}</p> <p class="secondary-text">{{ numberWithDots(release.NB_FAN) + ' fans' }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -137,8 +137,8 @@ <h1>No Playlists found</h1>
<div class="release_grid" v-if="results.data.length > 0"> <div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release"> <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'"> <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="primary-text">{{ release.TITLE }}</p>
<p class="subtitle">{{ release.NB_SONG+' tracks' }}</p> <p class="secondary-text">{{ release.NB_SONG+' tracks' }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -159,10 +159,8 @@ <h1>No Playlists found</h1>
</div> </div>
<div id="download_tab"> <div id="download_tab">
<i id="hide_download_tab" class="material-icons download_bar_icon">chevron_right</i> <i id="hide_download_tab" class="material-icons download_bar_icon">chevron_right</i>
<div id="download_list"> <div id="download_list" class="">
<div v-for="item in queue">
{{ item.artist }} - {{ item.title }} | {{ item.downloaded }} {{ item.size }}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -113,7 +113,9 @@ var mainSearch = new Vue({
changeSearchTab: function (section) { changeSearchTab: function (section) {
if (section != "TOP_RESULT") if (section != "TOP_RESULT")
clickElement('search_'+section.toLowerCase()+'_tab') clickElement('search_'+section.toLowerCase()+'_tab')
} },
addToQueue: function(url){socket.emit("addToQueue", {url: url})
console.log(url)}
} }
}) })
@ -128,6 +130,9 @@ var trackSearch = new Vue({
next: 0, next: 0,
total: 0 total: 0
} }
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
} }
}) })
@ -142,6 +147,9 @@ var albumSearch = new Vue({
next: 0, next: 0,
total: 0 total: 0
} }
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
} }
}) })
@ -156,6 +164,9 @@ var artistSearch = new Vue({
next: 0, next: 0,
total: 0 total: 0
} }
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
} }
}) })
@ -170,6 +181,9 @@ var playlistSearch = new Vue({
next: 0, next: 0,
total: 0 total: 0
} }
},
methods: {
addToQueue: function(url){socket.emit("addToQueue", {url: url})}
} }
}) })

View File

@ -1,21 +1,42 @@
var downloadList = new Vue({ var queueList = {}
el: '#download_list', var queue = []
data: {
queue: [],
queueList: {}
}
})
socket.on("addedToQueue", function(queueItem){ socket.on("addedToQueue", function(queueItem){
downloadList.queueList[queueItem.uuid] = queueItem queueList[queueItem.uuid] = queueItem
downloadList.queue.push(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){ 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) console.log(update)
if (update.downloaded) downloadList.queueList[update.uuid].downloaded++ if (update.downloaded){
if (update.failed) downloadList.queueList[update.uuid].failed++ queueList[update.uuid].downloaded++
if (update.progress) downloadList.queueList[update.uuid].progress = update.progress $("#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
}
} }
}) })