2021-08-19 01:31:19 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full my-2">
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="w-full bg-primary px-4 md:px-6 py-2 flex items-center cursor-pointer" @click.stop="clickBar">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="pr-2 md:pr-4">{{ $strings.HeaderLibraryFiles }}</p>
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="h-5 md:h-7 w-5 md:w-7 rounded-full bg-white bg-opacity-10 flex items-center justify-center">
|
2021-10-07 04:08:52 +02:00
|
|
|
<span class="text-sm font-mono">{{ files.length }}</span>
|
|
|
|
</div>
|
2021-08-19 01:31:19 +02:00
|
|
|
<div class="flex-grow" />
|
2023-04-09 23:10:03 +02:00
|
|
|
<ui-btn v-if="userIsAdmin" small :color="showFullPath ? 'gray-600' : 'primary'" class="mr-2 hidden md:block" @click.stop="showFullPath = !showFullPath">{{ $strings.ButtonFullPath }}</ui-btn>
|
2021-08-19 01:31:19 +02:00
|
|
|
<div class="cursor-pointer h-10 w-10 rounded-full hover:bg-black-400 flex justify-center items-center duration-500" :class="showFiles ? 'transform rotate-180' : ''">
|
|
|
|
<span class="material-icons text-4xl">expand_more</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<transition name="slide">
|
|
|
|
<div class="w-full" v-show="showFiles">
|
|
|
|
<table class="text-sm tracksTable">
|
2023-02-11 22:02:56 +01:00
|
|
|
<tr>
|
2022-11-08 01:27:17 +01:00
|
|
|
<th class="text-left px-4">{{ $strings.LabelPath }}</th>
|
|
|
|
<th class="text-left w-24 min-w-24">{{ $strings.LabelSize }}</th>
|
|
|
|
<th class="text-left px-4 w-24">{{ $strings.LabelType }}</th>
|
2023-04-16 01:09:49 +02:00
|
|
|
<th v-if="userCanDelete || userCanDownload || (userIsAdmin && audioFiles.length && !inModal)" class="text-center w-16"></th>
|
2021-08-19 01:31:19 +02:00
|
|
|
</tr>
|
2023-04-16 01:09:49 +02:00
|
|
|
<template v-for="file in filesWithAudioFile">
|
|
|
|
<tables-library-files-table-row :key="file.path" :libraryItemId="libraryItemId" :showFullPath="showFullPath" :file="file" :inModal="inModal" @showMore="showMore" />
|
2021-08-19 01:31:19 +02:00
|
|
|
</template>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</transition>
|
2023-04-16 01:09:49 +02:00
|
|
|
|
|
|
|
<modals-audio-file-data-modal v-model="showAudioFileDataModal" :audio-file="selectedAudioFile" />
|
2021-08-19 01:31:19 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2023-04-16 01:09:49 +02:00
|
|
|
libraryItem: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
2021-08-19 01:31:19 +02:00
|
|
|
},
|
2023-04-16 01:09:49 +02:00
|
|
|
expanded: Boolean, // start expanded
|
|
|
|
inModal: Boolean
|
2021-08-19 01:31:19 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-10-07 04:08:52 +02:00
|
|
|
showFiles: false,
|
2023-04-16 01:09:49 +02:00
|
|
|
showFullPath: false,
|
|
|
|
showAudioFileDataModal: false,
|
|
|
|
selectedAudioFile: null
|
2021-08-19 01:31:19 +02:00
|
|
|
}
|
|
|
|
},
|
2021-10-09 00:30:20 +02:00
|
|
|
computed: {
|
2023-04-16 01:09:49 +02:00
|
|
|
libraryItemId() {
|
|
|
|
return this.libraryItem.id
|
|
|
|
},
|
2021-10-09 00:30:20 +02:00
|
|
|
userToken() {
|
|
|
|
return this.$store.getters['user/getToken']
|
|
|
|
},
|
|
|
|
userCanDownload() {
|
|
|
|
return this.$store.getters['user/getUserCanDownload']
|
2023-04-09 23:10:03 +02:00
|
|
|
},
|
2023-04-14 01:03:39 +02:00
|
|
|
userCanDelete() {
|
|
|
|
return this.$store.getters['user/getUserCanDelete']
|
|
|
|
},
|
2023-04-09 23:10:03 +02:00
|
|
|
userIsAdmin() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
2023-04-16 01:09:49 +02:00
|
|
|
},
|
|
|
|
files() {
|
|
|
|
return this.libraryItem.libraryFiles || []
|
|
|
|
},
|
|
|
|
audioFiles() {
|
2023-04-30 16:45:28 +02:00
|
|
|
if (this.libraryItem.mediaType === 'podcast') {
|
|
|
|
return this.libraryItem.media?.episodes.map((ep) => ep.audioFile) || []
|
|
|
|
}
|
2023-04-16 01:09:49 +02:00
|
|
|
return this.libraryItem.media?.audioFiles || []
|
|
|
|
},
|
|
|
|
filesWithAudioFile() {
|
|
|
|
return this.files.map((file) => {
|
|
|
|
if (file.fileType === 'audio') {
|
|
|
|
file.audioFile = this.audioFiles.find((af) => af.ino === file.ino)
|
|
|
|
}
|
|
|
|
return file
|
|
|
|
})
|
2021-10-09 00:30:20 +02:00
|
|
|
}
|
|
|
|
},
|
2021-08-19 01:31:19 +02:00
|
|
|
methods: {
|
|
|
|
clickBar() {
|
|
|
|
this.showFiles = !this.showFiles
|
2023-04-16 01:09:49 +02:00
|
|
|
},
|
|
|
|
showMore(audioFile) {
|
|
|
|
this.selectedAudioFile = audioFile
|
|
|
|
this.showAudioFileDataModal = true
|
2021-08-19 01:31:19 +02:00
|
|
|
}
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
mounted() {
|
|
|
|
this.showFiles = this.expanded
|
|
|
|
}
|
2021-08-19 01:31:19 +02:00
|
|
|
}
|
|
|
|
</script>
|