2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
2022-02-19 00:18:01 -05:00
|
|
|
<div class="fd-page-with-tabs">
|
2022-02-19 00:39:14 -05:00
|
|
|
<tabs-music />
|
2018-08-11 01:47:10 -04:00
|
|
|
|
|
|
|
<content-with-heading>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #options>
|
2022-02-19 01:47:54 -05:00
|
|
|
<index-button-list :index="albums.indexList" />
|
2020-10-08 00:01:17 -04:00
|
|
|
|
|
|
|
<div class="columns">
|
|
|
|
<div class="column">
|
2022-02-19 00:39:14 -05:00
|
|
|
<p class="heading" style="margin-bottom: 24px">Filter</p>
|
2020-10-08 00:01:17 -04:00
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
2022-02-19 00:39:14 -05:00
|
|
|
<input
|
|
|
|
id="switchHideSingles"
|
|
|
|
v-model="hide_singles"
|
|
|
|
type="checkbox"
|
|
|
|
name="switchHideSingles"
|
|
|
|
class="switch"
|
|
|
|
/>
|
2020-10-08 00:01:17 -04:00
|
|
|
<label for="switchHideSingles">Hide singles</label>
|
|
|
|
</div>
|
2022-02-19 00:39:14 -05:00
|
|
|
<p class="help">
|
|
|
|
If active, hides singles and albums with tracks that only appear
|
|
|
|
in playlists.
|
|
|
|
</p>
|
2020-10-08 00:01:17 -04:00
|
|
|
</div>
|
2022-02-19 00:39:14 -05:00
|
|
|
<div v-if="spotify_enabled" class="field">
|
2020-10-08 00:01:17 -04:00
|
|
|
<div class="control">
|
2022-02-19 00:39:14 -05:00
|
|
|
<input
|
|
|
|
id="switchHideSpotify"
|
|
|
|
v-model="hide_spotify"
|
|
|
|
type="checkbox"
|
|
|
|
name="switchHideSpotify"
|
|
|
|
class="switch"
|
|
|
|
/>
|
2020-10-17 01:26:00 -04:00
|
|
|
<label for="switchHideSpotify">Hide albums from Spotify</label>
|
2020-10-08 00:01:17 -04:00
|
|
|
</div>
|
2022-02-19 00:39:14 -05:00
|
|
|
<p class="help">
|
|
|
|
If active, hides albums that only appear in your Spotify
|
|
|
|
library.
|
|
|
|
</p>
|
2020-10-08 00:01:17 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column">
|
2022-02-19 00:39:14 -05:00
|
|
|
<p class="heading" style="margin-bottom: 24px">Sort by</p>
|
2022-02-19 01:47:54 -05:00
|
|
|
<dropdown-menu
|
|
|
|
v-model="selected_groupby_option_name"
|
|
|
|
:options="groupby_option_names"
|
|
|
|
/>
|
2020-10-08 00:01:17 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-12-08 02:48:15 -05:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2018-08-11 01:47:10 -04:00
|
|
|
<p class="title is-4">Albums</p>
|
2022-02-19 01:47:54 -05:00
|
|
|
<p class="heading">{{ albums.count }} Albums</p>
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-right />
|
|
|
|
<template #content>
|
2022-02-19 01:47:54 -05:00
|
|
|
<list-albums :albums="albums" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 00:18:01 -05:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
|
|
|
import TabsMusic from '@/components/TabsMusic.vue'
|
|
|
|
import IndexButtonList from '@/components/IndexButtonList.vue'
|
|
|
|
import ListAlbums from '@/components/ListAlbums.vue'
|
|
|
|
import DropdownMenu from '@/components/DropdownMenu.vue'
|
2018-08-11 01:47:10 -04:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
import * as types from '@/store/mutation_types'
|
2022-02-19 01:47:54 -05:00
|
|
|
import { bySortName, byYear, GroupByList } from '@/lib/GroupByList'
|
2018-08-11 01:47:10 -04:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
const dataObject = {
|
2018-08-11 01:47:10 -04:00
|
|
|
load: function (to) {
|
2020-06-30 04:24:11 -04:00
|
|
|
return webapi.library_albums('music')
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (vm, response) {
|
2022-02-19 01:47:54 -05:00
|
|
|
vm.albums_list = new GroupByList(response.data)
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageAlbums',
|
2022-02-19 00:39:14 -05:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
|
|
|
TabsMusic,
|
|
|
|
IndexButtonList,
|
|
|
|
ListAlbums,
|
|
|
|
DropdownMenu
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next((vm) => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
2022-02-19 01:47:54 -05:00
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
beforeRouteUpdate(to, from, next) {
|
2022-02-19 01:47:54 -05:00
|
|
|
if (!this.albums_list.isEmpty()) {
|
2022-02-19 00:39:14 -05:00
|
|
|
next()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
},
|
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 {
|
2022-02-19 01:47:54 -05:00
|
|
|
albums_list: new GroupByList(),
|
|
|
|
|
|
|
|
// List of group by/sort options for itemsGroupByList
|
|
|
|
groupby_options: [
|
|
|
|
{ name: 'Name', options: bySortName('name_sort') },
|
|
|
|
{
|
|
|
|
name: 'Recently added',
|
|
|
|
options: byYear('time_added', {
|
|
|
|
direction: 'desc',
|
|
|
|
defaultValue: '0000'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Recently released',
|
|
|
|
options: byYear('date_released', {
|
|
|
|
direction: 'desc',
|
|
|
|
defaultValue: '0000'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
]
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-02-19 01:47:54 -05:00
|
|
|
albums() {
|
|
|
|
const groupBy = this.groupby_options.find(
|
|
|
|
(o) => o.name === this.selected_groupby_option_name
|
|
|
|
)
|
|
|
|
this.albums_list.group(groupBy.options, [
|
2022-03-20 10:22:31 -04:00
|
|
|
(album) => !this.hide_singles || album.track_count > 2,
|
2022-02-19 01:47:54 -05:00
|
|
|
(album) => !this.hide_spotify || album.data_kind !== 'spotify'
|
|
|
|
])
|
|
|
|
|
|
|
|
return this.albums_list
|
|
|
|
},
|
|
|
|
|
|
|
|
groupby_option_names() {
|
|
|
|
return [...this.groupby_options].map((o) => o.name)
|
|
|
|
},
|
|
|
|
|
|
|
|
selected_groupby_option_name: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.albums_sort
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
this.$store.commit(types.ALBUMS_SORT, value)
|
|
|
|
}
|
2020-04-11 13:43:53 -04:00
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
spotify_enabled() {
|
2020-10-11 03:01:34 -04:00
|
|
|
return this.$store.state.spotify.webapi_token_valid
|
|
|
|
},
|
|
|
|
|
2020-10-08 00:01:17 -04:00
|
|
|
hide_singles: {
|
2022-02-19 00:39:14 -05:00
|
|
|
get() {
|
2020-10-08 00:01:17 -04:00
|
|
|
return this.$store.state.hide_singles
|
|
|
|
},
|
2022-02-19 00:39:14 -05:00
|
|
|
set(value) {
|
2020-10-08 00:01:17 -04:00
|
|
|
this.$store.commit(types.HIDE_SINGLES, value)
|
2020-09-20 11:59:46 -04:00
|
|
|
}
|
2020-10-08 00:01:17 -04:00
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
|
2020-10-08 00:01:17 -04:00
|
|
|
hide_spotify: {
|
2022-02-19 00:39:14 -05:00
|
|
|
get() {
|
2020-10-08 00:01:17 -04:00
|
|
|
return this.$store.state.hide_spotify
|
|
|
|
},
|
2022-02-19 00:39:14 -05:00
|
|
|
set(value) {
|
2020-10-08 00:01:17 -04:00
|
|
|
this.$store.commit(types.HIDE_SPOTIFY, value)
|
|
|
|
}
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
2018-12-16 03:17:43 -05:00
|
|
|
},
|
|
|
|
|
2020-10-08 00:01:17 -04:00
|
|
|
methods: {
|
|
|
|
scrollToTop: function () {
|
|
|
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
2018-12-16 03:17:43 -05:00
|
|
|
}
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
<style></style>
|