2022-04-06 20:36:17 -05:00
|
|
|
<template>
|
2022-04-10 20:31:47 -05:00
|
|
|
<div class="w-full h-full py-6 px-2">
|
2023-02-17 16:07:37 -06:00
|
|
|
<div v-if="localLibraryItem" class="w-full h-full">
|
2022-04-10 20:31:47 -05:00
|
|
|
<div class="px-2 flex items-center mb-2">
|
2023-02-12 12:16:38 -06:00
|
|
|
<p class="text-basefont-semibold">{{ mediaMetadata.title }}</p>
|
2022-04-08 18:07:31 -05:00
|
|
|
<div class="flex-grow" />
|
|
|
|
|
2022-04-10 20:31:47 -05:00
|
|
|
<button v-if="audioTracks.length && !isPodcast" class="shadow-sm text-accent flex items-center justify-center rounded-full mx-2" @click.stop="play">
|
2022-04-06 20:36:17 -05:00
|
|
|
<span class="material-icons" style="font-size: 2rem">play_arrow</span>
|
|
|
|
</button>
|
2022-04-08 18:07:31 -05:00
|
|
|
<span class="material-icons" @click="showItemDialog">more_vert</span>
|
2022-04-06 20:36:17 -05:00
|
|
|
</div>
|
2022-04-07 18:46:58 -05:00
|
|
|
|
2022-08-11 13:16:25 -04:00
|
|
|
<p v-if="!isIos" class="px-2 text-sm mb-0.5 text-white text-opacity-75">Folder: {{ folderName }}</p>
|
2022-04-08 18:07:31 -05:00
|
|
|
|
2022-04-10 20:31:47 -05:00
|
|
|
<p class="px-2 mb-4 text-xs text-gray-400">{{ libraryItemId ? 'Linked to item on server ' + liServerAddress : 'Not linked to server item' }}</p>
|
2022-04-07 18:46:58 -05:00
|
|
|
|
2022-04-06 20:36:17 -05:00
|
|
|
<div v-if="isScanning" class="w-full text-center p-4">
|
|
|
|
<p>Scanning...</p>
|
|
|
|
</div>
|
2023-05-25 17:59:24 -05:00
|
|
|
<div v-else class="w-full max-w-full media-item-container overflow-y-auto overflow-x-hidden relative pb-4" :class="{ 'media-order-changed': orderChanged }">
|
|
|
|
<div v-if="!isPodcast && audioTracksCopy.length" class="w-full py-2">
|
2022-04-10 20:31:47 -05:00
|
|
|
<p class="text-base mb-2">Audio Tracks ({{ audioTracks.length }})</p>
|
2022-04-13 20:24:54 -05:00
|
|
|
|
2022-08-11 16:39:59 -04:00
|
|
|
<draggable v-model="audioTracksCopy" v-bind="dragOptions" handle=".drag-handle" draggable=".item" tag="div" @start="drag = true" @end="drag = false" @update="draggableUpdate" :disabled="isIos">
|
2022-04-13 20:24:54 -05:00
|
|
|
<transition-group type="transition" :name="!drag ? 'dragtrack' : null">
|
|
|
|
<template v-for="track in audioTracksCopy">
|
|
|
|
<div :key="track.localFileId" class="flex items-center my-1 item">
|
2022-08-11 16:39:59 -04:00
|
|
|
<div v-if="!isIos" class="w-8 h-12 flex items-center justify-center" style="min-width: 32px">
|
2022-04-13 20:24:54 -05:00
|
|
|
<span class="material-icons drag-handle text-lg text-white text-opacity-50 hover:text-opacity-100">menu</span>
|
|
|
|
</div>
|
|
|
|
<div class="w-8 h-12 flex items-center justify-center" style="min-width: 32px">
|
|
|
|
<p class="font-mono font-bold text-xl">{{ track.index }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow px-2">
|
|
|
|
<p class="text-xs">{{ track.title }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="w-20 text-center text-gray-300" style="min-width: 80px">
|
|
|
|
<p class="text-xs">{{ track.mimeType }}</p>
|
|
|
|
<p class="text-sm">{{ $elapsedPretty(track.duration) }}</p>
|
|
|
|
</div>
|
2022-08-11 16:39:59 -04:00
|
|
|
<div v-if="!isIos" class="w-12 h-12 flex items-center justify-center" style="min-width: 48px">
|
2022-04-13 20:24:54 -05:00
|
|
|
<span class="material-icons" @click="showTrackDialog(track)">more_vert</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</transition-group>
|
|
|
|
</draggable>
|
2022-04-10 20:31:47 -05:00
|
|
|
</div>
|
2023-05-25 17:59:24 -05:00
|
|
|
|
|
|
|
<div v-if="isPodcast" class="w-full py-2">
|
2022-04-15 20:48:39 -05:00
|
|
|
<p class="text-base mb-2">Episodes ({{ episodes.length }})</p>
|
|
|
|
<template v-for="episode in episodes">
|
2022-04-10 20:31:47 -05:00
|
|
|
<div :key="episode.id" class="flex items-center my-1">
|
|
|
|
<div class="w-10 h-12 flex items-center justify-center" style="min-width: 48px">
|
|
|
|
<p class="font-mono font-bold text-xl">{{ episode.index }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow px-2">
|
|
|
|
<p class="text-xs">{{ episode.title }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="w-20 text-center text-gray-300" style="min-width: 80px">
|
|
|
|
<p class="text-xs">{{ episode.audioTrack.mimeType }}</p>
|
|
|
|
<p class="text-sm">{{ $elapsedPretty(episode.audioTrack.duration) }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="w-12 h-12 flex items-center justify-center" style="min-width: 48px">
|
|
|
|
<span class="material-icons" @click="showTrackDialog(episode)">more_vert</span>
|
|
|
|
</div>
|
2022-04-06 20:36:17 -05:00
|
|
|
</div>
|
2022-04-10 20:31:47 -05:00
|
|
|
</template>
|
|
|
|
</div>
|
2022-04-06 20:36:17 -05:00
|
|
|
|
2023-05-25 17:59:24 -05:00
|
|
|
<div v-if="localFileForEbook" class="w-full py-2">
|
|
|
|
<p class="text-base mb-2">EBook File</p>
|
|
|
|
|
|
|
|
<div class="flex items-center my-1">
|
|
|
|
<div class="w-10 h-12 flex items-center justify-center" style="min-width: 40px">
|
|
|
|
<p class="font-mono font-bold text-sm">{{ ebookFile.ebookFormat }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow px-2">
|
|
|
|
<p class="text-xs">{{ localFileForEbook.filename }}</p>
|
|
|
|
</div>
|
|
|
|
<div class="w-24 text-center text-gray-300" style="min-width: 96px">
|
|
|
|
<p class="text-xs">{{ localFileForEbook.mimeType }}</p>
|
|
|
|
<p class="text-sm">{{ $bytesPretty(localFileForEbook.size) }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<p v-if="otherFiles.length" class="text-lg py-2">Other Files</p>
|
2022-04-08 18:07:31 -05:00
|
|
|
<template v-for="file in otherFiles">
|
2022-04-06 20:36:17 -05:00
|
|
|
<div :key="file.id" class="flex items-center my-1">
|
|
|
|
<div class="w-12 h-12 flex items-center justify-center">
|
|
|
|
<img v-if="(file.mimeType || '').startsWith('image')" :src="getCapImageSrc(file.contentUrl)" class="w-full h-full object-contain" />
|
|
|
|
<span v-else class="material-icons">music_note</span>
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow px-2">
|
|
|
|
<p class="text-sm">{{ file.filename }}</p>
|
|
|
|
</div>
|
2023-05-25 17:59:24 -05:00
|
|
|
<div class="w-24 text-center text-gray-300" style="min-width: 96px">
|
2022-04-06 20:36:17 -05:00
|
|
|
<p class="text-xs">{{ file.mimeType }}</p>
|
|
|
|
<p class="text-sm">{{ $bytesPretty(file.size) }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-04-10 20:31:47 -05:00
|
|
|
<div v-else class="px-2 w-full h-full">
|
2022-04-06 20:36:17 -05:00
|
|
|
<p class="text-lg text-center px-8">{{ failed ? 'Failed to get local library item ' + localLibraryItemId : 'Loading..' }}</p>
|
|
|
|
</div>
|
2022-04-08 18:07:31 -05:00
|
|
|
|
2023-06-19 12:37:44 -05:00
|
|
|
<div v-if="orderChanged" class="fixed left-0 w-full py-4 px-4 bg-bg box-shadow-book flex items-center" :style="{ bottom: isPlayerOpen ? '120px' : '0px' }">
|
2022-04-15 20:48:39 -05:00
|
|
|
<div class="flex-grow" />
|
|
|
|
<ui-btn small color="success" @click="saveTrackOrder">Save Order</ui-btn>
|
|
|
|
</div>
|
|
|
|
|
2022-04-08 18:07:31 -05:00
|
|
|
<modals-dialog v-model="showDialog" :items="dialogItems" @action="dialogAction" />
|
2022-04-06 20:36:17 -05:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-13 20:24:54 -05:00
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
2022-04-06 20:36:17 -05:00
|
|
|
import { Capacitor } from '@capacitor/core'
|
|
|
|
import { Dialog } from '@capacitor/dialog'
|
|
|
|
import { AbsFileSystem } from '@/plugins/capacitor'
|
|
|
|
|
|
|
|
export default {
|
2022-04-13 20:24:54 -05:00
|
|
|
components: {
|
|
|
|
draggable
|
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
asyncData({ params }) {
|
|
|
|
return {
|
|
|
|
localLibraryItemId: params.id
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-04-13 20:24:54 -05:00
|
|
|
drag: false,
|
|
|
|
dragOptions: {
|
|
|
|
animation: 200,
|
|
|
|
group: 'description',
|
|
|
|
delay: 40,
|
|
|
|
delayOnTouchOnly: true
|
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
failed: false,
|
|
|
|
localLibraryItem: null,
|
2022-04-13 20:24:54 -05:00
|
|
|
audioTracksCopy: [],
|
2022-04-06 20:36:17 -05:00
|
|
|
removingItem: false,
|
|
|
|
folderId: null,
|
|
|
|
folder: null,
|
2022-04-08 18:07:31 -05:00
|
|
|
isScanning: false,
|
|
|
|
showDialog: false,
|
2022-04-10 20:31:47 -05:00
|
|
|
selectedAudioTrack: null,
|
2022-04-15 20:48:39 -05:00
|
|
|
selectedEpisode: null,
|
|
|
|
orderChanged: false
|
2022-04-06 20:36:17 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2023-06-19 12:37:44 -05:00
|
|
|
isPlayerOpen() {
|
|
|
|
return this.$store.getters['getIsPlayerOpen']
|
2022-12-04 15:04:46 -06:00
|
|
|
},
|
2022-08-11 13:16:25 -04:00
|
|
|
isIos() {
|
|
|
|
return this.$platform === 'ios'
|
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
basePath() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.localLibraryItem?.basePath
|
2022-04-08 18:07:31 -05:00
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
localFiles() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.localLibraryItem?.localFiles || []
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
otherFiles() {
|
|
|
|
if (!this.localFiles.filter) {
|
|
|
|
console.error('Invalid local files', this.localFiles)
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
return this.localFiles.filter((lf) => {
|
2023-05-25 17:59:24 -05:00
|
|
|
if (this.localFileForEbook?.id === lf.id) return false
|
2022-04-08 18:07:31 -05:00
|
|
|
return !this.audioTracks.find((at) => at.localFileId == lf.id)
|
|
|
|
})
|
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
folderName() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.folder?.name
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
2023-06-03 17:24:32 -05:00
|
|
|
isInternalStorage() {
|
|
|
|
return this.folderId?.startsWith('internal-')
|
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
mediaType() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.localLibraryItem?.mediaType
|
2022-04-07 18:46:58 -05:00
|
|
|
},
|
2022-04-10 20:31:47 -05:00
|
|
|
isPodcast() {
|
|
|
|
return this.mediaType == 'podcast'
|
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
libraryItemId() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.localLibraryItem?.libraryItemId
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
liServerAddress() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.localLibraryItem?.serverAddress
|
2022-04-08 18:07:31 -05:00
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
media() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.localLibraryItem?.media
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
|
|
|
mediaMetadata() {
|
2023-05-25 17:59:24 -05:00
|
|
|
return this.media?.metadata || {}
|
|
|
|
},
|
|
|
|
ebookFile() {
|
|
|
|
return this.media?.ebookFile
|
|
|
|
},
|
|
|
|
localFileForEbook() {
|
|
|
|
if (!this.ebookFile) return null
|
|
|
|
return this.localFiles.find((lf) => lf.id == this.ebookFile.localFileId)
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
2022-04-15 20:48:39 -05:00
|
|
|
episodes() {
|
|
|
|
return this.media.episodes || []
|
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
audioTracks() {
|
|
|
|
if (!this.media) return []
|
|
|
|
if (this.mediaType == 'book') {
|
|
|
|
return this.media.tracks || []
|
|
|
|
} else {
|
2022-04-15 20:48:39 -05:00
|
|
|
return (this.media.episodes || []).map((ep) => ep.audioTrack)
|
2022-04-06 20:36:17 -05:00
|
|
|
}
|
2022-04-08 18:07:31 -05:00
|
|
|
},
|
|
|
|
dialogItems() {
|
2022-04-15 20:48:39 -05:00
|
|
|
if (this.selectedAudioTrack || this.selectedEpisode) {
|
2022-04-08 18:07:31 -05:00
|
|
|
return [
|
|
|
|
{
|
2023-06-17 12:49:24 -05:00
|
|
|
text: 'Delete local file',
|
2022-04-08 18:07:31 -05:00
|
|
|
value: 'track-delete'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
} else {
|
2022-08-11 13:16:25 -04:00
|
|
|
var options = []
|
2023-06-17 12:49:24 -05:00
|
|
|
if (!this.isIos && !this.isInternalStorage && !this.libraryItemId) {
|
2022-12-04 15:04:46 -06:00
|
|
|
options.push({ text: 'Scan', value: 'scan' })
|
|
|
|
options.push({ text: 'Force Re-Scan', value: 'rescan' })
|
2022-08-11 13:16:25 -04:00
|
|
|
}
|
2023-06-17 12:49:24 -05:00
|
|
|
options.push({ text: 'Delete local item', value: 'delete' })
|
2022-08-11 13:16:25 -04:00
|
|
|
return options
|
2022-04-08 18:07:31 -05:00
|
|
|
}
|
2022-04-06 20:36:17 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-04-13 20:24:54 -05:00
|
|
|
draggableUpdate() {
|
2022-04-15 20:48:39 -05:00
|
|
|
console.log('Draggable Update')
|
|
|
|
for (let i = 0; i < this.audioTracksCopy.length; i++) {
|
|
|
|
var trackCopy = this.audioTracksCopy[i]
|
|
|
|
var track = this.audioTracks[i]
|
|
|
|
if (track.localFileId !== trackCopy.localFileId) {
|
|
|
|
this.orderChanged = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.orderChanged = false
|
|
|
|
},
|
|
|
|
async saveTrackOrder() {
|
|
|
|
var copyOfCopy = this.audioTracksCopy.map((at) => ({ ...at }))
|
|
|
|
const payload = {
|
|
|
|
localLibraryItemId: this.localLibraryItemId,
|
|
|
|
tracks: copyOfCopy
|
|
|
|
}
|
|
|
|
var response = await this.$db.updateLocalTrackOrder(payload)
|
|
|
|
if (response) {
|
|
|
|
this.$toast.success('Library item updated')
|
|
|
|
console.log('updateLocal track order response', JSON.stringify(response))
|
|
|
|
this.localLibraryItem = response
|
|
|
|
this.audioTracksCopy = this.audioTracks.map((at) => ({ ...at }))
|
|
|
|
} else {
|
|
|
|
this.$toast.info(`No updates necessary`)
|
|
|
|
}
|
|
|
|
this.orderChanged = false
|
2022-04-13 20:24:54 -05:00
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
showItemDialog() {
|
|
|
|
this.selectedAudioTrack = null
|
2023-06-04 14:59:55 -05:00
|
|
|
this.selectedEpisode = null
|
2022-04-08 18:07:31 -05:00
|
|
|
this.showDialog = true
|
|
|
|
},
|
|
|
|
showTrackDialog(track) {
|
2022-04-10 20:31:47 -05:00
|
|
|
if (this.isPodcast) {
|
|
|
|
this.selectedAudioTrack = null
|
|
|
|
this.selectedEpisode = track
|
|
|
|
} else {
|
|
|
|
this.selectedEpisode = null
|
|
|
|
this.selectedAudioTrack = track
|
|
|
|
}
|
2022-04-08 18:07:31 -05:00
|
|
|
this.showDialog = true
|
|
|
|
},
|
2022-12-08 00:28:28 -05:00
|
|
|
async play() {
|
2023-01-08 15:32:15 -06:00
|
|
|
await this.$hapticsImpact()
|
2022-04-10 20:31:47 -05:00
|
|
|
this.$eventBus.$emit('play-item', { libraryItemId: this.localLibraryItemId })
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
|
|
|
getCapImageSrc(contentUrl) {
|
|
|
|
return Capacitor.convertFileSrc(contentUrl)
|
|
|
|
},
|
2022-12-08 00:28:28 -05:00
|
|
|
async dialogAction(action) {
|
2022-04-08 18:07:31 -05:00
|
|
|
console.log('Dialog action', action)
|
2023-01-08 15:32:15 -06:00
|
|
|
await this.$hapticsImpact()
|
2023-06-17 12:49:24 -05:00
|
|
|
|
2022-04-08 18:07:31 -05:00
|
|
|
if (action == 'scan') {
|
|
|
|
this.scanItem()
|
|
|
|
} else if (action == 'rescan') {
|
|
|
|
this.scanItem(true)
|
|
|
|
} else if (action == 'delete') {
|
|
|
|
this.deleteItem()
|
|
|
|
} else if (action == 'track-delete') {
|
2022-04-10 20:31:47 -05:00
|
|
|
if (this.isPodcast) this.deleteEpisode()
|
|
|
|
else this.deleteTrack()
|
2022-04-08 18:07:31 -05:00
|
|
|
}
|
|
|
|
this.showDialog = false
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
getLocalFileForTrack(localFileId) {
|
|
|
|
return this.localFiles.find((lf) => lf.id == localFileId)
|
2022-04-06 20:36:17 -05:00
|
|
|
},
|
2022-04-10 20:31:47 -05:00
|
|
|
async deleteEpisode() {
|
|
|
|
if (!this.selectedEpisode) return
|
|
|
|
var localFile = this.getLocalFileForTrack(this.selectedEpisode.audioTrack.localFileId)
|
|
|
|
if (!localFile) {
|
|
|
|
this.$toast.error('Audio track does not have matching local file..')
|
|
|
|
return
|
|
|
|
}
|
2023-06-17 12:49:24 -05:00
|
|
|
|
|
|
|
let confirmMessage = `Remove local audio file "${localFile.basePath}" from your device?`
|
|
|
|
if (this.libraryItemId) {
|
|
|
|
confirmMessage += ' The file on the server will be unaffected.'
|
|
|
|
}
|
2022-04-10 20:31:47 -05:00
|
|
|
const { value } = await Dialog.confirm({
|
|
|
|
title: 'Confirm',
|
2023-06-17 12:49:24 -05:00
|
|
|
message: confirmMessage
|
2022-04-10 20:31:47 -05:00
|
|
|
})
|
|
|
|
if (value) {
|
|
|
|
var res = await AbsFileSystem.deleteTrackFromItem({ id: this.localLibraryItem.id, trackLocalFileId: localFile.id, trackContentUrl: this.selectedEpisode.audioTrack.contentUrl })
|
|
|
|
if (res && res.id) {
|
|
|
|
this.$toast.success('Deleted track successfully')
|
|
|
|
this.localLibraryItem = res
|
|
|
|
} else this.$toast.error('Failed to delete')
|
|
|
|
}
|
|
|
|
},
|
2022-04-08 18:07:31 -05:00
|
|
|
async deleteTrack() {
|
|
|
|
if (!this.selectedAudioTrack) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var localFile = this.getLocalFileForTrack(this.selectedAudioTrack.localFileId)
|
|
|
|
if (!localFile) {
|
|
|
|
this.$toast.error('Audio track does not have matching local file..')
|
|
|
|
return
|
|
|
|
}
|
2023-06-17 12:49:24 -05:00
|
|
|
|
|
|
|
let confirmMessage = `Remove local audio file "${localFile.basePath}" from your device?`
|
|
|
|
if (this.libraryItemId) {
|
|
|
|
confirmMessage += ' The file on the server will be unaffected.'
|
|
|
|
}
|
2022-04-08 18:07:31 -05:00
|
|
|
const { value } = await Dialog.confirm({
|
|
|
|
title: 'Confirm',
|
2023-06-17 12:49:24 -05:00
|
|
|
message: confirmMessage
|
2022-04-08 18:07:31 -05:00
|
|
|
})
|
|
|
|
if (value) {
|
|
|
|
var res = await AbsFileSystem.deleteTrackFromItem({ id: this.localLibraryItem.id, trackLocalFileId: this.selectedAudioTrack.localFileId, trackContentUrl: this.selectedAudioTrack.contentUrl })
|
|
|
|
if (res && res.id) {
|
|
|
|
this.$toast.success('Deleted track successfully')
|
|
|
|
this.localLibraryItem = res
|
|
|
|
} else this.$toast.error('Failed to delete')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async deleteItem() {
|
2023-06-17 12:49:24 -05:00
|
|
|
let confirmMessage = 'Remove local files of this item from your device?'
|
|
|
|
if (this.libraryItemId) {
|
|
|
|
confirmMessage += ' The files on the server and your progress will be unaffected.'
|
|
|
|
}
|
2022-04-08 18:07:31 -05:00
|
|
|
const { value } = await Dialog.confirm({
|
|
|
|
title: 'Confirm',
|
2023-06-17 12:49:24 -05:00
|
|
|
message: confirmMessage
|
2022-04-08 18:07:31 -05:00
|
|
|
})
|
|
|
|
if (value) {
|
|
|
|
var res = await AbsFileSystem.deleteItem(this.localLibraryItem)
|
|
|
|
if (res && res.success) {
|
|
|
|
this.$toast.success('Deleted Successfully')
|
2023-06-20 16:34:44 -05:00
|
|
|
this.$router.replace(this.isIos ? '/downloads' : `/localMedia/folders/${this.folderId}`)
|
2022-04-08 18:07:31 -05:00
|
|
|
} else this.$toast.error('Failed to delete')
|
|
|
|
}
|
|
|
|
},
|
2022-04-06 20:36:17 -05:00
|
|
|
async scanItem(forceAudioProbe = false) {
|
2022-04-08 18:07:31 -05:00
|
|
|
if (this.isScanning) return
|
|
|
|
|
2022-04-06 20:36:17 -05:00
|
|
|
this.isScanning = true
|
|
|
|
var response = await AbsFileSystem.scanLocalLibraryItem({ localLibraryItemId: this.localLibraryItemId, forceAudioProbe })
|
|
|
|
|
|
|
|
if (response && response.localLibraryItem) {
|
|
|
|
if (response.updated) {
|
|
|
|
this.$toast.success('Local item was updated')
|
|
|
|
this.localLibraryItem = response.localLibraryItem
|
|
|
|
} else {
|
|
|
|
this.$toast.info('Local item was up to date')
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log('Failed')
|
|
|
|
this.$toast.error('Something went wrong..')
|
|
|
|
}
|
|
|
|
this.isScanning = false
|
|
|
|
},
|
|
|
|
async init() {
|
|
|
|
this.localLibraryItem = await this.$db.getLocalLibraryItem(this.localLibraryItemId)
|
2022-04-08 18:07:31 -05:00
|
|
|
|
2022-04-06 20:36:17 -05:00
|
|
|
if (!this.localLibraryItem) {
|
|
|
|
console.error('Failed to get local library item', this.localLibraryItemId)
|
|
|
|
this.failed = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-13 20:24:54 -05:00
|
|
|
this.audioTracksCopy = this.audioTracks.map((at) => ({ ...at }))
|
|
|
|
|
2022-04-06 20:36:17 -05:00
|
|
|
this.folderId = this.localLibraryItem.folderId
|
|
|
|
this.folder = await this.$db.getLocalFolder(this.folderId)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-02-26 14:57:04 -06:00
|
|
|
<style scoped>
|
2022-04-06 20:36:17 -05:00
|
|
|
.media-item-container {
|
|
|
|
height: calc(100vh - 200px);
|
|
|
|
max-height: calc(100vh - 200px);
|
|
|
|
}
|
2023-02-17 16:07:37 -06:00
|
|
|
.media-item-container.media-order-changed {
|
|
|
|
height: calc(100vh - 280px);
|
|
|
|
max-height: calc(100vh - 280px);
|
|
|
|
}
|
|
|
|
.playerOpen .media-item-container {
|
|
|
|
height: calc(100vh - 300px);
|
|
|
|
max-height: calc(100vh - 300px);
|
|
|
|
}
|
|
|
|
.playerOpen .media-item-container.media-order-changed {
|
|
|
|
height: calc(100vh - 380px);
|
|
|
|
max-height: calc(100vh - 380px);
|
|
|
|
}
|
2022-04-13 20:24:54 -05:00
|
|
|
.sortable-ghost {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
.dragtrack-enter-from,
|
|
|
|
.dragtrack-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(30px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.dragtrack-leave-active {
|
|
|
|
position: absolute;
|
|
|
|
}
|
2022-12-08 00:28:28 -05:00
|
|
|
</style>
|