Implemented Favorites tab
This commit is contained in:
parent
b3c60ef775
commit
e703ee66a7
@ -1,5 +1,6 @@
|
|||||||
/* Tabs */
|
/* Tabs */
|
||||||
.search_tabcontent,
|
.search_tabcontent,
|
||||||
.main_tabcontent {
|
.main_tabcontent,
|
||||||
|
.favorites_tabcontent {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
@ -366,6 +366,91 @@ <h1>Charts</h1>
|
|||||||
|
|
||||||
<div id="favorites_tab" class="main_tabcontent">
|
<div id="favorites_tab" class="main_tabcontent">
|
||||||
<h1>Favorites</h1>
|
<h1>Favorites</h1>
|
||||||
|
<div class="tab">
|
||||||
|
<button class="favorites_tablinks" id="favorites_playlist_tab">Playlists</button>
|
||||||
|
<button class="favorites_tablinks" id="favorites_album_tab">Albums</button>
|
||||||
|
<button class="favorites_tablinks" id="favorites_artist_tab">Artists</button>
|
||||||
|
<button class="favorites_tablinks" id="favorites_track_tab">Tracks</button>
|
||||||
|
</div>
|
||||||
|
<div id="playlist_favorites" class="favorites_tabcontent">
|
||||||
|
<div v-if="playlists.length == 0">
|
||||||
|
<h1>No Playlists found</h1>
|
||||||
|
</div>
|
||||||
|
<div class="release_grid" v-if="playlists.length > 0">
|
||||||
|
<div v-for="release in playlists" class="release clickable" @click="playlistView"
|
||||||
|
:data-id="release.id">
|
||||||
|
<div class="cover_container">
|
||||||
|
<img class="rounded coverart" :src="release.picture_medium">
|
||||||
|
<div role="button" aria-label="download" @contextmenu.prevent="openQualityModal"
|
||||||
|
@click.stop="addToQueue" :data-link="release.link" class="download_overlay"><i
|
||||||
|
class="material-icons">get_app</i></div>
|
||||||
|
</div>
|
||||||
|
<p class="primary-text">{{ release.title }}</p>
|
||||||
|
<p class="secondary-text">{{ 'by '+release.creator.name+' - '+release.nb_tracks+' tracks' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="album_favorites" class="favorites_tabcontent">
|
||||||
|
<div v-if="albums.length == 0">
|
||||||
|
<h1>No Favorite Albums found</h1>
|
||||||
|
</div>
|
||||||
|
<div class="release_grid" v-if="albums.length > 0">
|
||||||
|
<div v-for="release in albums" class="release clickable" @click="albumView" :data-id="release.id">
|
||||||
|
<div class="cover_container">
|
||||||
|
<img class="rounded coverart" :src="release.cover_medium">
|
||||||
|
<div role="button" aria-label="download" @contextmenu.prevent="openQualityModal"
|
||||||
|
@click.stop="addToQueue" :data-link="release.link" class="download_overlay"><i
|
||||||
|
class="material-icons">get_app</i></div>
|
||||||
|
</div>
|
||||||
|
<p class="primary-text">{{ release.title }}</p>
|
||||||
|
<p class="secondary-text">{{ 'by '+release.artist.name }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="artist_favorites" class="favorites_tabcontent">
|
||||||
|
<div v-if="artists.length == 0">
|
||||||
|
<h1>No Favorite Artist found</h1>
|
||||||
|
</div>
|
||||||
|
<div class="release_grid" v-if="artists.length > 0">
|
||||||
|
<div v-for="release in artists" class="release clickable" @click="artistView" :data-id="release.id">
|
||||||
|
<div class="cover_container">
|
||||||
|
<img class="circle coverart" :src="release.picture_medium">
|
||||||
|
<div role="button" aria-label="download" @contextmenu.prevent="openQualityModal"
|
||||||
|
@click.stop="addToQueue" :data-link="release.link" class="download_overlay"><i
|
||||||
|
class="material-icons">get_app</i></div>
|
||||||
|
</div>
|
||||||
|
<p class="primary-text">{{ release.name }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="track_favorites" class="favorites_tabcontent">
|
||||||
|
<div v-if="tracks.length == 0">
|
||||||
|
<h1>No Favorite Tracks found</h1>
|
||||||
|
</div>
|
||||||
|
<table v-if="tracks.length > 0">
|
||||||
|
<tr v-for="track in tracks" class="track_row">
|
||||||
|
<td class="top-tracks-position" :class="{ first: track.position === 1 }">{{ track.position }}</td>
|
||||||
|
<td style="width: 48px; text-align: center;">
|
||||||
|
<a href="#" @click="playPausePreview" :class="'rounded' + (track.preview ? ' single-cover' : '')"
|
||||||
|
:data-preview="track.preview"><i @mouseenter="previewMouseEnter" @mouseleave="previewMouseLeave"
|
||||||
|
v-if="track.preview" class="material-icons preview_controls">play_arrow</i><img
|
||||||
|
class="rounded coverart" :src="track.album.cover_small">
|
||||||
|
</td>
|
||||||
|
<td class="breakline">
|
||||||
|
{{ track.title + (track.title_version && track.title.indexOf(track.title_version) == -1 ? ' '+ track.title_version : '') }}
|
||||||
|
</td>
|
||||||
|
<td class="breakline clickable" @click="artistView" :data-id="track.artist.id">
|
||||||
|
{{track.artist.name}}</td>
|
||||||
|
<td class="breakline clickable" @click="albumView" :data-id="track.album.id">
|
||||||
|
{{track.album.title}}</td>
|
||||||
|
<td>{{convertDuration(track.duration)}}</td>
|
||||||
|
<td role="button" aria-label="download" @contextmenu.prevent="openQualityModal"
|
||||||
|
@click.stop="addToQueue" :data-link="track.link" style="width: 56px; text-align: center;"
|
||||||
|
class="clickable"><i class="material-icons">get_app</i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="analyzer_tab" class="main_tabcontent">
|
<div id="analyzer_tab" class="main_tabcontent">
|
||||||
|
45
public/js/modules/components/favorites-tab.js
Normal file
45
public/js/modules/components/favorites-tab.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { socket } from '../socket.js'
|
||||||
|
import { playlistView, artistView, albumView } from '../tabs.js'
|
||||||
|
import Downloads from '../downloads.js'
|
||||||
|
import QualityModal from '../quality-modal.js'
|
||||||
|
import TrackPreview from '../track-preview.js'
|
||||||
|
import Utils from '../utils.js'
|
||||||
|
|
||||||
|
const FavoritesTab = new Vue({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tracks: [],
|
||||||
|
albums: [],
|
||||||
|
artists: [],
|
||||||
|
playlists: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
playlistView,
|
||||||
|
artistView,
|
||||||
|
albumView,
|
||||||
|
playPausePreview: TrackPreview.playPausePreview,
|
||||||
|
previewMouseEnter: TrackPreview.previewMouseEnter,
|
||||||
|
previewMouseLeave: TrackPreview.previewMouseLeave,
|
||||||
|
convertDuration: Utils.convertDuration,
|
||||||
|
addToQueue(e) {
|
||||||
|
e.stopPropagation()
|
||||||
|
Downloads.sendAddToQueue(e.currentTarget.dataset.link)
|
||||||
|
},
|
||||||
|
openQualityModal(e) {
|
||||||
|
QualityModal.open(e.currentTarget.dataset.link)
|
||||||
|
},
|
||||||
|
initFavorites(data) {
|
||||||
|
this.tracks = data.tracks
|
||||||
|
this.albums = data.albums
|
||||||
|
this.artists = data.artists
|
||||||
|
this.playlists = data.playlists
|
||||||
|
document.getElementById('favorites_playlist_tab').click()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
socket.on('init_favorites', this.initFavorites)
|
||||||
|
}
|
||||||
|
}).$mount('#favorites_tab')
|
||||||
|
|
||||||
|
export default FavoritesTab
|
@ -3,6 +3,7 @@ import TracklistTab from './components/tracklist-tab.js'
|
|||||||
import LinkAnalyzerTab from './components/link-analyzer-tab.js'
|
import LinkAnalyzerTab from './components/link-analyzer-tab.js'
|
||||||
import HomeTab from './components/home-tab.js'
|
import HomeTab from './components/home-tab.js'
|
||||||
import ChartsTab from './components/charts-tab.js'
|
import ChartsTab from './components/charts-tab.js'
|
||||||
|
import FavoritesTab from './components/favorites-tab.js'
|
||||||
import { socket } from './socket.js'
|
import { socket } from './socket.js'
|
||||||
import SettingsTab from './components/settings-tab.js'
|
import SettingsTab from './components/settings-tab.js'
|
||||||
import MainSearch from './components/main-search.js'
|
import MainSearch from './components/main-search.js'
|
||||||
@ -53,7 +54,8 @@ function analyzeLink(link) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function linkListeners() {
|
function linkListeners() {
|
||||||
document.getElementById('search_tab').addEventListener('click', handleTabClick)
|
document.getElementById('search_tab').addEventListener('click', handleSearchTabClick)
|
||||||
|
document.getElementById('favorites_tab').addEventListener('click', handleFavoritesTabClick)
|
||||||
document.getElementById('sidebar').addEventListener('click', handleSidebarClick)
|
document.getElementById('sidebar').addEventListener('click', handleSidebarClick)
|
||||||
|
|
||||||
const backButtons = Array.from(document.getElementsByClassName('back-button'))
|
const backButtons = Array.from(document.getElementsByClassName('back-button'))
|
||||||
@ -106,7 +108,7 @@ function handleSidebarClick(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTabClick(event) {
|
function handleSearchTabClick(event) {
|
||||||
let targetID = event.target.id
|
let targetID = event.target.id
|
||||||
|
|
||||||
switch (targetID) {
|
switch (targetID) {
|
||||||
@ -131,6 +133,28 @@ function handleTabClick(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFavoritesTabClick(event) {
|
||||||
|
let targetID = event.target.id
|
||||||
|
|
||||||
|
switch (targetID) {
|
||||||
|
case 'favorites_playlist_tab':
|
||||||
|
changeTab(event.target, 'favorites', 'playlist_favorites')
|
||||||
|
break
|
||||||
|
case 'favorites_album_tab':
|
||||||
|
changeTab(event.target, 'favorites', 'album_favorites')
|
||||||
|
break
|
||||||
|
case 'favorites_artist_tab':
|
||||||
|
changeTab(event.target, 'favorites', 'artist_favorites')
|
||||||
|
break
|
||||||
|
case 'favorites_track_tab':
|
||||||
|
changeTab(event.target, 'favorites', 'track_favorites')
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function changeTab(sidebarEl, section, tabName) {
|
function changeTab(sidebarEl, section, tabName) {
|
||||||
windows_stack = []
|
windows_stack = []
|
||||||
currentStack = {}
|
currentStack = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user