2018-12-23 10:34:46 +01:00
|
|
|
<template>
|
2023-06-23 22:23:32 +02:00
|
|
|
<div class="fd-page">
|
2018-12-23 10:34:46 +01:00
|
|
|
<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-29 18:49:00 +02:00
|
|
|
<a
|
|
|
|
class="button is-small is-light is-rounded"
|
2022-06-05 20:24:52 +02:00
|
|
|
@click="show_details_modal = true"
|
2022-05-29 18:49:00 +02:00
|
|
|
>
|
2023-06-30 21:41:40 +02:00
|
|
|
<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">
|
2023-06-30 21:41:40 +02:00
|
|
|
<mdicon class="icon" name="play" size="16" />
|
2022-05-20 13:44:22 +02:00
|
|
|
<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>
|
2023-03-24 04:17:17 +01:00
|
|
|
<list-directories :directories="dirs" />
|
|
|
|
<list-playlists :playlists="playlists" />
|
2022-05-29 18:49:00 +02:00
|
|
|
<list-tracks
|
2023-03-24 04:17:17 +01:00
|
|
|
:tracks="tracks"
|
2022-05-29 18:49:00 +02:00
|
|
|
:expression="play_expression"
|
|
|
|
:show_icon="true"
|
|
|
|
/>
|
|
|
|
<modal-dialog-directory
|
2022-06-05 20:24:52 +02:00
|
|
|
:show="show_details_modal"
|
2023-03-24 04:17:17 +01:00
|
|
|
:directory="current_directory"
|
2022-06-05 20:24:52 +02:00
|
|
|
@close="show_details_modal = false"
|
2022-05-29 18:49:00 +02:00
|
|
|
/>
|
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'
|
2023-07-18 15:48:56 +02:00
|
|
|
import { GroupByList } from '@/lib/GroupByList'
|
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'
|
2022-06-05 20:24:52 +02:00
|
|
|
import ModalDialogDirectory from '@/components/ModalDialogDirectory.vue'
|
2018-12-23 10:34:46 +01: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) {
|
2018-12-23 10:34:46 +01:00
|
|
|
if (to.query.directory) {
|
|
|
|
return webapi.library_files(to.query.directory)
|
|
|
|
}
|
|
|
|
return Promise.resolve()
|
|
|
|
},
|
|
|
|
|
2023-06-07 21:25:54 +02:00
|
|
|
set(vm, response) {
|
2018-12-23 10:34:46 +01:00
|
|
|
if (response) {
|
2023-03-24 04:17:17 +01:00
|
|
|
vm.dirs = response.data.directories
|
|
|
|
vm.playlists = new GroupByList(response.data.playlists)
|
|
|
|
vm.tracks = new GroupByList(response.data.tracks)
|
2018-12-23 10:34:46 +01:00
|
|
|
} else {
|
2023-03-24 04:17:17 +01:00
|
|
|
vm.dirs = vm.$store.state.config.directories.map((dir) => {
|
|
|
|
return { path: dir }
|
|
|
|
})
|
|
|
|
vm.playlists = new GroupByList()
|
|
|
|
vm.tracks = new GroupByList()
|
2018-12-23 10:34:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageFiles',
|
2022-02-19 06:39:14 +01:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
2022-02-19 07:47:54 +01:00
|
|
|
ListDirectories,
|
|
|
|
ListPlaylists,
|
2022-06-05 20:24:52 +02:00
|
|
|
ListTracks,
|
|
|
|
ModalDialogDirectory
|
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 {
|
2023-03-24 04:17:17 +01:00
|
|
|
dirs: [],
|
|
|
|
playlists: new GroupByList(),
|
|
|
|
tracks: new GroupByList(),
|
2022-06-05 20:24:52 +02:00
|
|
|
show_details_modal: false
|
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: {
|
2023-06-07 21:25:54 +02:00
|
|
|
play() {
|
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>
|