2020-04-28 18:42:22 +00:00
|
|
|
import { socket } from '../socket.js'
|
|
|
|
import Downloads from '../downloads.js'
|
|
|
|
import QualityModal from '../quality-modal.js'
|
|
|
|
import { albumView } from '../tabs.js'
|
2020-04-21 20:20:19 +00:00
|
|
|
|
2020-04-23 19:03:12 +00:00
|
|
|
const ArtistTab = new Vue({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
currentTab: '',
|
|
|
|
sortKey: 'release_date',
|
|
|
|
sortOrder: 'desc',
|
|
|
|
title: '',
|
|
|
|
image: '',
|
|
|
|
type: '',
|
|
|
|
link: '',
|
|
|
|
head: null,
|
|
|
|
body: null
|
|
|
|
}
|
2020-04-21 20:20:19 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2020-04-22 20:06:59 +00:00
|
|
|
albumView,
|
2020-04-23 19:03:12 +00:00
|
|
|
reset() {
|
|
|
|
this.title = 'Loading...'
|
|
|
|
this.image = ''
|
|
|
|
this.type = ''
|
|
|
|
this.currentTab = ''
|
|
|
|
this.sortKey = 'release_date'
|
|
|
|
this.sortOrder = 'desc'
|
|
|
|
this.link = ''
|
|
|
|
this.head = []
|
|
|
|
this.body = null
|
|
|
|
},
|
2020-04-21 20:20:19 +00:00
|
|
|
addToQueue(e) {
|
|
|
|
e.stopPropagation()
|
2020-04-22 20:06:59 +00:00
|
|
|
Downloads.sendAddToQueue(e.currentTarget.dataset.link)
|
2020-04-21 20:20:19 +00:00
|
|
|
},
|
|
|
|
openQualityModal(e) {
|
|
|
|
e.preventDefault()
|
2020-04-22 20:06:59 +00:00
|
|
|
QualityModal.open(e.currentTarget.dataset.link)
|
2020-04-21 20:20:19 +00:00
|
|
|
},
|
|
|
|
moreInfo(url, e) {
|
|
|
|
if (e) e.preventDefault()
|
|
|
|
showTrackListSelective(url, true)
|
|
|
|
},
|
|
|
|
sortBy(key) {
|
|
|
|
if (key == this.sortKey) {
|
|
|
|
this.sortOrder = this.sortOrder == 'asc' ? 'desc' : 'asc'
|
|
|
|
} else {
|
|
|
|
this.sortKey = key
|
|
|
|
this.sortOrder = 'asc'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
changeTab(tab) {
|
|
|
|
this.currentTab = tab
|
|
|
|
},
|
|
|
|
checkNewRelease(date) {
|
2020-04-23 19:03:12 +00:00
|
|
|
let g1 = new Date()
|
|
|
|
let g2 = new Date(date)
|
2020-04-21 20:20:19 +00:00
|
|
|
g2.setDate(g2.getDate() + 3)
|
|
|
|
g1.setHours(0, 0, 0, 0)
|
2020-04-23 19:03:12 +00:00
|
|
|
|
|
|
|
return g1.getTime() <= g2.getTime()
|
|
|
|
},
|
|
|
|
showArtist(data) {
|
|
|
|
this.title = data.name
|
|
|
|
this.image = data.picture_xl
|
|
|
|
this.type = 'Artist'
|
|
|
|
this.link = `https://www.deezer.com/artist/${data.id}`
|
|
|
|
this.currentTab = Object.keys(data.releases)[0]
|
|
|
|
this.sortKey = 'release_date'
|
|
|
|
this.sortOrder = 'desc'
|
|
|
|
this.head = [
|
|
|
|
{ title: 'Title', sortKey: 'title' },
|
|
|
|
{ title: 'Release Date', sortKey: 'release_date' },
|
|
|
|
{ title: '', width: '32px' }
|
|
|
|
]
|
|
|
|
if (_.isEmpty(data.releases)) {
|
|
|
|
this.body = null
|
2020-04-21 20:20:19 +00:00
|
|
|
} else {
|
2020-04-23 19:03:12 +00:00
|
|
|
this.body = data.releases
|
2020-04-21 20:20:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
showTable() {
|
|
|
|
if (this.body) return _.orderBy(this.body[this.currentTab], this.sortKey, this.sortOrder)
|
|
|
|
else return []
|
|
|
|
}
|
2020-04-22 20:06:59 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
2020-04-23 19:03:12 +00:00
|
|
|
socket.on('show_artist', this.showArtist)
|
2020-04-21 20:20:19 +00:00
|
|
|
}
|
2020-04-23 19:03:12 +00:00
|
|
|
}).$mount('#artist_tab')
|
|
|
|
|
|
|
|
export default ArtistTab
|