2018-12-23 10:34:46 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<content-with-heading>
|
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.files.title')" />
|
|
|
|
<p class="title is-7 has-text-grey" v-text="current_directory" />
|
2018-12-23 10:34:46 +01:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-right>
|
2019-02-17 11:24:30 +01:00
|
|
|
<div class="buttons is-centered">
|
2022-05-20 13:44:22 +02:00
|
|
|
<a class="button is-small is-light is-rounded" @click="open_directory_dialog({ path: current_directory })">
|
|
|
|
<mdicon class="icon" name="dots-horizontal" size="16"/>
|
2019-02-17 11:24:30 +01:00
|
|
|
</a>
|
|
|
|
<a class="button is-small is-dark is-rounded" @click="play">
|
2022-05-20 13:44:22 +02:00
|
|
|
<mdicon class="icon" name="play" size="16" />
|
|
|
|
<span v-text="$t('page.files.play')" />
|
2019-02-17 11:24:30 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
2018-12-23 10:34:46 +01:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
2022-02-19 07:47:54 +01:00
|
|
|
<list-directories :directories="files.directories" />
|
|
|
|
<list-playlists :playlists="files.playlists.items" />
|
2022-05-20 13:44:22 +02:00
|
|
|
<list-tracks :tracks="files.tracks.items" :expression="play_expression" :show_icon="true" />
|
|
|
|
<modal-dialog-directory :show="show_directory_details_modal" :directory="selected_directory" @close="show_directory_details_modal = false" />
|
2018-12-23 10:34:46 +01:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
2022-02-19 07:47:54 +01:00
|
|
|
import ListDirectories from '@/components/ListDirectories.vue'
|
|
|
|
import ListPlaylists from '@/components/ListPlaylists.vue'
|
|
|
|
import ListTracks from '@/components/ListTracks.vue'
|
2018-12-23 10:34:46 +01:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
const dataObject = {
|
2018-12-23 10:34:46 +01:00
|
|
|
load: function (to) {
|
|
|
|
if (to.query.directory) {
|
|
|
|
return webapi.library_files(to.query.directory)
|
|
|
|
}
|
|
|
|
return Promise.resolve()
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (vm, response) {
|
|
|
|
if (response) {
|
|
|
|
vm.files = response.data
|
|
|
|
} else {
|
|
|
|
vm.files = {
|
2022-02-19 06:39:14 +01:00
|
|
|
directories: vm.$store.state.config.directories.map((dir) => {
|
|
|
|
return { path: dir }
|
|
|
|
}),
|
2018-12-23 10:34:46 +01:00
|
|
|
tracks: { items: [] },
|
|
|
|
playlists: { items: [] }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageFiles',
|
2022-02-19 06:39:14 +01:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
2022-02-19 07:47:54 +01:00
|
|
|
ListDirectories,
|
|
|
|
ListPlaylists,
|
|
|
|
ListTracks
|
2022-02-19 06:39:14 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next((vm) => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
},
|
2018-12-23 10:34:46 +01:00
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
data() {
|
2018-12-23 10:34:46 +01:00
|
|
|
return {
|
2022-02-19 06:39:14 +01:00
|
|
|
files: {
|
|
|
|
directories: [],
|
|
|
|
tracks: { items: [] },
|
|
|
|
playlists: { items: [] }
|
2022-02-19 07:47:54 +01:00
|
|
|
}
|
2018-12-23 10:34:46 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-02-19 06:39:14 +01:00
|
|
|
current_directory() {
|
2018-12-23 10:34:46 +01:00
|
|
|
if (this.$route.query && this.$route.query.directory) {
|
|
|
|
return this.$route.query.directory
|
|
|
|
}
|
|
|
|
return '/'
|
2022-02-19 07:47:54 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
play_expression() {
|
|
|
|
return (
|
|
|
|
'path starts with "' + this.current_directory + '" order by path asc'
|
|
|
|
)
|
2018-12-23 10:34:46 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
play: function () {
|
2022-02-19 07:47:54 +01:00
|
|
|
webapi.player_play_expression(this.play_expression, false)
|
2018-12-23 10:34:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|