mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-19 09:08:26 +02:00
iOS downloads page cleanup UI
This commit is contained in:
parent
d7c414f6c0
commit
d331e1f9ab
1 changed files with 41 additions and 45 deletions
|
@ -2,25 +2,23 @@
|
||||||
<div class="w-full h-full py-6 px-4 overflow-y-auto">
|
<div class="w-full h-full py-6 px-4 overflow-y-auto">
|
||||||
<p class="mb-2 text-base text-white">Downloads ({{ localLibraryItems.length }})</p>
|
<p class="mb-2 text-base text-white">Downloads ({{ localLibraryItems.length }})</p>
|
||||||
|
|
||||||
<div class="w-full media-item-container overflow-y-auto">
|
<div class="w-full">
|
||||||
<template v-for="(mediaItem, num) in localLibraryItems">
|
<template v-for="(mediaItem, num) in localLibraryItems">
|
||||||
<div :key="mediaItem.id">
|
<div :key="mediaItem.id" class="w-full">
|
||||||
<div class="flex w-full items-center">
|
<nuxt-link :to="`/localMedia/item/${mediaItem.id}`" class="flex items-center">
|
||||||
<nuxt-link :to="`/item/${mediaItem.id}`" class="flex flex-grow">
|
<div class="w-16 h-16 min-w-16 min-h-16 flex-none bg-primary relative">
|
||||||
<div class="w-16 h-16 min-w-16 min-h-16 flex-none bg-primary relative self-center">
|
|
||||||
<img v-if="mediaItem.coverPathSrc" :src="mediaItem.coverPathSrc" class="w-full h-full object-contain" />
|
<img v-if="mediaItem.coverPathSrc" :src="mediaItem.coverPathSrc" class="w-full h-full object-contain" />
|
||||||
</div>
|
</div>
|
||||||
<div class="px-2 self-center">
|
<div class="px-2 flex-grow">
|
||||||
<p class="text-sm">{{ mediaItem.media.metadata.title }}</p>
|
<p class="text-sm">{{ mediaItem.media.metadata.title }}</p>
|
||||||
<p v-if="mediaItem.mediaType == 'book'" class="text-xs text-gray-300">{{ mediaItem.media.tracks.length }} Track{{ mediaItem.media.tracks.length == 1 ? '' : 's' }}</p>
|
<p v-if="mediaItem.mediaType == 'book'" class="text-xs text-gray-300">{{ mediaItem.media.tracks.length }} Track{{ mediaItem.media.tracks.length == 1 ? '' : 's' }}</p>
|
||||||
<p v-else-if="mediaItem.mediaType == 'podcast'" class="text-xs text-gray-300">{{ mediaItem.media.episodes.length }} Episode{{ mediaItem.media.episodes.length == 1 ? '' : 's' }}</p>
|
<p v-else-if="mediaItem.mediaType == 'podcast'" class="text-xs text-gray-300">{{ mediaItem.media.episodes.length }} Episode{{ mediaItem.media.episodes.length == 1 ? '' : 's' }}</p>
|
||||||
<p v-if="size(mediaItem)" class="text-xs text-gray-300">{{ $bytesPretty(size(mediaItem)) }}</p>
|
<p v-if="mediaItem.size" class="text-xs text-gray-300">{{ $bytesPretty(mediaItem.size) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-12 h-12 flex items-center justify-center">
|
||||||
|
<span class="material-icons text-2xl text-gray-400">chevron_right</span>
|
||||||
</div>
|
</div>
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
<div class="w-12 h-12 flex items-center">
|
|
||||||
<span class="material-icons text-2xl text-red-400" @click="deleteItem(mediaItem)">delete</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="num+1 < localLibraryItems.length" class="flex border-t border-white border-opacity-10 my-3" />
|
<div v-if="num+1 < localLibraryItems.length" class="flex border-t border-white border-opacity-10 my-3" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -30,49 +28,47 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Capacitor } from '@capacitor/core'
|
import { Capacitor } from '@capacitor/core'
|
||||||
import { Dialog } from '@capacitor/dialog'
|
|
||||||
import { AbsFileSystem } from '@/plugins/capacitor'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
localLibraryItems: [],
|
localLibraryItems: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getSize(item) {
|
||||||
|
if (!item || !item.localFiles) return 0
|
||||||
|
let size = 0
|
||||||
|
for (let i = 0; i < item.localFiles.length; i++) {
|
||||||
|
size += item.localFiles[i].size
|
||||||
|
}
|
||||||
|
return size
|
||||||
|
},
|
||||||
|
newLocalLibraryItem(item) {
|
||||||
|
if (!item) return
|
||||||
|
const itemIndex = this.localLibraryItems.findIndex((li) => li.id === item.id)
|
||||||
|
const newItemObj = {
|
||||||
|
...item,
|
||||||
|
size: this.getSize(item),
|
||||||
|
coverPathSrc: item.coverContentUrl ? Capacitor.convertFileSrc(item.coverContentUrl) : null
|
||||||
|
}
|
||||||
|
if (itemIndex >= 0) {
|
||||||
|
this.localLibraryItems.splice(itemIndex, 1, newItemObj)
|
||||||
|
} else {
|
||||||
|
this.localLibraryItems.push(newItemObj)
|
||||||
|
}
|
||||||
|
},
|
||||||
async init() {
|
async init() {
|
||||||
var items = (await this.$db.getLocalLibraryItems()) || []
|
var items = (await this.$db.getLocalLibraryItems()) || []
|
||||||
this.localLibraryItems = items.map((lmi) => {
|
this.localLibraryItems = items.map((lmi) => {
|
||||||
console.log('Local library item', JSON.stringify(lmi))
|
console.log('Local library item', JSON.stringify(lmi))
|
||||||
return {
|
return {
|
||||||
...lmi,
|
...lmi,
|
||||||
|
size: this.getSize(lmi),
|
||||||
coverPathSrc: lmi.coverContentUrl ? Capacitor.convertFileSrc(lmi.coverContentUrl) : null
|
coverPathSrc: lmi.coverContentUrl ? Capacitor.convertFileSrc(lmi.coverContentUrl) : null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
|
||||||
size(item) {
|
|
||||||
console.log('sizing' + item)
|
|
||||||
let size = null
|
|
||||||
if (item.localFiles) {
|
|
||||||
for (let i = 0; i < item.localFiles.length; i++) {
|
|
||||||
size = size + item.localFiles[i].size
|
|
||||||
}
|
}
|
||||||
return size
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async deleteItem(item) {
|
|
||||||
const { value } = await Dialog.confirm({
|
|
||||||
title: 'Confirm',
|
|
||||||
message: `Warning! This will delete "${item.media.metadata.title}" and all associated local files. Are you sure?`
|
|
||||||
})
|
|
||||||
if (value) {
|
|
||||||
var res = await AbsFileSystem.deleteItem(item)
|
|
||||||
if (res && res.success) {
|
|
||||||
this.$toast.success('Deleted Successfully')
|
|
||||||
this.init()
|
|
||||||
} else this.$toast.error('Failed to delete')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
|
this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue