2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<!-- Search field + recent searches -->
|
2018-12-08 02:48:15 -05:00
|
|
|
<section class="section fd-remove-padding-bottom">
|
2018-08-11 01:47:10 -04:00
|
|
|
<div class="container">
|
|
|
|
<div class="columns is-centered">
|
|
|
|
<div class="column is-four-fifths">
|
2022-02-19 00:39:14 -05:00
|
|
|
<form @submit.prevent="new_search">
|
2018-08-11 01:47:10 -04:00
|
|
|
<div class="field">
|
|
|
|
<p class="control is-expanded has-icons-left">
|
2022-05-20 07:44:22 -04:00
|
|
|
<input ref="search_field" v-model="search_query" class="input is-rounded is-shadowless" type="text" placeholder="Search" autocomplete="off" />
|
|
|
|
<mdicon class="icon is-left" name="magnify" size="16" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</form>
|
2022-02-19 00:39:14 -05:00
|
|
|
<div class="tags" style="margin-top: 16px">
|
2022-05-20 07:44:22 -04:00
|
|
|
<a v-for="recent_search in recent_searches" :key="recent_search" class="tag" @click="open_recent_search(recent_search)" v-text="recent_search" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2022-02-19 00:39:14 -05:00
|
|
|
<tabs-search :query="search_query" />
|
2018-08-11 01:47:10 -04:00
|
|
|
<!-- Tracks -->
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-with-heading v-if="show_tracks && tracks.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p class="title is-4" v-text="$t('page.spotify.search.tracks')" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-list-item-track v-for="track in tracks.items" :key="track.id" :track="track" :album="track.album" :position="0" :context_uri="track.uri">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #actions>
|
2022-04-02 13:05:41 -04:00
|
|
|
<a @click.prevent.stop="open_track_dialog(track)">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon has-text-dark" name="dots-vertical" size="16" />
|
2018-12-17 05:52:09 -05:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</spotify-list-item-track>
|
2022-05-20 07:44:22 -04:00
|
|
|
<VueEternalLoading v-if="query.type === 'track'" :load="search_tracks_next">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #no-more> . </template>
|
|
|
|
</VueEternalLoading>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-modal-dialog-track :show="show_track_details_modal" :track="selected_track" :album="selected_track.album" @close="show_track_details_modal = false" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #footer>
|
2018-08-11 01:47:10 -04:00
|
|
|
<nav v-if="show_all_tracks_button" class="level">
|
|
|
|
<p class="level-item">
|
2022-05-20 07:44:22 -04:00
|
|
|
<a class="button is-light is-small is-rounded" @click="open_search_tracks" v-text="$t('page.spotify.search.show-all-tracks', { count: tracks.total.toLocaleString() })" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</p>
|
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-text v-if="show_tracks && !tracks.total" class="mt-6">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p><i v-text="$t('page.spotify.search.no-tracks')" /></p>
|
2020-10-17 05:42:50 -04:00
|
|
|
</template>
|
|
|
|
</content-text>
|
2018-08-11 01:47:10 -04:00
|
|
|
<!-- Artists -->
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-with-heading v-if="show_artists && artists.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p class="title is-4" v-text="$t('page.spotify.search.artists')" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-list-item-artist v-for="artist in artists.items" :key="artist.id" :artist="artist">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #actions>
|
2022-04-02 13:05:41 -04:00
|
|
|
<a @click.prevent.stop="open_artist_dialog(artist)">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon has-text-dark" name="dots-vertical" size="16" />
|
2018-12-17 05:52:09 -05:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</spotify-list-item-artist>
|
2022-05-20 07:44:22 -04:00
|
|
|
<VueEternalLoading v-if="query.type === 'artist'" :load="search_artists_next">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #no-more> . </template>
|
|
|
|
</VueEternalLoading>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-modal-dialog-artist :show="show_artist_details_modal" :artist="selected_artist" @close="show_artist_details_modal = false" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #footer>
|
2018-08-11 01:47:10 -04:00
|
|
|
<nav v-if="show_all_artists_button" class="level">
|
|
|
|
<p class="level-item">
|
2022-05-20 07:44:22 -04:00
|
|
|
<a class="button is-light is-small is-rounded" @click="open_search_artists" v-text="$t('page.spotify.search.show-all-artists', { count: artists.total.toLocaleString() })" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</p>
|
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-text v-if="show_artists && !artists.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p><i v-text="$t('page.spotify.search.no-artists')" /></p>
|
2020-10-17 05:42:50 -04:00
|
|
|
</template>
|
|
|
|
</content-text>
|
2018-08-11 01:47:10 -04:00
|
|
|
<!-- Albums -->
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-with-heading v-if="show_albums && albums.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p class="title is-4" v-text="$t('page.spotify.search.albums')" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-list-item-album v-for="album in albums.items" :key="album.id" :album="album" @click="open_album(album)">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template v-if="is_visible_artwork" #artwork>
|
2020-08-23 13:26:54 -04:00
|
|
|
<p class="image is-64x64 fd-has-shadow fd-has-action">
|
2022-05-20 07:44:22 -04:00
|
|
|
<cover-artwork :artwork_url="artwork_url(album)" :artist="album.artist" :album="album.name" :maxwidth="64" :maxheight="64" />
|
2020-08-23 13:26:54 -04:00
|
|
|
</p>
|
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #actions>
|
2022-04-02 13:05:41 -04:00
|
|
|
<a @click.prevent.stop="open_album_dialog(album)">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon has-text-dark" name="dots-vertical" size="16" />
|
2018-12-17 05:52:09 -05:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</spotify-list-item-album>
|
2022-05-20 07:44:22 -04:00
|
|
|
<VueEternalLoading v-if="query.type === 'album'" :load="search_albums_next">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #no-more> . </template>
|
|
|
|
</VueEternalLoading>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-modal-dialog-album :show="show_album_details_modal" :album="selected_album" @close="show_album_details_modal = false" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #footer>
|
2018-08-11 01:47:10 -04:00
|
|
|
<nav v-if="show_all_albums_button" class="level">
|
|
|
|
<p class="level-item">
|
2022-05-20 07:44:22 -04:00
|
|
|
<a class="button is-light is-small is-rounded" @click="open_search_albums" v-text="$t('page.spotify.search.show-all-albums', { count: albums.total.toLocaleString() })" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</p>
|
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-text v-if="show_albums && !albums.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p><i v-text="$t('page.spotify.search.no-albums')" /></p>
|
2020-10-17 05:42:50 -04:00
|
|
|
</template>
|
|
|
|
</content-text>
|
2018-08-11 01:47:10 -04:00
|
|
|
<!-- Playlists -->
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-with-heading v-if="show_playlists && playlists.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p class="title is-4" v-text="$t('page.spotify.search.playlists')" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-list-item-playlist v-for="playlist in playlists.items" :key="playlist.id" :playlist="playlist">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #actions>
|
2022-04-02 13:05:41 -04:00
|
|
|
<a @click.prevent.stop="open_playlist_dialog(playlist)">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon has-text-dark" name="dots-vertical" size="16" />
|
2018-12-17 05:52:09 -05:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</spotify-list-item-playlist>
|
2022-05-20 07:44:22 -04:00
|
|
|
<VueEternalLoading v-if="query.type === 'playlist'" :load="search_playlists_next">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #no-more> . </template>
|
|
|
|
</VueEternalLoading>
|
2022-05-20 07:44:22 -04:00
|
|
|
<spotify-modal-dialog-playlist :show="show_playlist_details_modal" :playlist="selected_playlist" @close="show_playlist_details_modal = false" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #footer>
|
2018-08-11 01:47:10 -04:00
|
|
|
<nav v-if="show_all_playlists_button" class="level">
|
|
|
|
<p class="level-item">
|
2022-05-20 07:44:22 -04:00
|
|
|
<a class="button is-light is-small is-rounded" @click="open_search_playlists" v-text="$t('page.spotify.search.show-all-playlists', { count: playlists.total.toLocaleString() })" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</p>
|
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
2020-10-17 05:42:50 -04:00
|
|
|
<content-text v-if="show_playlists && !playlists.total">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p><i v-text="$t('page.spotify.search.no-playlists')" /></p>
|
2020-10-17 05:42:50 -04:00
|
|
|
</template>
|
|
|
|
</content-text>
|
2018-08-11 01:47:10 -04:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 00:18:01 -05:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
|
|
|
import ContentText from '@/templates/ContentText.vue'
|
|
|
|
import TabsSearch from '@/components/TabsSearch.vue'
|
|
|
|
import SpotifyListItemTrack from '@/components/SpotifyListItemTrack.vue'
|
|
|
|
import SpotifyListItemArtist from '@/components/SpotifyListItemArtist.vue'
|
|
|
|
import SpotifyListItemAlbum from '@/components/SpotifyListItemAlbum.vue'
|
|
|
|
import SpotifyListItemPlaylist from '@/components/SpotifyListItemPlaylist.vue'
|
|
|
|
import SpotifyModalDialogTrack from '@/components/SpotifyModalDialogTrack.vue'
|
|
|
|
import SpotifyModalDialogArtist from '@/components/SpotifyModalDialogArtist.vue'
|
|
|
|
import SpotifyModalDialogAlbum from '@/components/SpotifyModalDialogAlbum.vue'
|
|
|
|
import SpotifyModalDialogPlaylist from '@/components/SpotifyModalDialogPlaylist.vue'
|
|
|
|
import CoverArtwork from '@/components/CoverArtwork.vue'
|
2018-08-11 01:47:10 -04:00
|
|
|
import SpotifyWebApi from 'spotify-web-api-js'
|
|
|
|
import webapi from '@/webapi'
|
|
|
|
import * as types from '@/store/mutation_types'
|
2022-02-19 00:18:01 -05:00
|
|
|
import { VueEternalLoading } from '@ts-pro/vue-eternal-loading'
|
|
|
|
|
|
|
|
const PAGE_SIZE = 50
|
2018-08-11 01:47:10 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SpotifyPageSearch',
|
2022-02-19 00:39:14 -05:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
|
|
|
ContentText,
|
|
|
|
TabsSearch,
|
|
|
|
SpotifyListItemTrack,
|
|
|
|
SpotifyListItemArtist,
|
|
|
|
SpotifyListItemAlbum,
|
|
|
|
SpotifyListItemPlaylist,
|
|
|
|
SpotifyModalDialogTrack,
|
|
|
|
SpotifyModalDialogArtist,
|
|
|
|
SpotifyModalDialogAlbum,
|
|
|
|
SpotifyModalDialogPlaylist,
|
|
|
|
VueEternalLoading,
|
|
|
|
CoverArtwork
|
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
data() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return {
|
|
|
|
search_query: '',
|
|
|
|
tracks: { items: [], total: 0 },
|
|
|
|
artists: { items: [], total: 0 },
|
|
|
|
albums: { items: [], total: 0 },
|
|
|
|
playlists: { items: [], total: 0 },
|
|
|
|
|
|
|
|
query: {},
|
2018-12-17 05:52:09 -05:00
|
|
|
search_param: {},
|
|
|
|
|
|
|
|
show_track_details_modal: false,
|
|
|
|
selected_track: {},
|
|
|
|
|
|
|
|
show_album_details_modal: false,
|
|
|
|
selected_album: {},
|
|
|
|
|
|
|
|
show_artist_details_modal: false,
|
|
|
|
selected_artist: {},
|
|
|
|
|
|
|
|
show_playlist_details_modal: false,
|
2020-08-30 09:53:12 -04:00
|
|
|
selected_playlist: {},
|
|
|
|
|
|
|
|
validSearchTypes: ['track', 'artist', 'album', 'playlist']
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-02-19 00:39:14 -05:00
|
|
|
recent_searches() {
|
|
|
|
return this.$store.state.recent_searches.filter(
|
|
|
|
(search) => !search.startsWith('query:')
|
|
|
|
)
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
show_tracks() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.$route.query.type && this.$route.query.type.includes('track')
|
|
|
|
},
|
2022-02-19 00:39:14 -05:00
|
|
|
show_all_tracks_button() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.tracks.total > this.tracks.items.length
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
show_artists() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.$route.query.type && this.$route.query.type.includes('artist')
|
|
|
|
},
|
2022-02-19 00:39:14 -05:00
|
|
|
show_all_artists_button() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.artists.total > this.artists.items.length
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
show_albums() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.$route.query.type && this.$route.query.type.includes('album')
|
|
|
|
},
|
2022-02-19 00:39:14 -05:00
|
|
|
show_all_albums_button() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.albums.total > this.albums.items.length
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
show_playlists() {
|
|
|
|
return (
|
|
|
|
this.$route.query.type && this.$route.query.type.includes('playlist')
|
|
|
|
)
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
2022-02-19 00:39:14 -05:00
|
|
|
show_all_playlists_button() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return this.playlists.total > this.playlists.items.length
|
2020-08-23 13:26:54 -04:00
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
is_visible_artwork() {
|
|
|
|
return this.$store.getters.settings_option(
|
|
|
|
'webinterface',
|
|
|
|
'show_cover_artwork_in_album_lists'
|
|
|
|
).value
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
$route(to, from) {
|
|
|
|
this.query = to.query
|
|
|
|
this.search()
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
mounted: function () {
|
|
|
|
this.query = this.$route.query
|
|
|
|
this.search()
|
|
|
|
},
|
|
|
|
|
2018-08-11 01:47:10 -04:00
|
|
|
methods: {
|
|
|
|
reset: function () {
|
|
|
|
this.tracks = { items: [], total: 0 }
|
|
|
|
this.artists = { items: [], total: 0 }
|
|
|
|
this.albums = { items: [], total: 0 }
|
|
|
|
this.playlists = { items: [], total: 0 }
|
|
|
|
},
|
|
|
|
|
|
|
|
search: function () {
|
|
|
|
this.reset()
|
|
|
|
|
|
|
|
// If no search query present reset and focus search field
|
2022-02-19 00:39:14 -05:00
|
|
|
if (
|
|
|
|
!this.query.query ||
|
|
|
|
this.query.query === '' ||
|
|
|
|
this.query.query.startsWith('query:')
|
|
|
|
) {
|
2018-08-11 01:47:10 -04:00
|
|
|
this.search_query = ''
|
|
|
|
this.$refs.search_field.focus()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-10-18 01:39:29 -04:00
|
|
|
this.search_query = this.query.query
|
2022-02-19 00:18:01 -05:00
|
|
|
this.search_param.limit = this.query.limit ? this.query.limit : PAGE_SIZE
|
2018-08-11 01:47:10 -04:00
|
|
|
this.search_param.offset = this.query.offset ? this.query.offset : 0
|
|
|
|
|
|
|
|
this.$store.commit(types.ADD_RECENT_SEARCH, this.query.query)
|
|
|
|
|
2020-11-21 05:08:26 -05:00
|
|
|
this.search_all()
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
spotify_search: function () {
|
|
|
|
return webapi.spotify().then(({ data }) => {
|
|
|
|
this.search_param.market = data.webapi_country
|
|
|
|
|
2021-01-10 01:51:50 -05:00
|
|
|
const spotifyApi = new SpotifyWebApi()
|
2018-08-11 01:47:10 -04:00
|
|
|
spotifyApi.setAccessToken(data.webapi_token)
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
const types = this.query.type
|
|
|
|
.split(',')
|
|
|
|
.filter((type) => this.validSearchTypes.includes(type))
|
2020-08-30 09:53:12 -04:00
|
|
|
return spotifyApi.search(this.query.query, types, this.search_param)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
search_all: function () {
|
2022-02-19 00:39:14 -05:00
|
|
|
this.spotify_search().then((data) => {
|
2018-08-11 01:47:10 -04:00
|
|
|
this.tracks = data.tracks ? data.tracks : { items: [], total: 0 }
|
|
|
|
this.artists = data.artists ? data.artists : { items: [], total: 0 }
|
|
|
|
this.albums = data.albums ? data.albums : { items: [], total: 0 }
|
2022-02-19 00:39:14 -05:00
|
|
|
this.playlists = data.playlists
|
|
|
|
? data.playlists
|
|
|
|
: { items: [], total: 0 }
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
search_tracks_next: function ({ loaded }) {
|
2022-02-19 00:39:14 -05:00
|
|
|
this.spotify_search().then((data) => {
|
2018-08-11 01:47:10 -04:00
|
|
|
this.tracks.items = this.tracks.items.concat(data.tracks.items)
|
|
|
|
this.tracks.total = data.tracks.total
|
|
|
|
this.search_param.offset += data.tracks.limit
|
2022-02-19 00:39:14 -05:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
loaded(data.tracks.items.length, PAGE_SIZE)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
search_artists_next: function ({ loaded }) {
|
2022-02-19 00:39:14 -05:00
|
|
|
this.spotify_search().then((data) => {
|
2018-08-11 01:47:10 -04:00
|
|
|
this.artists.items = this.artists.items.concat(data.artists.items)
|
|
|
|
this.artists.total = data.artists.total
|
|
|
|
this.search_param.offset += data.artists.limit
|
2022-02-19 00:39:14 -05:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
loaded(data.artists.items.length, PAGE_SIZE)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
search_albums_next: function ({ loaded }) {
|
2022-02-19 00:39:14 -05:00
|
|
|
this.spotify_search().then((data) => {
|
2018-08-11 01:47:10 -04:00
|
|
|
this.albums.items = this.albums.items.concat(data.albums.items)
|
|
|
|
this.albums.total = data.albums.total
|
|
|
|
this.search_param.offset += data.albums.limit
|
2022-02-19 00:39:14 -05:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
loaded(data.albums.items.length, PAGE_SIZE)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
search_playlists_next: function ({ loaded }) {
|
2022-02-19 00:39:14 -05:00
|
|
|
this.spotify_search().then((data) => {
|
2018-08-11 01:47:10 -04:00
|
|
|
this.playlists.items = this.playlists.items.concat(data.playlists.items)
|
|
|
|
this.playlists.total = data.playlists.total
|
|
|
|
this.search_param.offset += data.playlists.limit
|
2022-02-19 00:39:14 -05:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
loaded(data.playlists.items.length, PAGE_SIZE)
|
2018-08-11 01:47:10 -04:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
new_search: function () {
|
|
|
|
if (!this.search_query) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-04-11 13:43:53 -04:00
|
|
|
this.$router.push({
|
|
|
|
path: '/search/spotify',
|
2018-08-11 01:47:10 -04:00
|
|
|
query: {
|
2020-08-30 09:53:12 -04:00
|
|
|
type: 'track,artist,album,playlist,audiobook,podcast',
|
2018-08-11 01:47:10 -04:00
|
|
|
query: this.search_query,
|
|
|
|
limit: 3,
|
|
|
|
offset: 0
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$refs.search_field.blur()
|
|
|
|
},
|
|
|
|
|
|
|
|
open_search_tracks: function () {
|
2020-04-11 13:43:53 -04:00
|
|
|
this.$router.push({
|
|
|
|
path: '/search/spotify',
|
2018-08-11 01:47:10 -04:00
|
|
|
query: {
|
|
|
|
type: 'track',
|
|
|
|
query: this.$route.query.query
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
open_search_artists: function () {
|
2020-04-11 13:43:53 -04:00
|
|
|
this.$router.push({
|
|
|
|
path: '/search/spotify',
|
2018-08-11 01:47:10 -04:00
|
|
|
query: {
|
|
|
|
type: 'artist',
|
|
|
|
query: this.$route.query.query
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
open_search_albums: function () {
|
2020-04-11 13:43:53 -04:00
|
|
|
this.$router.push({
|
|
|
|
path: '/search/spotify',
|
2018-08-11 01:47:10 -04:00
|
|
|
query: {
|
|
|
|
type: 'album',
|
|
|
|
query: this.$route.query.query
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
open_search_playlists: function () {
|
2020-04-11 13:43:53 -04:00
|
|
|
this.$router.push({
|
|
|
|
path: '/search/spotify',
|
2018-08-11 01:47:10 -04:00
|
|
|
query: {
|
|
|
|
type: 'playlist',
|
|
|
|
query: this.$route.query.query
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
open_recent_search: function (query) {
|
|
|
|
this.search_query = query
|
|
|
|
this.new_search()
|
2018-12-17 05:52:09 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
open_track_dialog: function (track) {
|
|
|
|
this.selected_track = track
|
|
|
|
this.show_track_details_modal = true
|
|
|
|
},
|
|
|
|
|
|
|
|
open_album_dialog: function (album) {
|
|
|
|
this.selected_album = album
|
|
|
|
this.show_album_details_modal = true
|
|
|
|
},
|
|
|
|
|
|
|
|
open_artist_dialog: function (artist) {
|
|
|
|
this.selected_artist = artist
|
|
|
|
this.show_artist_details_modal = true
|
|
|
|
},
|
|
|
|
|
|
|
|
open_playlist_dialog: function (playlist) {
|
|
|
|
this.selected_playlist = playlist
|
|
|
|
this.show_playlist_details_modal = true
|
2020-08-23 13:26:54 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
open_album: function (album) {
|
|
|
|
this.$router.push({ path: '/music/spotify/albums/' + album.id })
|
|
|
|
},
|
|
|
|
|
|
|
|
artwork_url: function (album) {
|
|
|
|
if (album.images && album.images.length > 0) {
|
|
|
|
return album.images[0].url
|
|
|
|
}
|
|
|
|
return ''
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
<style></style>
|