2018-12-23 10:34:46 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2018-12-23 10:34:46 +01:00
|
|
|
<p class="title is-4">Files</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<p class="title is-7 has-text-grey">
|
|
|
|
{{ current_directory }}
|
|
|
|
</p>
|
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-02-19 06:39:14 +01:00
|
|
|
<a
|
|
|
|
class="button is-small is-light is-rounded"
|
|
|
|
@click="open_directory_dialog({ path: current_directory })"
|
|
|
|
>
|
|
|
|
<span class="icon"
|
|
|
|
><i class="mdi mdi-dots-horizontal mdi-18px"
|
|
|
|
/></span>
|
2019-02-17 11:24:30 +01:00
|
|
|
</a>
|
|
|
|
<a class="button is-small is-dark is-rounded" @click="play">
|
2022-02-19 06:39:14 +01:00
|
|
|
<span class="icon"><i class="mdi mdi-play" /></span>
|
|
|
|
<span>Play</span>
|
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>
|
|
|
|
<div
|
|
|
|
v-if="$route.query.directory"
|
|
|
|
class="media"
|
|
|
|
@click="open_parent_directory()"
|
|
|
|
>
|
2018-12-23 10:34:46 +01:00
|
|
|
<figure class="media-left fd-has-action">
|
|
|
|
<span class="icon">
|
2022-02-19 06:39:14 +01:00
|
|
|
<i class="mdi mdi-subdirectory-arrow-left" />
|
2018-12-23 10:34:46 +01:00
|
|
|
</span>
|
|
|
|
</figure>
|
|
|
|
<div class="media-content fd-has-action is-clipped">
|
|
|
|
<h1 class="title is-6">..</h1>
|
|
|
|
</div>
|
|
|
|
<div class="media-right">
|
2022-02-19 06:39:14 +01:00
|
|
|
<slot name="actions" />
|
2018-12-23 10:34:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<list-item-directory
|
|
|
|
v-for="directory in files.directories"
|
|
|
|
:key="directory.path"
|
|
|
|
:directory="directory"
|
|
|
|
@click="open_directory(directory)"
|
|
|
|
>
|
|
|
|
<template #actions>
|
|
|
|
<a @click="open_directory_dialog(directory)">
|
|
|
|
<span class="icon has-text-dark"
|
|
|
|
><i class="mdi mdi-dots-vertical mdi-18px"
|
|
|
|
/></span>
|
|
|
|
</a>
|
|
|
|
</template>
|
2018-12-23 10:34:46 +01:00
|
|
|
</list-item-directory>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<list-item-playlist
|
|
|
|
v-for="playlist in files.playlists.items"
|
|
|
|
:key="playlist.id"
|
|
|
|
:playlist="playlist"
|
|
|
|
@click="open_playlist(playlist)"
|
|
|
|
>
|
|
|
|
<template #icon>
|
2018-12-23 10:34:46 +01:00
|
|
|
<span class="icon">
|
2022-02-19 06:39:14 +01:00
|
|
|
<i class="mdi mdi-library-music" />
|
2018-12-23 10:34:46 +01:00
|
|
|
</span>
|
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #actions>
|
2018-12-23 10:34:46 +01:00
|
|
|
<a @click="open_playlist_dialog(playlist)">
|
2022-02-19 06:39:14 +01:00
|
|
|
<span class="icon has-text-dark"
|
|
|
|
><i class="mdi mdi-dots-vertical mdi-18px"
|
|
|
|
/></span>
|
2018-12-23 10:34:46 +01:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</list-item-playlist>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<list-item-track
|
|
|
|
v-for="(track, index) in files.tracks.items"
|
|
|
|
:key="track.id"
|
|
|
|
:track="track"
|
|
|
|
@click="play_track(index)"
|
|
|
|
>
|
|
|
|
<template #icon>
|
2018-12-23 10:34:46 +01:00
|
|
|
<span class="icon">
|
2022-02-19 06:39:14 +01:00
|
|
|
<i class="mdi mdi-file-outline" />
|
2018-12-23 10:34:46 +01:00
|
|
|
</span>
|
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #actions>
|
2018-12-23 10:34:46 +01:00
|
|
|
<a @click="open_track_dialog(track)">
|
2022-02-19 06:39:14 +01:00
|
|
|
<span class="icon has-text-dark"
|
|
|
|
><i class="mdi mdi-dots-vertical mdi-18px"
|
|
|
|
/></span>
|
2018-12-23 10:34:46 +01:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</list-item-track>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<modal-dialog-directory
|
|
|
|
:show="show_directory_details_modal"
|
|
|
|
:directory="selected_directory"
|
|
|
|
@close="show_directory_details_modal = false"
|
|
|
|
/>
|
|
|
|
<modal-dialog-playlist
|
|
|
|
:show="show_playlist_details_modal"
|
|
|
|
:playlist="selected_playlist"
|
|
|
|
@close="show_playlist_details_modal = false"
|
|
|
|
/>
|
|
|
|
<modal-dialog-track
|
|
|
|
:show="show_track_details_modal"
|
|
|
|
:track="selected_track"
|
|
|
|
@close="show_track_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'
|
|
|
|
import ListItemDirectory from '@/components/ListItemDirectory.vue'
|
|
|
|
import ListItemPlaylist from '@/components/ListItemPlaylist.vue'
|
|
|
|
import ListItemTrack from '@/components/ListItemTrack.vue'
|
|
|
|
import ModalDialogDirectory from '@/components/ModalDialogDirectory.vue'
|
|
|
|
import ModalDialogPlaylist from '@/components/ModalDialogPlaylist.vue'
|
|
|
|
import ModalDialogTrack from '@/components/ModalDialogTrack.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,
|
|
|
|
ListItemDirectory,
|
|
|
|
ListItemPlaylist,
|
|
|
|
ListItemTrack,
|
|
|
|
ModalDialogDirectory,
|
|
|
|
ModalDialogPlaylist,
|
|
|
|
ModalDialogTrack
|
|
|
|
},
|
|
|
|
|
|
|
|
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: [] }
|
|
|
|
},
|
2018-12-23 10:34:46 +01:00
|
|
|
|
|
|
|
show_directory_details_modal: false,
|
|
|
|
selected_directory: {},
|
|
|
|
|
|
|
|
show_playlist_details_modal: false,
|
|
|
|
selected_playlist: {},
|
|
|
|
|
|
|
|
show_track_details_modal: false,
|
|
|
|
selected_track: {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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 '/'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
open_parent_directory: function () {
|
2022-02-19 06:39:14 +01:00
|
|
|
const parent = this.current_directory.slice(
|
|
|
|
0,
|
|
|
|
this.current_directory.lastIndexOf('/')
|
|
|
|
)
|
|
|
|
if (
|
|
|
|
parent === '' ||
|
|
|
|
this.$store.state.config.directories.includes(this.current_directory)
|
|
|
|
) {
|
2018-12-23 10:34:46 +01:00
|
|
|
this.$router.push({ path: '/files' })
|
|
|
|
} else {
|
2022-02-19 06:39:14 +01:00
|
|
|
this.$router.push({
|
|
|
|
path: '/files',
|
|
|
|
query: {
|
|
|
|
directory: this.current_directory.slice(
|
|
|
|
0,
|
|
|
|
this.current_directory.lastIndexOf('/')
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
2018-12-23 10:34:46 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
open_directory: function (directory) {
|
2022-02-19 06:39:14 +01:00
|
|
|
this.$router.push({
|
|
|
|
path: '/files',
|
|
|
|
query: { directory: directory.path }
|
|
|
|
})
|
2018-12-23 10:34:46 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
open_directory_dialog: function (directory) {
|
|
|
|
this.selected_directory = directory
|
|
|
|
this.show_directory_details_modal = true
|
|
|
|
},
|
|
|
|
|
|
|
|
play: function () {
|
2022-02-19 06:39:14 +01:00
|
|
|
webapi.player_play_expression(
|
|
|
|
'path starts with "' + this.current_directory + '" order by path asc',
|
|
|
|
false
|
|
|
|
)
|
2018-12-23 10:34:46 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
play_track: function (position) {
|
2022-02-19 06:39:14 +01:00
|
|
|
webapi.player_play_uri(
|
|
|
|
this.files.tracks.items.map((a) => a.uri).join(','),
|
|
|
|
false,
|
|
|
|
position
|
|
|
|
)
|
2018-12-23 10:34:46 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
open_track_dialog: function (track) {
|
|
|
|
this.selected_track = track
|
|
|
|
this.show_track_details_modal = true
|
|
|
|
},
|
|
|
|
|
|
|
|
open_playlist: function (playlist) {
|
2020-03-08 11:56:19 +01:00
|
|
|
this.$router.push({ path: '/playlists/' + playlist.id + '/tracks' })
|
2018-12-23 10:34:46 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
open_playlist_dialog: function (playlist) {
|
|
|
|
this.selected_playlist = playlist
|
|
|
|
this.show_playlist_details_modal = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|