[web] Cleanup of code to simplify

Useless methods have been removed and code has been partially cleaned up.
This commit is contained in:
Alain Nussbaumer
2023-06-07 21:25:54 +02:00
parent 3a1cc63e8f
commit 387e531d64
84 changed files with 355 additions and 362 deletions

View File

@@ -51,14 +51,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_album(to.params.album_id),
webapi.library_album_tracks(to.params.album_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.album = response[0].data
vm.tracks = new GroupByList(response[1].data)
}
@@ -90,12 +90,12 @@ export default {
},
methods: {
open_artist: function () {
open_artist() {
this.show_details_modal = false
this.$router.push({ path: '/music/artists/' + this.album.artist_id })
},
play: function () {
play() {
webapi.player_play_uri(this.album.uri, true)
}
}

View File

@@ -80,14 +80,14 @@ import ListAlbums from '@/components/ListAlbums.vue'
import DropdownMenu from '@/components/DropdownMenu.vue'
import webapi from '@/webapi'
import * as types from '@/store/mutation_types'
import { byName, byYear, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_albums('music')
},
set: function (vm, response) {
set(vm, response) {
vm.albums_list = new GroupByList(response.data)
}
}

View File

@@ -61,17 +61,17 @@ import ModalDialogArtist from '@/components/ModalDialogArtist.vue'
import DropdownMenu from '@/components/DropdownMenu.vue'
import webapi from '@/webapi'
import * as types from '@/store/mutation_types'
import { byName, byYear, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_artist(to.params.artist_id),
webapi.library_artist_albums(to.params.artist_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.artist = response[0].data
vm.albums_list = new GroupByList(response[1].data)
}
@@ -142,13 +142,13 @@ export default {
},
methods: {
open_tracks: function () {
open_tracks() {
this.$router.push({
path: '/music/artists/' + this.artist.id + '/tracks'
})
},
play: function () {
play() {
webapi.player_play_uri(
this.albums.items.map((a) => a.uri).join(','),
true

View File

@@ -71,17 +71,17 @@ import ListTracks from '@/components/ListTracks.vue'
import ModalDialogArtist from '@/components/ModalDialogArtist.vue'
import webapi from '@/webapi'
import * as types from '@/store/mutation_types'
import { byName, byRating, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName, byRating } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_artist(to.params.artist_id),
webapi.library_artist_tracks(to.params.artist_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.artist = response[0].data
vm.tracks_list = new GroupByList(response[1].data.tracks)
}
@@ -154,12 +154,12 @@ export default {
},
methods: {
open_artist: function () {
open_artist() {
this.show_details_modal = false
this.$router.push({ path: '/music/artists/' + this.artist.id })
},
play: function () {
play() {
webapi.player_play_uri(this.tracks_list.map((a) => a.uri).join(','), true)
}
}

View File

@@ -80,14 +80,14 @@ import ListArtists from '@/components/ListArtists.vue'
import DropdownMenu from '@/components/DropdownMenu.vue'
import webapi from '@/webapi'
import * as types from '@/store/mutation_types'
import { byName, byYear, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_artists('music')
},
set: function (vm, response) {
set(vm, response) {
vm.artists_list = new GroupByList(response.data)
}
}

View File

@@ -54,14 +54,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_album(to.params.album_id),
webapi.library_album_tracks(to.params.album_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.album = response[0].data
vm.tracks = new GroupByList(response[1].data)
}
@@ -93,12 +93,12 @@ export default {
},
methods: {
open_artist: function () {
open_artist() {
this.show_details_modal = false
this.$router.push({ path: '/audiobooks/artists/' + this.album.artist_id })
},
play: function () {
play() {
webapi.player_play_uri(this.album.uri, false)
}
}

View File

@@ -25,14 +25,14 @@ import IndexButtonList from '@/components/IndexButtonList.vue'
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ListAlbums from '@/components/ListAlbums.vue'
import webapi from '@/webapi'
import { byName, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_albums('audiobook')
},
set: function (vm, response) {
set(vm, response) {
vm.albums = new GroupByList(response.data)
vm.albums.group(byName('name_sort', true))
}

View File

@@ -44,14 +44,14 @@ import webapi from '@/webapi'
import { GroupByList } from '../lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_artist(to.params.artist_id),
webapi.library_artist_albums(to.params.artist_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.artist = response[0].data
vm.albums = new GroupByList(response[1].data)
}
@@ -89,7 +89,7 @@ export default {
},
methods: {
play: function () {
play() {
webapi.player_play_uri(
this.albums.items.map((a) => a.uri).join(','),
false

View File

@@ -26,14 +26,14 @@ import TabsAudiobooks from '@/components/TabsAudiobooks.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ListArtists from '@/components/ListArtists.vue'
import webapi from '@/webapi'
import { byName, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_artists('audiobook')
},
set: function (vm, response) {
set(vm, response) {
vm.artists_list = new GroupByList(response.data)
}
}

View File

@@ -58,7 +58,7 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.search({
type: 'album',
@@ -75,7 +75,7 @@ const dataObject = {
])
},
set: function (vm, response) {
set(vm, response) {
vm.recently_added = new GroupByList(response[0].data.albums)
vm.recently_played = new GroupByList(response[1].data.tracks)
}
@@ -110,7 +110,7 @@ export default {
},
methods: {
open_browse: function (type) {
open_browse(type) {
this.$router.push({ path: '/music/browse/' + type })
}
}

View File

@@ -19,10 +19,10 @@ import TabsMusic from '@/components/TabsMusic.vue'
import ListAlbums from '@/components/ListAlbums.vue'
import webapi from '@/webapi'
import store from '@/store'
import { byDateSinceToday, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byDateSinceToday } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
const limit = store.getters.settings_option_recently_added_limit
return webapi.search({
type: 'album',
@@ -32,7 +32,7 @@ const dataObject = {
})
},
set: function (vm, response) {
set(vm, response) {
vm.recently_added = new GroupByList(response.data.albums)
vm.recently_added.group(
byDateSinceToday('time_added', {

View File

@@ -24,7 +24,7 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.search({
type: 'track',
expression:
@@ -33,7 +33,7 @@ const dataObject = {
})
},
set: function (vm, response) {
set(vm, response) {
vm.recently_played = new GroupByList(response.data.tracks)
}
}

View File

@@ -55,14 +55,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_composer(to.params.composer),
webapi.library_composer_albums(to.params.composer)
])
},
set: function (vm, response) {
set(vm, response) {
vm.composer = response[0].data
vm.albums_list = new GroupByList(response[1].data.albums)
}
@@ -98,14 +98,14 @@ export default {
},
methods: {
open_tracks: function () {
open_tracks() {
this.$router.push({
name: 'ComposerTracks',
params: { composer: this.composer.name }
})
},
play: function () {
play() {
webapi.player_play_expression(
'composer is "' + this.composer.name + '" and media_kind is music',
true

View File

@@ -73,17 +73,17 @@ import ListTracks from '@/components/ListTracks.vue'
import ModalDialogComposer from '@/components/ModalDialogComposer.vue'
import webapi from '@/webapi'
import * as types from '@/store/mutation_types'
import { byName, byRating, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName, byRating } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_composer(to.params.composer),
webapi.library_composer_tracks(to.params.composer)
])
},
set: function (vm, response) {
set(vm, response) {
vm.composer = response[0].data
vm.tracks_list = new GroupByList(response[1].data.tracks)
}
@@ -156,7 +156,7 @@ export default {
},
methods: {
open_albums: function () {
open_albums() {
this.show_details_modal = false
this.$router.push({
name: 'ComposerAlbums',
@@ -164,7 +164,7 @@ export default {
})
},
play: function () {
play() {
webapi.player_play_expression(this.expression, true)
}
}

View File

@@ -25,14 +25,14 @@ import TabsMusic from '@/components/TabsMusic.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ListComposers from '@/components/ListComposers.vue'
import webapi from '@/webapi'
import { byName, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_composers('music')
},
set: function (vm, response) {
set(vm, response) {
vm.composers = new GroupByList(response.data)
vm.composers.group(byName('name_sort'))
}

View File

@@ -49,14 +49,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
if (to.query.directory) {
return webapi.library_files(to.query.directory)
}
return Promise.resolve()
},
set: function (vm, response) {
set(vm, response) {
if (response) {
vm.dirs = response.data.directories
vm.playlists = new GroupByList(response.data.playlists)
@@ -119,7 +119,7 @@ export default {
},
methods: {
play: function () {
play() {
webapi.player_play_expression(this.play_expression, false)
}
}

View File

@@ -52,17 +52,17 @@ import IndexButtonList from '@/components/IndexButtonList.vue'
import ListAlbums from '@/components/ListAlbums.vue'
import ModalDialogGenre from '@/components/ModalDialogGenre.vue'
import webapi from '@/webapi'
import { byName, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_genre(to.params.genre),
webapi.library_genre_albums(to.params.genre)
])
},
set: function (vm, response) {
set(vm, response) {
vm.genre = response[0].data
vm.albums_list = new GroupByList(response[1].data.albums)
vm.albums_list.group(byName('name_sort', true))
@@ -105,7 +105,7 @@ export default {
},
methods: {
open_tracks: function () {
open_tracks() {
this.show_details_modal = false
this.$router.push({
name: 'GenreTracks',
@@ -113,7 +113,7 @@ export default {
})
},
play: function () {
play() {
webapi.player_play_expression(
'genre is "' + this.genre.name + '" and media_kind is music',
true

View File

@@ -67,17 +67,17 @@ import ListTracks from '@/components/ListTracks.vue'
import ModalDialogGenre from '@/components/ModalDialogGenre.vue'
import webapi from '@/webapi'
import * as types from '@/store/mutation_types'
import { byName, byRating, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName, byRating } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_genre(to.params.genre),
webapi.library_genre_tracks(to.params.genre)
])
},
set: function (vm, response) {
set(vm, response) {
vm.genre = response[0].data
vm.tracks_list = new GroupByList(response[1].data.tracks)
}
@@ -150,12 +150,12 @@ export default {
},
methods: {
open_genre: function () {
open_genre() {
this.show_details_modal = false
this.$router.push({ name: 'Genre', params: { genre: this.genre.name } })
},
play: function () {
play() {
webapi.player_play_expression(this.expression, true)
}
}

View File

@@ -25,14 +25,14 @@ import TabsMusic from '@/components/TabsMusic.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ListGenres from '@/components/ListGenres.vue'
import webapi from '@/webapi'
import { byName, GroupByList } from '@/lib/GroupByList'
import { GroupByList, byName } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_genres('music')
},
set: function (vm, response) {
set(vm, response) {
vm.genres = response.data
vm.genres = new GroupByList(response.data)
vm.genres.group(byName('name_sort'))

View File

@@ -161,7 +161,7 @@ export default {
}
},
mounted: function () {},
mounted() {},
created() {
this.item_progress_ms = this.state.item_progress_ms
@@ -181,27 +181,27 @@ export default {
},
methods: {
tick: function () {
tick() {
if (!this.is_dragged) {
this.item_progress_ms += 1000
}
},
start_dragging: function () {
start_dragging() {
this.is_dragged = true
},
end_dragging: function () {
end_dragging() {
this.is_dragged = false
},
seek: function (newPosition) {
seek(newPosition) {
webapi.player_seek_to_pos(newPosition).catch(() => {
this.item_progress_ms = this.state.item_progress_ms
})
},
open_dialog: function (item) {
open_dialog(item) {
this.selected_item = item
this.show_details_modal = true
}

View File

@@ -41,14 +41,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_playlist(to.params.playlist_id),
webapi.library_playlist_tracks(to.params.playlist_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.playlist = response[0].data
vm.tracks = new GroupByList(response[1].data)
}
@@ -89,7 +89,7 @@ export default {
},
methods: {
play: function () {
play() {
webapi.player_play_uri(this.uris, true)
}
}

View File

@@ -20,14 +20,14 @@ import webapi from '@/webapi'
import { GroupByList, noop } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_playlist(to.params.playlist_id),
webapi.library_playlist_folder(to.params.playlist_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.playlist = response[0].data
vm.playlists_list = new GroupByList(response[1].data)
}

View File

@@ -64,14 +64,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_album(to.params.album_id),
webapi.library_podcast_episodes(to.params.album_id)
])
},
set: function (vm, response) {
set(vm, response) {
vm.album = response[0].data
vm.tracks = new GroupByList(response[1].data.tracks)
}
@@ -116,11 +116,11 @@ export default {
},
methods: {
play: function () {
play() {
webapi.player_play_uri(this.album.uri, false)
},
open_remove_podcast_dialog: function () {
open_remove_podcast_dialog() {
webapi
.library_track_playlists(this.tracks.items[0].id)
.then(({ data }) => {
@@ -132,7 +132,7 @@ export default {
})
},
remove_podcast: function () {
remove_podcast() {
this.show_remove_podcast_modal = false
webapi
.library_playlist_delete(this.rss_playlist_to_remove.id)
@@ -141,7 +141,7 @@ export default {
})
},
reload_tracks: function () {
reload_tracks() {
webapi.library_podcast_episodes(this.album.id).then(({ data }) => {
this.tracks = new GroupByList(data.tracks)
})

View File

@@ -66,14 +66,14 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return Promise.all([
webapi.library_albums('podcast'),
webapi.library_podcasts_new_episodes()
])
},
set: function (vm, response) {
set(vm, response) {
vm.albums = new GroupByList(response[0].data)
vm.new_episodes = new GroupByList(response[1].data.tracks)
}
@@ -118,31 +118,31 @@ export default {
},
methods: {
mark_all_played: function () {
mark_all_played() {
this.new_episodes.items.forEach((ep) => {
webapi.library_track_update(ep.id, { play_count: 'increment' })
})
this.new_episodes.items = {}
},
open_add_podcast_dialog: function (item) {
open_add_podcast_dialog(item) {
this.show_url_modal = true
},
reload_new_episodes: function () {
reload_new_episodes() {
webapi.library_podcasts_new_episodes().then(({ data }) => {
this.new_episodes = new GroupByList(data.tracks)
})
},
reload_podcasts: function () {
reload_podcasts() {
webapi.library_albums('podcast').then(({ data }) => {
this.albums = new GroupByList(data)
this.reload_new_episodes()
})
},
update_rss: function () {
update_rss() {
this.$store.commit(types.UPDATE_DIALOG_SCAN_KIND, 'rss')
this.$store.commit(types.SHOW_UPDATE_DIALOG, true)
}

View File

@@ -162,19 +162,19 @@ export default {
},
methods: {
queue_clear: function () {
queue_clear() {
webapi.queue_clear()
},
update_show_next_items: function (e) {
update_show_next_items(e) {
this.$store.commit(types.SHOW_ONLY_NEXT_ITEMS, !this.show_only_next_items)
},
remove: function (item) {
remove(item) {
webapi.queue_remove(item.id)
},
move_item: function (e) {
move_item(e) {
const oldPosition = !this.show_only_next_items
? e.oldIndex
: e.oldIndex + this.current_position
@@ -185,16 +185,16 @@ export default {
}
},
open_dialog: function (item) {
open_dialog(item) {
this.selected_item = item
this.show_details_modal = true
},
open_add_stream_dialog: function (item) {
open_add_stream_dialog(item) {
this.show_url_modal = true
},
save_dialog: function (item) {
save_dialog(item) {
if (this.queue_items.length > 0) {
this.show_pls_save_modal = true
}

View File

@@ -22,11 +22,11 @@ import webapi from '@/webapi'
import { GroupByList } from '@/lib/GroupByList'
const dataObject = {
load: function (to) {
load(to) {
return webapi.library_radio_streams()
},
set: function (vm, response) {
set(vm, response) {
vm.tracks = new GroupByList(response.data.tracks)
}
}

View File

@@ -345,13 +345,6 @@ export default {
},
show_all_podcasts_button() {
return this.podcasts.total > this.podcasts.items.length
},
is_visible_artwork() {
return this.$store.getters.settings_option(
'webinterface',
'show_cover_artwork_in_album_lists'
).value
}
},
@@ -361,12 +354,12 @@ export default {
}
},
mounted: function () {
mounted() {
this.search(this.$route)
},
methods: {
search: function (route) {
search(route) {
if (!route.query.query || route.query.query === '') {
this.search_query = ''
this.$refs.search_field.focus()
@@ -380,7 +373,7 @@ export default {
this.$store.commit(types.ADD_RECENT_SEARCH, route.query.query)
},
searchMusic: function (query) {
searchMusic(query) {
if (
query.type.indexOf('track') < 0 &&
query.type.indexOf('artist') < 0 &&
@@ -415,7 +408,7 @@ export default {
})
},
searchAudiobooks: function (query) {
searchAudiobooks(query) {
if (query.type.indexOf('audiobook') < 0) {
return
}
@@ -446,7 +439,7 @@ export default {
})
},
searchPodcasts: function (query) {
searchPodcasts(query) {
if (query.type.indexOf('podcast') < 0) {
return
}
@@ -477,7 +470,7 @@ export default {
})
},
new_search: function () {
new_search() {
if (!this.search_query) {
return
}
@@ -494,7 +487,7 @@ export default {
this.$refs.search_field.blur()
},
open_search_tracks: function () {
open_search_tracks() {
this.$router.push({
path: '/search/library',
query: {
@@ -504,7 +497,7 @@ export default {
})
},
open_search_artists: function () {
open_search_artists() {
this.$router.push({
path: '/search/library',
query: {
@@ -514,7 +507,7 @@ export default {
})
},
open_search_albums: function () {
open_search_albums() {
this.$router.push({
path: '/search/library',
query: {
@@ -524,7 +517,7 @@ export default {
})
},
open_search_composers: function () {
open_search_composers() {
this.$router.push({
path: '/search/library',
query: {
@@ -534,7 +527,7 @@ export default {
})
},
open_search_playlists: function () {
open_search_playlists() {
this.$router.push({
path: '/search/library',
query: {
@@ -544,7 +537,7 @@ export default {
})
},
open_search_audiobooks: function () {
open_search_audiobooks() {
this.$router.push({
path: '/search/library',
query: {
@@ -554,7 +547,7 @@ export default {
})
},
open_search_podcasts: function () {
open_search_podcasts() {
this.$router.push({
path: '/search/library',
query: {
@@ -564,43 +557,43 @@ export default {
})
},
open_composer: function (composer) {
open_composer(composer) {
this.$router.push({
name: 'ComposerAlbums',
params: { composer: composer.name }
})
},
open_playlist: function (playlist) {
open_playlist(playlist) {
this.$router.push({ path: '/playlists/' + playlist.id + '/tracks' })
},
open_recent_search: function (query) {
open_recent_search(query) {
this.search_query = query
this.new_search()
},
open_track_dialog: function (track) {
open_track_dialog(track) {
this.selected_track = track
this.show_track_details_modal = true
},
open_album_dialog: function (album) {
open_album_dialog(album) {
this.selected_album = album
this.show_album_details_modal = true
},
open_artist_dialog: function (artist) {
open_artist_dialog(artist) {
this.selected_artist = artist
this.show_artist_details_modal = true
},
open_composer_dialog: function (composer) {
open_composer_dialog(composer) {
this.selected_composer = composer
this.show_composer_details_modal = true
},
open_playlist_dialog: function (playlist) {
open_playlist_dialog(playlist) {
this.selected_playlist = playlist
this.show_playlist_details_modal = true
}

View File

@@ -80,7 +80,7 @@ import webapi from '@/webapi'
import SpotifyWebApi from 'spotify-web-api-js'
const dataObject = {
load: function (to) {
load(to) {
const spotifyApi = new SpotifyWebApi()
spotifyApi.setAccessToken(store.state.spotify.webapi_token)
return spotifyApi.getAlbum(to.params.album_id, {
@@ -88,7 +88,7 @@ const dataObject = {
})
},
set: function (vm, response) {
set(vm, response) {
vm.album = response
}
}
@@ -128,7 +128,7 @@ export default {
},
computed: {
artwork_url: function () {
artwork_url() {
if (this.album.images && this.album.images.length > 0) {
return this.album.images[0].url
}
@@ -137,18 +137,18 @@ export default {
},
methods: {
open_artist: function () {
open_artist() {
this.$router.push({
path: '/music/spotify/artists/' + this.album.artists[0].id
})
},
play: function () {
play() {
this.show_details_modal = false
webapi.player_play_uri(this.album.uri, true)
},
open_track_dialog: function (track) {
open_track_dialog(track) {
this.selected_track = track
this.show_track_details_modal = true
}

View File

@@ -91,7 +91,7 @@ const dataObject = {
])
},
set: function (vm, response) {
set(vm, response) {
vm.artist = response[0]
vm.albums = []
@@ -149,7 +149,7 @@ export default {
},
methods: {
load_next: function ({ loaded }) {
load_next({ loaded }) {
const spotifyApi = new SpotifyWebApi()
spotifyApi.setAccessToken(this.$store.state.spotify.webapi_token)
spotifyApi
@@ -164,27 +164,27 @@ export default {
})
},
append_albums: function (data) {
append_albums(data) {
this.albums = this.albums.concat(data.items)
this.total = data.total
this.offset += data.limit
},
play: function () {
play() {
this.show_details_modal = false
webapi.player_play_uri(this.artist.uri, true)
},
open_album: function (album) {
open_album(album) {
this.$router.push({ path: '/music/spotify/albums/' + album.id })
},
open_dialog: function (album) {
open_dialog(album) {
this.selected_album = album
this.show_details_modal = true
},
artwork_url: function (album) {
artwork_url(album) {
if (album.images && album.images.length > 0) {
return album.images[0].url
}

View File

@@ -105,7 +105,7 @@ import * as types from '@/store/mutation_types'
import SpotifyWebApi from 'spotify-web-api-js'
const dataObject = {
load: function (to) {
load(to) {
if (
store.state.spotify_new_releases.length > 0 &&
store.state.spotify_featured_playlists.length > 0
@@ -127,7 +127,7 @@ const dataObject = {
])
},
set: function (vm, response) {
set(vm, response) {
if (response) {
store.commit(types.SPOTIFY_NEW_RELEASES, response[0].albums.items)
store.commit(
@@ -191,21 +191,21 @@ export default {
},
methods: {
open_album: function (album) {
open_album(album) {
this.$router.push({ path: '/music/spotify/albums/' + album.id })
},
open_album_dialog: function (album) {
open_album_dialog(album) {
this.selected_album = album
this.show_album_details_modal = true
},
open_playlist_dialog: function (playlist) {
open_playlist_dialog(playlist) {
this.selected_playlist = playlist
this.show_playlist_details_modal = true
},
artwork_url: function (album) {
artwork_url(album) {
if (album.images && album.images.length > 0) {
return album.images[0].url
}

View File

@@ -39,7 +39,7 @@ import * as types from '@/store/mutation_types'
import SpotifyWebApi from 'spotify-web-api-js'
const dataObject = {
load: function (to) {
load(to) {
if (store.state.spotify_featured_playlists.length > 0) {
return Promise.resolve()
}
@@ -52,7 +52,7 @@ const dataObject = {
})
},
set: function (vm, response) {
set(vm, response) {
if (response) {
store.commit(types.SPOTIFY_FEATURED_PLAYLISTS, response.playlists.items)
}
@@ -95,7 +95,7 @@ export default {
},
methods: {
open_playlist_dialog: function (playlist) {
open_playlist_dialog(playlist) {
this.selected_playlist = playlist
this.show_playlist_details_modal = true
}

View File

@@ -51,7 +51,7 @@ import * as types from '@/store/mutation_types'
import SpotifyWebApi from 'spotify-web-api-js'
const dataObject = {
load: function (to) {
load(to) {
if (store.state.spotify_new_releases.length > 0) {
return Promise.resolve()
}
@@ -64,7 +64,7 @@ const dataObject = {
})
},
set: function (vm, response) {
set(vm, response) {
if (response) {
store.commit(types.SPOTIFY_NEW_RELEASES, response.albums.items)
}
@@ -115,16 +115,16 @@ export default {
},
methods: {
open_album: function (album) {
open_album(album) {
this.$router.push({ path: '/music/spotify/albums/' + album.id })
},
open_album_dialog: function (album) {
open_album_dialog(album) {
this.selected_album = album
this.show_album_details_modal = true
},
artwork_url: function (album) {
artwork_url(album) {
if (album.images && album.images.length > 0) {
return album.images[0].url
}

View File

@@ -83,7 +83,7 @@ const dataObject = {
])
},
set: function (vm, response) {
set(vm, response) {
vm.playlist = response[0]
vm.tracks = []
vm.total = 0
@@ -130,7 +130,7 @@ export default {
},
methods: {
load_next: function ({ loaded }) {
load_next({ loaded }) {
const spotifyApi = new SpotifyWebApi()
spotifyApi.setAccessToken(this.$store.state.spotify.webapi_token)
spotifyApi
@@ -144,18 +144,18 @@ export default {
})
},
append_tracks: function (data) {
append_tracks(data) {
this.tracks = this.tracks.concat(data.items)
this.total = data.total
this.offset += data.limit
},
play: function () {
play() {
this.show_details_modal = false
webapi.player_play_uri(this.playlist.uri, true)
},
open_track_dialog: function (track) {
open_track_dialog(track) {
this.selected_track = track
this.show_track_details_modal = true
}

View File

@@ -379,20 +379,20 @@ export default {
}
},
mounted: function () {
mounted() {
this.query = this.$route.query
this.search()
},
methods: {
reset: function () {
reset() {
this.tracks = { items: [], total: 0 }
this.artists = { items: [], total: 0 }
this.albums = { items: [], total: 0 }
this.playlists = { items: [], total: 0 }
},
search: function () {
search() {
this.reset()
// If no search query present reset and focus search field
@@ -415,7 +415,7 @@ export default {
this.search_all()
},
spotify_search: function () {
spotify_search() {
return webapi.spotify().then(({ data }) => {
this.search_param.market = data.webapi_country
@@ -429,7 +429,7 @@ export default {
})
},
search_all: function () {
search_all() {
this.spotify_search().then((data) => {
this.tracks = data.tracks ? data.tracks : { items: [], total: 0 }
this.artists = data.artists ? data.artists : { items: [], total: 0 }
@@ -440,7 +440,7 @@ export default {
})
},
search_tracks_next: function ({ loaded }) {
search_tracks_next({ loaded }) {
this.spotify_search().then((data) => {
this.tracks.items = this.tracks.items.concat(data.tracks.items)
this.tracks.total = data.tracks.total
@@ -450,7 +450,7 @@ export default {
})
},
search_artists_next: function ({ loaded }) {
search_artists_next({ loaded }) {
this.spotify_search().then((data) => {
this.artists.items = this.artists.items.concat(data.artists.items)
this.artists.total = data.artists.total
@@ -460,7 +460,7 @@ export default {
})
},
search_albums_next: function ({ loaded }) {
search_albums_next({ loaded }) {
this.spotify_search().then((data) => {
this.albums.items = this.albums.items.concat(data.albums.items)
this.albums.total = data.albums.total
@@ -470,7 +470,7 @@ export default {
})
},
search_playlists_next: function ({ loaded }) {
search_playlists_next({ loaded }) {
this.spotify_search().then((data) => {
this.playlists.items = this.playlists.items.concat(data.playlists.items)
this.playlists.total = data.playlists.total
@@ -480,7 +480,7 @@ export default {
})
},
new_search: function () {
new_search() {
if (!this.search_query) {
return
}
@@ -497,7 +497,7 @@ export default {
this.$refs.search_field.blur()
},
open_search_tracks: function () {
open_search_tracks() {
this.$router.push({
path: '/search/spotify',
query: {
@@ -507,7 +507,7 @@ export default {
})
},
open_search_artists: function () {
open_search_artists() {
this.$router.push({
path: '/search/spotify',
query: {
@@ -517,7 +517,7 @@ export default {
})
},
open_search_albums: function () {
open_search_albums() {
this.$router.push({
path: '/search/spotify',
query: {
@@ -527,7 +527,7 @@ export default {
})
},
open_search_playlists: function () {
open_search_playlists() {
this.$router.push({
path: '/search/spotify',
query: {
@@ -537,36 +537,36 @@ export default {
})
},
open_recent_search: function (query) {
open_recent_search(query) {
this.search_query = query
this.new_search()
},
open_track_dialog: function (track) {
open_track_dialog(track) {
this.selected_track = track
this.show_track_details_modal = true
},
open_album_dialog: function (album) {
open_album_dialog(album) {
this.selected_album = album
this.show_album_details_modal = true
},
open_artist_dialog: function (artist) {
open_artist_dialog(artist) {
this.selected_artist = artist
this.show_artist_details_modal = true
},
open_playlist_dialog: function (playlist) {
open_playlist_dialog(playlist) {
this.selected_playlist = playlist
this.show_playlist_details_modal = true
},
open_album: function (album) {
open_album(album) {
this.$router.push({ path: '/music/spotify/albums/' + album.id })
},
artwork_url: function (album) {
artwork_url(album) {
if (album.images && album.images.length > 0) {
return album.images[0].url
}