2020-06-24 20:54:36 +00:00
|
|
|
<template>
|
2020-07-28 19:39:44 +00:00
|
|
|
<div id="tracklist_tab" class="main_tabcontent fixed_footer image_header" ref="root">
|
2020-06-24 20:54:36 +00:00
|
|
|
<header
|
|
|
|
:style="{
|
|
|
|
'background-image':
|
|
|
|
'linear-gradient(to bottom, transparent 0%, var(--main-background) 100%), url(\'' + image + '\')'
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<h1 class="inline-flex">
|
|
|
|
{{ title }} <i v-if="explicit" class="material-icons explicit_icon explicit_icon--right">explicit</i>
|
|
|
|
</h1>
|
|
|
|
<h2 class="inline-flex">
|
2020-07-18 20:44:27 +00:00
|
|
|
<span v-if="metadata">{{ metadata }}</span>
|
|
|
|
<span class="right" v-if="release_date">{{ release_date }}</span>
|
2020-06-24 20:54:36 +00:00
|
|
|
</h2>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<table class="table table--tracklist">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
<i class="material-icons">music_note</i>
|
|
|
|
</th>
|
|
|
|
<th>#</th>
|
2020-07-23 15:46:35 +00:00
|
|
|
<th>{{ $tc('globals.listTabs.title', 1) }}</th>
|
2020-07-18 20:44:27 +00:00
|
|
|
<th>{{ $tc('globals.listTabs.artist', 1) }}</th>
|
2020-07-20 20:31:54 +00:00
|
|
|
<th v-if="type === 'playlist'">{{ $tc('globals.listTabs.album', 1) }}</th>
|
2020-06-24 20:54:36 +00:00
|
|
|
<th>
|
|
|
|
<i class="material-icons">timer</i>
|
|
|
|
</th>
|
|
|
|
<th class="table__icon table__cell--center clickable">
|
|
|
|
<input @click="toggleAll" class="selectAll" type="checkbox" />
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2020-07-20 20:31:54 +00:00
|
|
|
<template v-if="type !== 'spotifyPlaylist'">
|
2020-07-25 13:22:16 +00:00
|
|
|
<template v-for="(track, index) in body">
|
|
|
|
<tr v-if="track.type == 'track'" @click="selectRow(index, track)">
|
2020-06-24 20:54:36 +00:00
|
|
|
<td class="table__cell--x-small table__cell--center">
|
|
|
|
<div class="table__cell-content table__cell-content--vertical-center">
|
|
|
|
<i
|
|
|
|
class="material-icons"
|
|
|
|
:class="{ preview_playlist_controls: track.preview, disabled: !track.preview }"
|
|
|
|
v-on="{ click: track.preview ? playPausePreview : false }"
|
|
|
|
:data-preview="track.preview"
|
2020-07-25 13:51:36 +00:00
|
|
|
:title="$t('globals.play_hint')"
|
2020-06-24 20:54:36 +00:00
|
|
|
>
|
|
|
|
play_arrow
|
|
|
|
</i>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td class="table__cell--small table__cell--center track_position">
|
2020-07-20 20:31:54 +00:00
|
|
|
{{ type === 'album' ? track.track_position : body.indexOf(track) + 1 }}
|
2020-06-24 20:54:36 +00:00
|
|
|
</td>
|
|
|
|
<td class="table__cell--large table__cell--with-icon">
|
|
|
|
<div class="table__cell-content table__cell-content--vertical-center">
|
2020-09-19 15:07:28 +00:00
|
|
|
<i v-if="track.explicit_lyrics" class="material-icons explicit_icon"> explicit </i>
|
2020-06-24 20:54:36 +00:00
|
|
|
{{
|
|
|
|
track.title +
|
2020-07-27 20:01:57 +00:00
|
|
|
(track.title_version && track.title.indexOf(track.title_version) == -1
|
|
|
|
? ' ' + track.title_version
|
|
|
|
: '')
|
2020-06-24 20:54:36 +00:00
|
|
|
}}
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td
|
|
|
|
class="table__cell--medium table__cell--center clickable"
|
|
|
|
@click="artistView"
|
|
|
|
:data-id="track.artist.id"
|
|
|
|
>
|
|
|
|
{{ track.artist.name }}
|
|
|
|
</td>
|
|
|
|
<td
|
2020-07-20 20:31:54 +00:00
|
|
|
v-if="type == 'playlist'"
|
2020-06-24 20:54:36 +00:00
|
|
|
class="table__cell--medium table__cell--center clickable"
|
|
|
|
@click="albumView"
|
|
|
|
:data-id="track.album.id"
|
|
|
|
>
|
|
|
|
{{ track.album.title }}
|
|
|
|
</td>
|
|
|
|
<td
|
|
|
|
class="table__cell--center"
|
2020-07-20 20:31:54 +00:00
|
|
|
:class="{ 'table__cell--small': type === 'album', 'table__cell--x-small': type === 'playlist' }"
|
2020-06-24 20:54:36 +00:00
|
|
|
>
|
|
|
|
{{ convertDuration(track.duration) }}
|
|
|
|
</td>
|
|
|
|
<td class="table__icon table__cell--center">
|
|
|
|
<input class="clickable" type="checkbox" v-model="track.selected" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
2020-09-19 15:07:28 +00:00
|
|
|
<tr v-else-if="track.type == 'disc_separator'" class="table__row-no-highlight" style="opacity: 0.54">
|
2020-06-24 20:54:36 +00:00
|
|
|
<td>
|
2020-09-19 15:07:28 +00:00
|
|
|
<div class="table__cell-content table__cell-content--vertical-center" style="opacity: 0.54">
|
2020-06-24 20:54:36 +00:00
|
|
|
<i class="material-icons">album</i>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td class="table__cell--center">
|
|
|
|
{{ track.number }}
|
|
|
|
</td>
|
|
|
|
<td colspan="4"></td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<tr v-for="(track, i) in body">
|
|
|
|
<td>
|
|
|
|
<i
|
|
|
|
v-if="track.preview_url"
|
|
|
|
@click="playPausePreview"
|
|
|
|
:class="'material-icons' + (track.preview_url ? ' preview_playlist_controls' : '')"
|
|
|
|
:data-preview="track.preview_url"
|
2020-07-25 13:51:36 +00:00
|
|
|
:title="$t('globals.play_hint')"
|
2020-06-24 20:54:36 +00:00
|
|
|
>
|
2020-07-18 20:44:27 +00:00
|
|
|
play_arrow
|
|
|
|
</i>
|
2020-06-24 20:54:36 +00:00
|
|
|
<i v-else class="material-icons disabled">play_arrow</i>
|
|
|
|
</td>
|
|
|
|
<td>{{ i + 1 }}</td>
|
|
|
|
<td class="inline-flex">
|
|
|
|
<i v-if="track.explicit" class="material-icons explicit_icon">explicit</i>
|
|
|
|
{{ track.name }}
|
|
|
|
</td>
|
|
|
|
<td>{{ track.artists[0].name }}</td>
|
|
|
|
<td>{{ track.album.name }}</td>
|
|
|
|
<td>{{ convertDuration(Math.floor(track.duration_ms / 1000)) }}</td>
|
|
|
|
<td><input class="clickable" type="checkbox" v-model="track.selected" /></td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2020-09-19 15:07:28 +00:00
|
|
|
<span v-if="label" style="opacity: 0.4; margin-top: 8px; display: inline-block; font-size: 13px">{{ label }}</span>
|
2020-06-24 20:54:36 +00:00
|
|
|
<footer>
|
2020-08-11 19:12:47 +00:00
|
|
|
<button @click.stop="addToQueue" :data-link="link">
|
2020-09-19 15:07:28 +00:00
|
|
|
{{ `${$t('globals.download', { thing: $tc(`globals.listTabs.${type}`, 1) })}` }}
|
2020-06-24 20:54:36 +00:00
|
|
|
</button>
|
2020-08-11 19:12:47 +00:00
|
|
|
<button class="with_icon" @click.stop="addToQueue" :data-link="selectedLinks()">
|
2020-07-18 20:44:27 +00:00
|
|
|
{{ $t('tracklist.downloadSelection') }}<i class="material-icons">file_download</i>
|
2020-06-24 20:54:36 +00:00
|
|
|
</button>
|
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 } from 'lodash-es'
|
2020-07-16 22:11:28 +00:00
|
|
|
import { socket } from '@/utils/socket'
|
2020-07-28 19:39:44 +00:00
|
|
|
import { showView, backTab } from '@js/tabs.js'
|
2020-07-16 22:11:28 +00:00
|
|
|
import Downloads from '@/utils/downloads'
|
|
|
|
import Utils from '@/utils/utils'
|
|
|
|
import EventBus from '@/utils/EventBus'
|
2020-06-24 20:54:36 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'tracklist-tab',
|
|
|
|
data: () => ({
|
|
|
|
title: '',
|
|
|
|
metadata: '',
|
|
|
|
release_date: '',
|
|
|
|
label: '',
|
|
|
|
explicit: false,
|
|
|
|
image: '',
|
2020-07-18 20:44:27 +00:00
|
|
|
type: 'empty',
|
2020-06-24 20:54:36 +00:00
|
|
|
link: '',
|
|
|
|
body: []
|
|
|
|
}),
|
|
|
|
methods: {
|
2020-07-28 19:39:44 +00:00
|
|
|
backTab,
|
2020-06-24 20:54:36 +00:00
|
|
|
artistView: showView.bind(null, 'artist'),
|
|
|
|
albumView: showView.bind(null, 'album'),
|
2020-07-16 20:49:08 +00:00
|
|
|
playPausePreview(e) {
|
|
|
|
EventBus.$emit('trackPreview:playPausePreview', e)
|
|
|
|
},
|
2020-06-24 20:54:36 +00:00
|
|
|
reset() {
|
|
|
|
this.title = 'Loading...'
|
|
|
|
this.image = ''
|
|
|
|
this.metadata = ''
|
|
|
|
this.label = ''
|
|
|
|
this.release_date = ''
|
|
|
|
this.explicit = false
|
2020-07-18 20:44:27 +00:00
|
|
|
this.type = 'empty'
|
2020-06-24 20:54:36 +00:00
|
|
|
this.body = []
|
|
|
|
},
|
|
|
|
addToQueue(e) {
|
|
|
|
Downloads.sendAddToQueue(e.currentTarget.dataset.link)
|
|
|
|
},
|
|
|
|
toggleAll(e) {
|
|
|
|
this.body.forEach(item => {
|
|
|
|
if (item.type == 'track') {
|
|
|
|
item.selected = e.currentTarget.checked
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
selectedLinks() {
|
|
|
|
var selected = []
|
|
|
|
if (this.body) {
|
|
|
|
this.body.forEach(item => {
|
|
|
|
if (item.type == 'track' && item.selected)
|
2020-07-20 20:31:54 +00:00
|
|
|
selected.push(this.type == 'spotifyPlaylist' ? item.uri : item.link)
|
2020-06-24 20:54:36 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return selected.join(';')
|
|
|
|
},
|
|
|
|
convertDuration: Utils.convertDuration,
|
|
|
|
showAlbum(data) {
|
2020-07-28 19:39:44 +00:00
|
|
|
this.reset()
|
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
const {
|
|
|
|
id: albumID,
|
|
|
|
title: albumTitle,
|
|
|
|
explicit_lyrics,
|
|
|
|
label: albumLabel,
|
|
|
|
artist: { name: artistName },
|
|
|
|
tracks: albumTracks,
|
|
|
|
tracks: { length: numberOfTracks },
|
|
|
|
release_date,
|
|
|
|
cover_xl
|
|
|
|
} = data
|
|
|
|
|
2020-07-20 20:31:54 +00:00
|
|
|
this.type = 'album'
|
2020-06-24 20:54:36 +00:00
|
|
|
this.link = `https://www.deezer.com/album/${albumID}`
|
|
|
|
this.title = albumTitle
|
|
|
|
this.explicit = explicit_lyrics
|
|
|
|
this.label = albumLabel
|
2020-07-20 20:31:54 +00:00
|
|
|
this.metadata = `${artistName} • ${this.$tc('globals.listTabs.trackN', numberOfTracks)}`
|
2020-06-24 20:54:36 +00:00
|
|
|
this.release_date = release_date.substring(0, 10)
|
|
|
|
this.image = cover_xl
|
|
|
|
|
|
|
|
if (isEmpty(albumTracks)) {
|
|
|
|
this.body = null
|
|
|
|
} else {
|
|
|
|
this.body = albumTracks
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showPlaylist(data) {
|
2020-07-28 19:39:44 +00:00
|
|
|
this.reset()
|
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
const {
|
|
|
|
id: playlistID,
|
|
|
|
title: playlistTitle,
|
|
|
|
picture_xl: playlistCover,
|
|
|
|
creation_date,
|
|
|
|
creator: { name: creatorName },
|
|
|
|
tracks: playlistTracks,
|
|
|
|
tracks: { length: numberOfTracks }
|
|
|
|
} = data
|
|
|
|
|
2020-07-20 20:31:54 +00:00
|
|
|
this.type = 'playlist'
|
2020-06-24 20:54:36 +00:00
|
|
|
this.link = `https://www.deezer.com/playlist/${playlistID}`
|
|
|
|
this.title = playlistTitle
|
|
|
|
this.image = playlistCover
|
|
|
|
this.release_date = creation_date.substring(0, 10)
|
2020-09-19 15:07:28 +00:00
|
|
|
this.metadata = `${this.$t('globals.by', { artist: creatorName })} • ${this.$tc(
|
|
|
|
'globals.listTabs.trackN',
|
|
|
|
numberOfTracks
|
|
|
|
)}`
|
2020-06-24 20:54:36 +00:00
|
|
|
|
|
|
|
if (isEmpty(playlistTracks)) {
|
|
|
|
this.body = null
|
|
|
|
} else {
|
|
|
|
this.body = playlistTracks
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showSpotifyPlaylist(data) {
|
2020-07-28 19:39:44 +00:00
|
|
|
this.reset()
|
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
const {
|
|
|
|
uri: playlistURI,
|
|
|
|
name: playlistName,
|
|
|
|
images,
|
|
|
|
images: { length: numberOfImages },
|
|
|
|
owner: { display_name: ownerName },
|
|
|
|
tracks: playlistTracks,
|
|
|
|
tracks: { length: numberOfTracks }
|
|
|
|
} = data
|
|
|
|
|
2020-07-20 20:31:54 +00:00
|
|
|
this.type = 'spotifyPlaylist'
|
2020-06-24 20:54:36 +00:00
|
|
|
this.link = playlistURI
|
|
|
|
this.title = playlistName
|
|
|
|
this.image = numberOfImages
|
|
|
|
? images[0].url
|
|
|
|
: 'https://e-cdns-images.dzcdn.net/images/cover/d41d8cd98f00b204e9800998ecf8427e/1000x1000-000000-80-0-0.jpg'
|
|
|
|
this.release_date = ''
|
2020-09-19 15:07:28 +00:00
|
|
|
this.metadata = `${this.$t('globals.by', { artist: ownerName })} • ${this.$tc(
|
|
|
|
'globals.listTabs.trackN',
|
|
|
|
numberOfTracks
|
|
|
|
)}`
|
2020-06-24 20:54:36 +00:00
|
|
|
|
|
|
|
if (isEmpty(playlistTracks)) {
|
|
|
|
this.body = null
|
|
|
|
} else {
|
|
|
|
this.body = playlistTracks
|
|
|
|
}
|
2020-07-25 13:22:16 +00:00
|
|
|
},
|
|
|
|
selectRow(index, track) {
|
2020-07-27 20:01:57 +00:00
|
|
|
track.selected = !track.selected
|
2020-06-24 20:54:36 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-07-25 13:22:16 +00:00
|
|
|
EventBus.$on('tracklistTab:selectRow', this.selectRow)
|
2020-06-24 20:54:36 +00:00
|
|
|
|
|
|
|
socket.on('show_album', this.showAlbum)
|
|
|
|
socket.on('show_playlist', this.showPlaylist)
|
|
|
|
socket.on('show_spotifyplaylist', this.showSpotifyPlaylist)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2020-07-20 20:31:54 +00:00
|
|
|
</style>
|