2020-06-24 20:54:36 +00:00
|
|
|
<template>
|
2020-07-28 19:39:44 +00:00
|
|
|
<div id="artist_tab" class="main_tabcontent fixed_footer image_header" ref="root">
|
2020-06-24 20:54:36 +00:00
|
|
|
<header
|
|
|
|
class="inline-flex"
|
|
|
|
:style="{
|
|
|
|
'background-image':
|
|
|
|
'linear-gradient(to bottom, transparent 0%, var(--main-background) 100%), url(\'' + image + '\')'
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<h1>{{ title }}</h1>
|
2020-08-11 19:12:47 +00:00
|
|
|
<div role="button" aria-label="download" @click.stop="addToQueue" :data-link="link" class="fab right">
|
2020-07-25 13:51:36 +00:00
|
|
|
<i class="material-icons" :title="$t('globals.download_hint')">get_app</i>
|
2020-06-24 20:54:36 +00:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div class="tab">
|
2020-07-18 16:06:07 +00:00
|
|
|
<button
|
|
|
|
v-for="(item, name) in body"
|
|
|
|
:key="name"
|
|
|
|
class="selective"
|
|
|
|
:class="{ active: name === currentTab }"
|
|
|
|
:href="'#artist_' + name"
|
|
|
|
@click="changeTab(name)"
|
|
|
|
>
|
2020-07-20 15:59:23 +00:00
|
|
|
{{ $tc(`globals.listTabs.${name}`, 2) }}
|
2020-07-18 16:06:07 +00:00
|
|
|
</button>
|
2020-06-24 20:54:36 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th
|
|
|
|
v-for="data in head"
|
|
|
|
@click="data.sortKey ? sortBy(data.sortKey) : null"
|
|
|
|
:style="{ width: data.width ? data.width : 'auto' }"
|
|
|
|
:class="{
|
|
|
|
'sort-asc': data.sortKey == sortKey && sortOrder == 'asc',
|
|
|
|
'sort-desc': data.sortKey == sortKey && sortOrder == 'desc',
|
|
|
|
sortable: data.sortKey,
|
|
|
|
clickable: data.sortKey
|
|
|
|
}"
|
|
|
|
>
|
2020-07-18 16:06:07 +00:00
|
|
|
<!-- Need to change this behaviour for translations -->
|
2020-06-24 20:54:36 +00:00
|
|
|
{{ data.title }}
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2020-07-18 16:06:07 +00:00
|
|
|
<tr v-for="release in showTable" :key="release.id">
|
2020-06-24 20:54:36 +00:00
|
|
|
<td class="inline-flex clickable" @click="albumView" :data-id="release.id">
|
|
|
|
<img
|
|
|
|
class="rounded coverart"
|
|
|
|
:src="release.cover_small"
|
|
|
|
style="margin-right: 16px; width: 56px; height: 56px;"
|
|
|
|
/>
|
|
|
|
<i v-if="release.explicit_lyrics" class="material-icons explicit_icon">
|
|
|
|
explicit
|
|
|
|
</i>
|
|
|
|
{{ release.title }}
|
2020-07-28 19:39:44 +00:00
|
|
|
<i v-if="checkNewRelease(release.release_date)" class="material-icons" style="color: #ff7300;">
|
2020-06-24 20:54:36 +00:00
|
|
|
fiber_new
|
|
|
|
</i>
|
|
|
|
</td>
|
|
|
|
<td>{{ release.release_date }}</td>
|
2020-08-04 13:11:40 +00:00
|
|
|
<td>{{ release.nb_song }}</td>
|
2020-08-11 19:12:47 +00:00
|
|
|
<td @click.stop="addToQueue" :data-link="release.link" class="clickable">
|
2020-07-25 13:51:36 +00:00
|
|
|
<i class="material-icons" :title="$t('globals.download_hint')">
|
2020-06-24 20:54:36 +00:00
|
|
|
file_download
|
|
|
|
</i>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<footer>
|
2020-07-28 19:39:44 +00:00
|
|
|
<button class="back-button" @click="backTab">{{ $t('globals.back') }}</button>
|
2020-06-24 20:54:36 +00:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { isEmpty, orderBy } from 'lodash-es'
|
2020-07-16 22:11:28 +00:00
|
|
|
import { socket } from '@/utils/socket'
|
|
|
|
import Downloads from '@/utils/downloads'
|
2020-07-28 19:39:44 +00:00
|
|
|
import { showView, backTab } from '@js/tabs'
|
2020-07-16 22:11:28 +00:00
|
|
|
import EventBus from '@/utils/EventBus'
|
2020-06-24 20:54:36 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'artist-tab',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
currentTab: '',
|
|
|
|
sortKey: 'release_date',
|
|
|
|
sortOrder: 'desc',
|
|
|
|
title: '',
|
|
|
|
image: '',
|
|
|
|
type: '',
|
|
|
|
link: '',
|
|
|
|
head: null,
|
|
|
|
body: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2020-07-28 19:39:44 +00:00
|
|
|
backTab,
|
2020-06-24 20:54:36 +00:00
|
|
|
albumView: showView.bind(null, 'album'),
|
|
|
|
reset() {
|
|
|
|
this.title = 'Loading...'
|
|
|
|
this.image = ''
|
|
|
|
this.type = ''
|
|
|
|
this.currentTab = ''
|
|
|
|
this.sortKey = 'release_date'
|
|
|
|
this.sortOrder = 'desc'
|
|
|
|
this.link = ''
|
|
|
|
this.head = []
|
|
|
|
this.body = null
|
|
|
|
},
|
|
|
|
addToQueue(e) {
|
|
|
|
e.stopPropagation()
|
|
|
|
Downloads.sendAddToQueue(e.currentTarget.dataset.link)
|
|
|
|
},
|
|
|
|
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
|
|
|
|
},
|
|
|
|
getCurrentTab() {
|
|
|
|
return this.currentTab
|
|
|
|
},
|
|
|
|
updateSelected() {
|
2020-07-14 20:27:48 +00:00
|
|
|
window.currentStack.selected = this.currentTab
|
2020-06-24 20:54:36 +00:00
|
|
|
},
|
|
|
|
checkNewRelease(date) {
|
|
|
|
let g1 = new Date()
|
|
|
|
let g2 = new Date(date)
|
|
|
|
g2.setDate(g2.getDate() + 3)
|
|
|
|
g1.setHours(0, 0, 0, 0)
|
|
|
|
|
|
|
|
return g1.getTime() <= g2.getTime()
|
|
|
|
},
|
|
|
|
showArtist(data) {
|
2020-07-28 19:39:44 +00:00
|
|
|
this.reset()
|
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
const { name, picture_xl, id, releases } = data
|
|
|
|
|
|
|
|
this.title = name
|
|
|
|
this.image = picture_xl
|
|
|
|
this.type = 'Artist'
|
|
|
|
this.link = `https://www.deezer.com/artist/${id}`
|
|
|
|
if (this.currentTab === '') this.currentTab = Object.keys(releases)[0]
|
|
|
|
this.sortKey = 'release_date'
|
|
|
|
this.sortOrder = 'desc'
|
|
|
|
this.head = [
|
2020-07-28 19:39:44 +00:00
|
|
|
{ title: this.$tc('globals.listTabs.title', 1), sortKey: 'title' },
|
2020-07-20 20:31:54 +00:00
|
|
|
{ title: this.$t('globals.listTabs.releaseDate'), sortKey: 'release_date' },
|
2020-08-04 13:11:40 +00:00
|
|
|
{ title: this.$tc('globals.listTabs.track', 2), sortKey: 'nb_song' },
|
2020-06-24 20:54:36 +00:00
|
|
|
{ title: '', width: '32px' }
|
|
|
|
]
|
|
|
|
if (isEmpty(releases)) {
|
|
|
|
this.body = null
|
|
|
|
} else {
|
|
|
|
this.body = releases
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
showTable() {
|
2020-08-11 19:12:47 +00:00
|
|
|
if (this.body) {
|
|
|
|
if (this.sortKey == 'nb_song')
|
|
|
|
return orderBy(
|
|
|
|
this.body[this.currentTab],
|
|
|
|
function (o) {
|
|
|
|
return new Number(o.nb_song)
|
|
|
|
},
|
|
|
|
this.sortOrder
|
|
|
|
)
|
|
|
|
else return orderBy(this.body[this.currentTab], this.sortKey, this.sortOrder)
|
|
|
|
} else return []
|
2020-06-24 20:54:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-08-31 20:14:14 +00:00
|
|
|
// this.$refs.root.style.display = 'block'
|
2020-07-28 19:39:44 +00:00
|
|
|
console.log('artist mounted')
|
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
socket.on('show_artist', this.showArtist)
|
|
|
|
|
|
|
|
EventBus.$on('artistTab:updateSelected', this.updateSelected)
|
|
|
|
EventBus.$on('artistTab:changeTab', this.changeTab)
|
2020-07-28 19:39:44 +00:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
console.log('artist bef dest')
|
2020-08-31 20:14:14 +00:00
|
|
|
// this.$refs.root.style.display = 'none'
|
2020-06-24 20:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2020-07-20 20:31:54 +00:00
|
|
|
</style>
|