added artist and tracklist tab routing
This commit is contained in:
parent
9346f89d48
commit
20460ef9ce
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@ window.vol = {
|
|||||||
|
|
||||||
import App from '@components/App.vue'
|
import App from '@components/App.vue'
|
||||||
import i18n from '@/plugins/i18n'
|
import i18n from '@/plugins/i18n'
|
||||||
// import router from '@/plugins/router'
|
import router from '@/plugins/router'
|
||||||
|
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
import { socket } from '@/utils/socket'
|
import { socket } from '@/utils/socket'
|
||||||
@ -23,7 +23,7 @@ function startApp() {
|
|||||||
|
|
||||||
function mountApp() {
|
function mountApp() {
|
||||||
new Vue({
|
new Vue({
|
||||||
// router,
|
router,
|
||||||
i18n,
|
i18n,
|
||||||
render: h => h(App)
|
render: h => h(App)
|
||||||
}).$mount('#app')
|
}).$mount('#app')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="artist_tab" class="main_tabcontent fixed_footer image_header">
|
<div id="artist_tab" class="main_tabcontent fixed_footer image_header" ref="root">
|
||||||
<header
|
<header
|
||||||
class="inline-flex"
|
class="inline-flex"
|
||||||
:style="{
|
:style="{
|
||||||
@ -64,7 +64,7 @@
|
|||||||
explicit
|
explicit
|
||||||
</i>
|
</i>
|
||||||
{{ release.title }}
|
{{ release.title }}
|
||||||
<i v-if="checkNewRelease(release.release_date)" class="material-icons" style="color:#FF7300;">
|
<i v-if="checkNewRelease(release.release_date)" class="material-icons" style="color: #ff7300;">
|
||||||
fiber_new
|
fiber_new
|
||||||
</i>
|
</i>
|
||||||
</td>
|
</td>
|
||||||
@ -84,7 +84,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<button class="back-button">{{ $t('globals.back') }}</button>
|
<button class="back-button" @click="backTab">{{ $t('globals.back') }}</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
import { isEmpty, orderBy } from 'lodash-es'
|
import { isEmpty, orderBy } from 'lodash-es'
|
||||||
import { socket } from '@/utils/socket'
|
import { socket } from '@/utils/socket'
|
||||||
import Downloads from '@/utils/downloads'
|
import Downloads from '@/utils/downloads'
|
||||||
import { showView } from '@js/tabs'
|
import { showView, backTab } from '@js/tabs'
|
||||||
import EventBus from '@/utils/EventBus'
|
import EventBus from '@/utils/EventBus'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -112,6 +112,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
backTab,
|
||||||
albumView: showView.bind(null, 'album'),
|
albumView: showView.bind(null, 'album'),
|
||||||
reset() {
|
reset() {
|
||||||
this.title = 'Loading...'
|
this.title = 'Loading...'
|
||||||
@ -157,6 +158,8 @@ export default {
|
|||||||
return g1.getTime() <= g2.getTime()
|
return g1.getTime() <= g2.getTime()
|
||||||
},
|
},
|
||||||
showArtist(data) {
|
showArtist(data) {
|
||||||
|
this.reset()
|
||||||
|
|
||||||
const { name, picture_xl, id, releases } = data
|
const { name, picture_xl, id, releases } = data
|
||||||
|
|
||||||
this.title = name
|
this.title = name
|
||||||
@ -167,7 +170,7 @@ export default {
|
|||||||
this.sortKey = 'release_date'
|
this.sortKey = 'release_date'
|
||||||
this.sortOrder = 'desc'
|
this.sortOrder = 'desc'
|
||||||
this.head = [
|
this.head = [
|
||||||
{ title: this.$tc('globals.listTabs.title',1), sortKey: 'title' },
|
{ title: this.$tc('globals.listTabs.title', 1), sortKey: 'title' },
|
||||||
{ title: this.$t('globals.listTabs.releaseDate'), sortKey: 'release_date' },
|
{ title: this.$t('globals.listTabs.releaseDate'), sortKey: 'release_date' },
|
||||||
{ title: '', width: '32px' }
|
{ title: '', width: '32px' }
|
||||||
]
|
]
|
||||||
@ -185,11 +188,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$refs.root.style.display = 'block'
|
||||||
|
console.log('artist mounted')
|
||||||
|
|
||||||
socket.on('show_artist', this.showArtist)
|
socket.on('show_artist', this.showArtist)
|
||||||
|
|
||||||
EventBus.$on('artistTab:reset', this.reset)
|
|
||||||
EventBus.$on('artistTab:updateSelected', this.updateSelected)
|
EventBus.$on('artistTab:updateSelected', this.updateSelected)
|
||||||
EventBus.$on('artistTab:changeTab', this.changeTab)
|
EventBus.$on('artistTab:changeTab', this.changeTab)
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
console.log('artist bef dest')
|
||||||
|
this.$refs.root.style.display = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,28 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<section id="content" @scroll="handleContentScroll" ref="content">
|
<section id="content" @scroll="handleContentScroll" ref="content">
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<ArtistTab />
|
<router-view></router-view>
|
||||||
|
|
||||||
|
<!-- <ArtistTab /> -->
|
||||||
|
<!-- <TracklistTab /> -->
|
||||||
|
<!-- <TheHomeTab /> -->
|
||||||
<TheChartsTab />
|
<TheChartsTab />
|
||||||
<TheFavoritesTab />
|
<TheFavoritesTab />
|
||||||
<TheErrorsTab />
|
<TheErrorsTab />
|
||||||
<TheHomeTab />
|
|
||||||
<TheLinkAnalyzerTab />
|
<TheLinkAnalyzerTab />
|
||||||
<TheAboutTab />
|
<TheAboutTab />
|
||||||
<TheSettingsTab />
|
<TheSettingsTab />
|
||||||
<TheMainSearch :scrolled-search-type="newScrolled" />
|
<TheMainSearch :scrolled-search-type="newScrolled" />
|
||||||
<TracklistTab />
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ArtistTab from '@components/ArtistTab.vue'
|
// import ArtistTab from '@components/ArtistTab.vue'
|
||||||
import TracklistTab from '@components/TracklistTab.vue'
|
// import TracklistTab from '@components/TracklistTab.vue'
|
||||||
|
|
||||||
import TheChartsTab from '@components/TheChartsTab.vue'
|
import TheChartsTab from '@components/TheChartsTab.vue'
|
||||||
import TheFavoritesTab from '@components/TheFavoritesTab.vue'
|
import TheFavoritesTab from '@components/TheFavoritesTab.vue'
|
||||||
import TheErrorsTab from '@components/TheErrorsTab.vue'
|
import TheErrorsTab from '@components/TheErrorsTab.vue'
|
||||||
import TheHomeTab from '@components/TheHomeTab.vue'
|
// import TheHomeTab from '@components/TheHomeTab.vue'
|
||||||
import TheLinkAnalyzerTab from '@components/TheLinkAnalyzerTab.vue'
|
import TheLinkAnalyzerTab from '@components/TheLinkAnalyzerTab.vue'
|
||||||
import TheAboutTab from '@components/TheAboutTab.vue'
|
import TheAboutTab from '@components/TheAboutTab.vue'
|
||||||
import TheSettingsTab from '@components/TheSettingsTab.vue'
|
import TheSettingsTab from '@components/TheSettingsTab.vue'
|
||||||
@ -33,22 +35,22 @@ import EventBus from '@/utils/EventBus.js'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ArtistTab,
|
// ArtistTab,
|
||||||
|
// TracklistTab
|
||||||
TheChartsTab,
|
TheChartsTab,
|
||||||
TheFavoritesTab,
|
TheFavoritesTab,
|
||||||
TheErrorsTab,
|
TheErrorsTab,
|
||||||
TheHomeTab,
|
// TheHomeTab,
|
||||||
TheLinkAnalyzerTab,
|
TheLinkAnalyzerTab,
|
||||||
TheAboutTab,
|
TheAboutTab,
|
||||||
TheSettingsTab,
|
TheSettingsTab,
|
||||||
TheMainSearch,
|
TheMainSearch
|
||||||
TracklistTab
|
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
newScrolled: null
|
newScrolled: null
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
handleContentScroll: debounce(async function() {
|
handleContentScroll: debounce(async function () {
|
||||||
if (this.$refs.content.scrollTop + this.$refs.content.clientHeight < this.$refs.content.scrollHeight) return
|
if (this.$refs.content.scrollTop + this.$refs.content.clientHeight < this.$refs.content.scrollHeight) return
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="home_tab" class="main_tabcontent">
|
<div id="home_tab" class="main_tabcontent" ref="root">
|
||||||
<h2 class="page_heading">{{ $t('globals.welcome') }}</h2>
|
<h2 class="page_heading">{{ $t('globals.welcome') }}</h2>
|
||||||
<section id="home_not_logged_in" class="home_section" ref="notLogged">
|
<section id="home_not_logged_in" class="home_section" ref="notLogged">
|
||||||
<p id="home_not_logged_text">{{ $t('home.needTologin') }}</p>
|
<p id="home_not_logged_text">{{ $t('home.needTologin') }}</p>
|
||||||
@ -103,11 +103,19 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
console.log('home mounted')
|
||||||
|
this.$refs.root.style.display = 'block'
|
||||||
|
|
||||||
if (localStorage.getItem('arl')) {
|
if (localStorage.getItem('arl')) {
|
||||||
this.$refs.notLogged.classList.add('hide')
|
this.$refs.notLogged.classList.add('hide')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ! Need to init home everytime, atm this is called only on connect
|
||||||
socket.on('init_home', this.initHome)
|
socket.on('init_home', this.initHome)
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
console.log('home bef dest')
|
||||||
|
this.$refs.root.style.display = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<main id="main_content">
|
<main id="main_content">
|
||||||
<!-- <router-link to="/tracklist/132">Go to Foo</router-link> -->
|
|
||||||
<!-- <router-view></router-view> -->
|
|
||||||
<TheMiddleSection />
|
<TheMiddleSection />
|
||||||
<TheDownloadTab />
|
<TheDownloadTab />
|
||||||
</main>
|
</main>
|
||||||
@ -15,9 +13,6 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
TheMiddleSection,
|
TheMiddleSection,
|
||||||
TheDownloadTab
|
TheDownloadTab
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
console.log(this.$route)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -611,6 +611,56 @@ export default {
|
|||||||
accountNum: 0,
|
accountNum: 0,
|
||||||
accounts: []
|
accounts: []
|
||||||
}),
|
}),
|
||||||
|
mounted() {
|
||||||
|
this.locales = this.$i18n.availableLocales
|
||||||
|
|
||||||
|
EventBus.$on('settingsTab:revertSettings', this.revertSettings)
|
||||||
|
EventBus.$on('settingsTab:revertCredentials', this.revertCredentials)
|
||||||
|
|
||||||
|
this.$refs.loggedInInfo.classList.add('hide')
|
||||||
|
|
||||||
|
let storedLocale = localStorage.getItem('locale')
|
||||||
|
|
||||||
|
if (storedLocale) {
|
||||||
|
this.$i18n.locale = storedLocale
|
||||||
|
this.currentLocale = storedLocale
|
||||||
|
}
|
||||||
|
|
||||||
|
let storedArl = localStorage.getItem('arl')
|
||||||
|
|
||||||
|
if (storedArl) {
|
||||||
|
this.$refs.loginInput.value = storedArl.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
let storedAccountNum = localStorage.getItem('accountNum')
|
||||||
|
|
||||||
|
if (storedAccountNum) {
|
||||||
|
this.accountNum = storedAccountNum
|
||||||
|
}
|
||||||
|
|
||||||
|
let spotifyUser = localStorage.getItem('spotifyUser')
|
||||||
|
|
||||||
|
if (spotifyUser) {
|
||||||
|
this.lastUser = spotifyUser
|
||||||
|
this.spotifyUser = spotifyUser
|
||||||
|
socket.emit('update_userSpotifyPlaylists', spotifyUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads')
|
||||||
|
|
||||||
|
let volume = parseInt(localStorage.getItem('previewVolume'))
|
||||||
|
if (isNaN(volume)) {
|
||||||
|
volume = 80
|
||||||
|
localStorage.setItem('previewVolume', volume)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.vol.preview_max_volume = volume
|
||||||
|
|
||||||
|
socket.on('init_settings', this.initSettings)
|
||||||
|
socket.on('updateSettings', this.updateSettings)
|
||||||
|
socket.on('accountChanged', this.accountChanged)
|
||||||
|
socket.on('familyAccounts', this.initAccounts)
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
changeSlimDownloads: {
|
changeSlimDownloads: {
|
||||||
get() {
|
get() {
|
||||||
@ -705,55 +755,6 @@ export default {
|
|||||||
resetSettings() {
|
resetSettings() {
|
||||||
this.settings = { ...this.defaultSettings }
|
this.settings = { ...this.defaultSettings }
|
||||||
}
|
}
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.locales = this.$i18n.availableLocales
|
|
||||||
|
|
||||||
EventBus.$on('settingsTab:revertSettings', this.revertSettings)
|
|
||||||
EventBus.$on('settingsTab:revertCredentials', this.revertCredentials)
|
|
||||||
|
|
||||||
this.$refs.loggedInInfo.classList.add('hide')
|
|
||||||
|
|
||||||
let storedLocale = localStorage.getItem('locale')
|
|
||||||
|
|
||||||
if (storedLocale) {
|
|
||||||
this.$i18n.locale = storedLocale
|
|
||||||
this.currentLocale = storedLocale
|
|
||||||
}
|
|
||||||
|
|
||||||
let storedArl = localStorage.getItem('arl')
|
|
||||||
|
|
||||||
if (storedArl) {
|
|
||||||
this.$refs.loginInput.value = storedArl.trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
let storedAccountNum = localStorage.getItem('accountNum')
|
|
||||||
|
|
||||||
if (storedAccountNum) {
|
|
||||||
this.accountNum = storedAccountNum
|
|
||||||
}
|
|
||||||
|
|
||||||
let spotifyUser = localStorage.getItem('spotifyUser')
|
|
||||||
|
|
||||||
if (spotifyUser) {
|
|
||||||
this.lastUser = spotifyUser
|
|
||||||
this.spotifyUser = spotifyUser
|
|
||||||
socket.emit('update_userSpotifyPlaylists', spotifyUser)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.changeSlimDownloads = 'true' === localStorage.getItem('slimDownloads')
|
|
||||||
|
|
||||||
let volume = parseInt(localStorage.getItem('previewVolume'))
|
|
||||||
if (isNaN(volume)) {
|
|
||||||
volume = 80
|
|
||||||
localStorage.setItem('previewVolume', volume)
|
|
||||||
}
|
|
||||||
window.vol.preview_max_volume = volume
|
|
||||||
|
|
||||||
socket.on('init_settings', this.initSettings)
|
|
||||||
socket.on('updateSettings', this.updateSettings)
|
|
||||||
socket.on('accountChanged', this.accountChanged)
|
|
||||||
socket.on('familyAccounts', this.initAccounts)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -88,7 +88,7 @@ export default {
|
|||||||
},
|
},
|
||||||
stopStackedTabsPreview() {
|
stopStackedTabsPreview() {
|
||||||
if (
|
if (
|
||||||
$('.preview_playlist_controls').filter(function() {
|
$('.preview_playlist_controls').filter(function () {
|
||||||
return $(this).attr('playing')
|
return $(this).attr('playing')
|
||||||
}).length > 0
|
}).length > 0
|
||||||
) {
|
) {
|
||||||
@ -104,15 +104,7 @@ export default {
|
|||||||
previewMouseLeave(event) {
|
previewMouseLeave(event) {
|
||||||
const { currentTarget: obj } = event
|
const { currentTarget: obj } = event
|
||||||
|
|
||||||
if (
|
if (($(obj).parent().attr('playing') && this.previewStopped) || !$(obj).parent().attr('playing')) {
|
||||||
($(obj)
|
|
||||||
.parent()
|
|
||||||
.attr('playing') &&
|
|
||||||
this.previewStopped) ||
|
|
||||||
!$(obj)
|
|
||||||
.parent()
|
|
||||||
.attr('playing')
|
|
||||||
) {
|
|
||||||
$(obj).css({ opacity: 0 }, 200)
|
$(obj).css({ opacity: 0 }, 200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="tracklist_tab" class="main_tabcontent fixed_footer image_header">
|
<div id="tracklist_tab" class="main_tabcontent fixed_footer image_header" ref="root">
|
||||||
<header
|
<header
|
||||||
:style="{
|
:style="{
|
||||||
'background-image':
|
'background-image':
|
||||||
@ -144,7 +144,7 @@
|
|||||||
>
|
>
|
||||||
{{ $t('tracklist.downloadSelection') }}<i class="material-icons">file_download</i>
|
{{ $t('tracklist.downloadSelection') }}<i class="material-icons">file_download</i>
|
||||||
</button>
|
</button>
|
||||||
<button class="back-button">{{ $t('globals.back') }}</button>
|
<button class="back-button" @click="backTab">{{ $t('globals.back') }}</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -152,7 +152,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { isEmpty } from 'lodash-es'
|
import { isEmpty } from 'lodash-es'
|
||||||
import { socket } from '@/utils/socket'
|
import { socket } from '@/utils/socket'
|
||||||
import { showView } from '@js/tabs.js'
|
import { showView, backTab } from '@js/tabs.js'
|
||||||
import Downloads from '@/utils/downloads'
|
import Downloads from '@/utils/downloads'
|
||||||
import Utils from '@/utils/utils'
|
import Utils from '@/utils/utils'
|
||||||
import EventBus from '@/utils/EventBus'
|
import EventBus from '@/utils/EventBus'
|
||||||
@ -171,12 +171,14 @@ export default {
|
|||||||
body: []
|
body: []
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
|
backTab,
|
||||||
artistView: showView.bind(null, 'artist'),
|
artistView: showView.bind(null, 'artist'),
|
||||||
albumView: showView.bind(null, 'album'),
|
albumView: showView.bind(null, 'album'),
|
||||||
playPausePreview(e) {
|
playPausePreview(e) {
|
||||||
EventBus.$emit('trackPreview:playPausePreview', e)
|
EventBus.$emit('trackPreview:playPausePreview', e)
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
|
console.log('resetto')
|
||||||
this.title = 'Loading...'
|
this.title = 'Loading...'
|
||||||
this.image = ''
|
this.image = ''
|
||||||
this.metadata = ''
|
this.metadata = ''
|
||||||
@ -211,6 +213,8 @@ export default {
|
|||||||
},
|
},
|
||||||
convertDuration: Utils.convertDuration,
|
convertDuration: Utils.convertDuration,
|
||||||
showAlbum(data) {
|
showAlbum(data) {
|
||||||
|
this.reset()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
id: albumID,
|
id: albumID,
|
||||||
title: albumTitle,
|
title: albumTitle,
|
||||||
@ -239,6 +243,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showPlaylist(data) {
|
showPlaylist(data) {
|
||||||
|
this.reset()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
id: playlistID,
|
id: playlistID,
|
||||||
title: playlistTitle,
|
title: playlistTitle,
|
||||||
@ -263,6 +269,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showSpotifyPlaylist(data) {
|
showSpotifyPlaylist(data) {
|
||||||
|
this.reset()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
uri: playlistURI,
|
uri: playlistURI,
|
||||||
name: playlistName,
|
name: playlistName,
|
||||||
@ -294,12 +302,16 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log('tracklist mounted')
|
console.log('tracklist mounted')
|
||||||
EventBus.$on('tracklistTab:reset', this.reset)
|
this.$refs.root.style.display = 'block'
|
||||||
EventBus.$on('tracklistTab:selectRow', this.selectRow)
|
EventBus.$on('tracklistTab:selectRow', this.selectRow)
|
||||||
|
|
||||||
socket.on('show_album', this.showAlbum)
|
socket.on('show_album', this.showAlbum)
|
||||||
socket.on('show_playlist', this.showPlaylist)
|
socket.on('show_playlist', this.showPlaylist)
|
||||||
socket.on('show_spotifyplaylist', this.showSpotifyPlaylist)
|
socket.on('show_spotifyplaylist', this.showSpotifyPlaylist)
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
console.log('tracklist bef dest')
|
||||||
|
this.$refs.root.style.display = 'none'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
107
src/js/tabs.js
107
src/js/tabs.js
@ -1,5 +1,6 @@
|
|||||||
import { socket } from '@/utils/socket'
|
import { socket } from '@/utils/socket'
|
||||||
import EventBus from '@/utils/EventBus'
|
import EventBus from '@/utils/EventBus'
|
||||||
|
import router from '@/plugins/router'
|
||||||
|
|
||||||
/* ===== Globals ====== */
|
/* ===== Globals ====== */
|
||||||
window.search_selected = ''
|
window.search_selected = ''
|
||||||
@ -7,35 +8,6 @@ window.main_selected = ''
|
|||||||
window.windows_stack = []
|
window.windows_stack = []
|
||||||
window.currentStack = {}
|
window.currentStack = {}
|
||||||
|
|
||||||
// Exporting this function out of the default export
|
|
||||||
// because it's used in components that are needed
|
|
||||||
// in this file too
|
|
||||||
export function showView(viewType, event) {
|
|
||||||
// console.error('SHOW VIEW')
|
|
||||||
const {
|
|
||||||
currentTarget: {
|
|
||||||
dataset: { id }
|
|
||||||
}
|
|
||||||
} = event
|
|
||||||
|
|
||||||
switch (viewType) {
|
|
||||||
case 'artist':
|
|
||||||
EventBus.$emit('artistTab:reset')
|
|
||||||
break
|
|
||||||
case 'album':
|
|
||||||
case 'playlist':
|
|
||||||
case 'spotifyplaylist':
|
|
||||||
EventBus.$emit('tracklistTab:reset')
|
|
||||||
break
|
|
||||||
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.emit('getTracklist', { type: viewType, id })
|
|
||||||
showTab(viewType, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the tab to the wanted one
|
* Changes the tab to the wanted one
|
||||||
* Need to understand the difference from showTab
|
* Need to understand the difference from showTab
|
||||||
@ -87,14 +59,41 @@ export function changeTab(sidebarEl, section, tabName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function showView(viewType, event) {
|
||||||
|
const {
|
||||||
|
currentTarget: {
|
||||||
|
dataset: { id }
|
||||||
|
}
|
||||||
|
} = event
|
||||||
|
const isArtist = viewType === 'artist'
|
||||||
|
const name = isArtist ? 'Artist' : 'Tracklist'
|
||||||
|
const params = isArtist ? { id } : { type: viewType, id }
|
||||||
|
|
||||||
|
router.push({
|
||||||
|
name,
|
||||||
|
params
|
||||||
|
})
|
||||||
|
|
||||||
|
// showTab(viewType, id)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the passed tab, keeping track of the one that the user is coming from.
|
* Shows the passed tab, keeping track of the one that the user is coming from.
|
||||||
*
|
*
|
||||||
* Needs EventBus
|
* Needs EventBus
|
||||||
*/
|
*/
|
||||||
function showTab(type, id, back = false) {
|
function showTab(type, id, back = false) {
|
||||||
|
return
|
||||||
|
updateStack(type, id, back)
|
||||||
|
window.tab = type === 'artist' ? 'artist_tab' : 'tracklist_tab'
|
||||||
|
displayTabs()
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateStack(type, id, back) {
|
||||||
if (window.windows_stack.length === 0) {
|
if (window.windows_stack.length === 0) {
|
||||||
window.windows_stack.push({ tab: window.main_selected })
|
window.windows_stack.push({
|
||||||
|
tab: window.main_selected
|
||||||
|
})
|
||||||
} else if (!back) {
|
} else if (!back) {
|
||||||
if (window.currentStack.type === 'artist') {
|
if (window.currentStack.type === 'artist') {
|
||||||
EventBus.$emit('artistTab:updateSelected')
|
EventBus.$emit('artistTab:updateSelected')
|
||||||
@ -103,18 +102,21 @@ function showTab(type, id, back = false) {
|
|||||||
window.windows_stack.push(window.currentStack)
|
window.windows_stack.push(window.currentStack)
|
||||||
}
|
}
|
||||||
|
|
||||||
window.tab = type === 'artist' ? 'artist_tab' : 'tracklist_tab'
|
|
||||||
|
|
||||||
window.currentStack = { type, id }
|
window.currentStack = { type, id }
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayTabs() {
|
||||||
let tabcontent = document.getElementsByClassName('main_tabcontent')
|
let tabcontent = document.getElementsByClassName('main_tabcontent')
|
||||||
|
|
||||||
for (let i = 0; i < tabcontent.length; i++) {
|
for (let i = 0; i < tabcontent.length; i++) {
|
||||||
tabcontent[i].style.display = 'none'
|
tabcontent[i].style.display = 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById(window.tab).style.display = 'block'
|
let newTab = document.getElementById(window.tab)
|
||||||
|
|
||||||
EventBus.$emit('trackPreview:stopStackedTabsPreview')
|
if (newTab) {
|
||||||
|
newTab.style.display = 'block'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,42 +124,31 @@ function showTab(type, id, back = false) {
|
|||||||
*
|
*
|
||||||
* Needs EventBus and socket
|
* Needs EventBus and socket
|
||||||
*/
|
*/
|
||||||
function backTab() {
|
export function backTab() {
|
||||||
|
router.back()
|
||||||
|
|
||||||
|
// ! Need to implement the memory of the opened artist tab
|
||||||
|
return
|
||||||
|
|
||||||
if (window.windows_stack.length == 1) {
|
if (window.windows_stack.length == 1) {
|
||||||
document.getElementById(`main_${window.main_selected}link`).click()
|
console.log(window.main_selected)
|
||||||
|
if (document.getElementById(`main_${window.main_selected}link`)) {
|
||||||
|
// document.getElementById(`main_${window.main_selected}link`).click()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Retrieving tab type and tab id
|
// Retrieving tab type and tab id
|
||||||
let data = window.windows_stack.pop()
|
let data = window.windows_stack.pop()
|
||||||
let { type, id, selected } = data
|
let { type, id, selected } = data
|
||||||
|
|
||||||
if (type === 'artist') {
|
if (type === 'artist' && selected) {
|
||||||
EventBus.$emit('artistTab:reset')
|
|
||||||
|
|
||||||
if (selected) {
|
|
||||||
EventBus.$emit('artistTab:changeTab', selected)
|
EventBus.$emit('artistTab:changeTab', selected)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
EventBus.$emit('tracklistTab:reset')
|
// showTab(type, id, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('getTracklist', { type, id })
|
|
||||||
showTab(type, id, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
EventBus.$emit('trackPreview:stopStackedTabsPreview')
|
|
||||||
}
|
|
||||||
|
|
||||||
function _linkListeners() {
|
|
||||||
const backButtons = Array.prototype.slice.call(document.getElementsByClassName('back-button'))
|
|
||||||
|
|
||||||
backButtons.forEach(button => {
|
|
||||||
button.addEventListener('click', backTab)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function init() {
|
export function init() {
|
||||||
// Open default tab
|
// Open default tab
|
||||||
changeTab(document.getElementById('main_home_tablink'), 'main', 'home_tab')
|
changeTab(document.getElementById('main_home_tablink'), 'main', 'home_tab')
|
||||||
|
|
||||||
_linkListeners()
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,30 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router'
|
||||||
|
import { socket } from '@/utils/socket'
|
||||||
|
import EventBus from '@/utils/EventBus'
|
||||||
|
|
||||||
|
import TheHomeTab from '@components/TheHomeTab.vue'
|
||||||
import TracklistTab from '@components/TracklistTab.vue'
|
import TracklistTab from '@components/TracklistTab.vue'
|
||||||
|
import ArtistTab from '@components/ArtistTab.vue'
|
||||||
console.log(TracklistTab)
|
|
||||||
|
|
||||||
Vue.use(VueRouter)
|
Vue.use(VueRouter)
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: '/tracklist/:id',
|
path: '/',
|
||||||
|
component: TheHomeTab
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/tracklist/:type/:id',
|
||||||
|
name: 'Tracklist',
|
||||||
component: TracklistTab
|
component: TracklistTab
|
||||||
},
|
},
|
||||||
// 404
|
{
|
||||||
|
path: '/artist/:id',
|
||||||
|
name: 'Artist',
|
||||||
|
component: ArtistTab
|
||||||
|
},
|
||||||
|
// 404 client side
|
||||||
{
|
{
|
||||||
path: '*',
|
path: '*',
|
||||||
component: TracklistTab
|
component: TracklistTab
|
||||||
@ -29,7 +41,28 @@ const router = new VueRouter({
|
|||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log({ from, to })
|
console.log('before route change', to)
|
||||||
|
|
||||||
|
switch (to.name) {
|
||||||
|
case 'Artist':
|
||||||
|
socket.emit('getTracklist', {
|
||||||
|
type: 'artist',
|
||||||
|
id: to.params.id
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'Tracklist':
|
||||||
|
socket.emit('getTracklist', {
|
||||||
|
type: to.params.type,
|
||||||
|
id: to.params.id
|
||||||
|
})
|
||||||
|
break
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
EventBus.$emit('trackPreview:stopStackedTabsPreview')
|
||||||
|
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user