2018-08-11 07:47:10 +02:00
|
|
|
<template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<div class="fd-page-with-tabs">
|
2022-02-19 06:39:14 +01:00
|
|
|
<tabs-music />
|
2018-08-11 07:47:10 +02:00
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #options>
|
2022-02-19 07:47:54 +01:00
|
|
|
<index-button-list :index="artists.indexList" />
|
2020-10-08 06:01:17 +02:00
|
|
|
<div class="columns">
|
|
|
|
<div class="column">
|
2023-07-01 18:19:29 +02:00
|
|
|
<p class="heading mb-5" v-text="$t('page.artists.filter')" />
|
2020-10-08 06:01:17 +02:00
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
2022-05-29 18:49:00 +02:00
|
|
|
<input
|
|
|
|
id="switchHideSingles"
|
|
|
|
v-model="hide_singles"
|
|
|
|
type="checkbox"
|
2023-07-02 11:30:06 +02:00
|
|
|
class="switch is-rounded"
|
2022-05-29 18:49:00 +02:00
|
|
|
/>
|
|
|
|
<label
|
|
|
|
for="switchHideSingles"
|
|
|
|
v-text="$t('page.artists.hide-singles')"
|
|
|
|
/>
|
2020-10-08 06:01:17 +02:00
|
|
|
</div>
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="help" v-text="$t('page.artists.hide-singles-help')" />
|
2020-10-08 06:01:17 +02:00
|
|
|
</div>
|
2022-02-19 06:39:14 +01:00
|
|
|
<div v-if="spotify_enabled" class="field">
|
2020-10-08 06:01:17 +02:00
|
|
|
<div class="control">
|
2022-05-29 18:49:00 +02:00
|
|
|
<input
|
|
|
|
id="switchHideSpotify"
|
|
|
|
v-model="hide_spotify"
|
|
|
|
type="checkbox"
|
2023-07-02 11:30:06 +02:00
|
|
|
class="switch is-rounded"
|
2022-05-29 18:49:00 +02:00
|
|
|
/>
|
|
|
|
<label
|
|
|
|
for="switchHideSpotify"
|
|
|
|
v-text="$t('page.artists.hide-spotify')"
|
|
|
|
/>
|
2020-10-08 06:01:17 +02:00
|
|
|
</div>
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="help" v-text="$t('page.artists.hide-spotify-help')" />
|
2020-10-08 06:01:17 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column">
|
2023-07-01 18:19:29 +02:00
|
|
|
<p class="heading mb-5" v-text="$t('page.artists.sort-by.title')" />
|
2023-07-08 14:43:38 +02:00
|
|
|
<control-dropdown
|
|
|
|
v-model:value="selected_groupby_option_id"
|
2022-05-29 18:49:00 +02:00
|
|
|
:options="groupby_options"
|
|
|
|
/>
|
2020-10-08 06:01:17 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-12-08 08:48:15 +01:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="title is-4" v-text="$t('page.artists.title')" />
|
2022-05-29 18:49:00 +02:00
|
|
|
<p
|
|
|
|
class="heading"
|
|
|
|
v-text="$t('page.artists.count', { count: artists.count })"
|
|
|
|
/>
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-right />
|
|
|
|
<template #content>
|
2022-02-19 07:47:54 +01:00
|
|
|
<list-artists :artists="artists" />
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-08 14:43:38 +02:00
|
|
|
import * as types from '@/store/mutation_types'
|
|
|
|
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
2023-07-08 14:43:38 +02:00
|
|
|
import ControlDropdown from '@/components/ControlDropdown.vue'
|
2022-02-19 06:18:01 +01:00
|
|
|
import IndexButtonList from '@/components/IndexButtonList.vue'
|
|
|
|
import ListArtists from '@/components/ListArtists.vue'
|
2023-07-08 14:43:38 +02:00
|
|
|
import TabsMusic from '@/components/TabsMusic.vue'
|
2018-08-11 07:47:10 +02:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
const dataObject = {
|
2023-06-07 21:25:54 +02:00
|
|
|
load(to) {
|
2020-07-01 07:29:03 +02:00
|
|
|
return webapi.library_artists('music')
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2023-06-07 21:25:54 +02:00
|
|
|
set(vm, response) {
|
2022-02-19 07:47:54 +01:00
|
|
|
vm.artists_list = new GroupByList(response.data)
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageArtists',
|
2022-02-19 06:39:14 +01:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
2023-07-08 14:43:38 +02:00
|
|
|
ControlDropdown,
|
2022-02-19 06:39:14 +01:00
|
|
|
IndexButtonList,
|
|
|
|
ListArtists,
|
2023-07-09 00:25:06 +02:00
|
|
|
TabsMusic
|
2022-02-19 06:39:14 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next((vm) => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
2022-02-19 07:47:54 +01:00
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
beforeRouteUpdate(to, from, next) {
|
2022-02-19 07:47:54 +01:00
|
|
|
if (!this.artists_list.isEmpty()) {
|
2022-02-19 06:39:14 +01:00
|
|
|
next()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
},
|
2018-08-11 07:47:10 +02:00
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
data() {
|
2018-08-11 07:47:10 +02:00
|
|
|
return {
|
2022-02-19 07:47:54 +01:00
|
|
|
artists_list: new GroupByList(),
|
|
|
|
groupby_options: [
|
|
|
|
{
|
2022-05-20 13:44:22 +02:00
|
|
|
id: 1,
|
|
|
|
name: this.$t('page.artists.sort-by.name'),
|
2023-06-04 13:54:01 +02:00
|
|
|
options: byName('name_sort', true)
|
2022-05-20 13:44:22 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
name: this.$t('page.artists.sort-by.recently-added'),
|
2022-02-19 07:47:54 +01:00
|
|
|
options: byYear('time_added', {
|
2023-06-04 13:54:01 +02:00
|
|
|
direction: 'desc'
|
2022-02-19 07:47:54 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
]
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-02-19 07:47:54 +01:00
|
|
|
// Wraps GroupByList and updates it if filter or sort changes
|
|
|
|
artists() {
|
|
|
|
if (!this.artists_list) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
const groupBy = this.groupby_options.find(
|
2022-05-20 13:44:22 +02:00
|
|
|
(o) => o.id === this.selected_groupby_option_id
|
2022-02-19 07:47:54 +01:00
|
|
|
)
|
|
|
|
this.artists_list.group(groupBy.options, [
|
|
|
|
(artist) =>
|
2022-03-20 15:22:31 +01:00
|
|
|
!this.hide_singles || artist.track_count > artist.album_count * 2,
|
2022-02-19 07:47:54 +01:00
|
|
|
(artist) => !this.hide_spotify || artist.data_kind !== 'spotify'
|
|
|
|
])
|
|
|
|
|
|
|
|
return this.artists_list
|
|
|
|
},
|
|
|
|
|
2022-05-20 13:44:22 +02:00
|
|
|
selected_groupby_option_id: {
|
2022-02-19 07:47:54 +01:00
|
|
|
get() {
|
|
|
|
return this.$store.state.artists_sort
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
this.$store.commit(types.ARTISTS_SORT, value)
|
|
|
|
}
|
2018-12-08 08:48:15 +01:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_enabled() {
|
2020-10-11 09:01:34 +02:00
|
|
|
return this.$store.state.spotify.webapi_token_valid
|
|
|
|
},
|
|
|
|
|
2020-10-08 06:01:17 +02:00
|
|
|
hide_singles: {
|
2022-02-19 06:39:14 +01:00
|
|
|
get() {
|
2020-10-08 06:01:17 +02:00
|
|
|
return this.$store.state.hide_singles
|
|
|
|
},
|
2022-02-19 06:39:14 +01:00
|
|
|
set(value) {
|
2020-10-08 06:01:17 +02:00
|
|
|
this.$store.commit(types.HIDE_SINGLES, value)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hide_spotify: {
|
2022-02-19 06:39:14 +01:00
|
|
|
get() {
|
2020-10-08 06:01:17 +02:00
|
|
|
return this.$store.state.hide_spotify
|
|
|
|
},
|
2022-02-19 06:39:14 +01:00
|
|
|
set(value) {
|
2020-10-08 06:01:17 +02:00
|
|
|
this.$store.commit(types.HIDE_SPOTIFY, value)
|
|
|
|
}
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
2023-06-30 03:51:38 +02:00
|
|
|
}
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|