mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-24 19:11:44 +01:00
76 lines
2.2 KiB
Vue
76 lines
2.2 KiB
Vue
|
<template>
|
||
|
<div class="w-full">
|
||
|
<div v-if="missingParts.length" class="bg-error border-red-800 shadow-md p-4">
|
||
|
<p class="text-sm mb-2">
|
||
|
Missing Parts <span class="text-sm">({{ missingParts.length }})</span>
|
||
|
</p>
|
||
|
<p class="text-sm font-mono">{{ missingPartChunks.join(', ') }}</p>
|
||
|
</div>
|
||
|
|
||
|
<div v-if="invalidParts.length" class="bg-error border-red-800 shadow-md p-4">
|
||
|
<p class="text-sm mb-2">
|
||
|
Invalid Parts <span class="text-sm">({{ invalidParts.length }})</span>
|
||
|
</p>
|
||
|
<div>
|
||
|
<p v-for="part in invalidParts" :key="part.filename" class="text-sm font-mono">{{ part.filename }}: {{ part.error }}</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<tables-tracks-table :key="audiobook.id" :title="`Audiobook Tracks (${audiobook.name})`" :tracks="audiobook.tracks" :audiobook-id="audiobook.id" class="mt-6" />
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
props: {
|
||
|
audiobook: {
|
||
|
type: Object,
|
||
|
default: () => {}
|
||
|
}
|
||
|
},
|
||
|
data() {
|
||
|
return {}
|
||
|
},
|
||
|
computed: {
|
||
|
missingPartChunks() {
|
||
|
if (this.missingParts === 1) return this.missingParts[0]
|
||
|
var chunks = []
|
||
|
|
||
|
var currentIndex = this.missingParts[0]
|
||
|
var currentChunk = [this.missingParts[0]]
|
||
|
|
||
|
for (let i = 1; i < this.missingParts.length; i++) {
|
||
|
var partIndex = this.missingParts[i]
|
||
|
if (currentIndex === partIndex - 1) {
|
||
|
currentChunk.push(partIndex)
|
||
|
currentIndex = partIndex
|
||
|
} else {
|
||
|
// console.log('Chunk ended', currentChunk.join(', '), currentIndex, partIndex)
|
||
|
if (currentChunk.length === 0) {
|
||
|
console.error('How is current chunk 0?', currentChunk.join(', '))
|
||
|
}
|
||
|
chunks.push(currentChunk)
|
||
|
currentChunk = [partIndex]
|
||
|
currentIndex = partIndex
|
||
|
}
|
||
|
}
|
||
|
if (currentChunk.length) {
|
||
|
chunks.push(currentChunk)
|
||
|
}
|
||
|
chunks = chunks.map((chunk) => {
|
||
|
if (chunk.length === 1) return chunk[0]
|
||
|
else return `${chunk[0]}-${chunk[chunk.length - 1]}`
|
||
|
})
|
||
|
return chunks
|
||
|
},
|
||
|
missingParts() {
|
||
|
return this.audiobook.missingParts || []
|
||
|
},
|
||
|
invalidParts() {
|
||
|
return this.audiobook.invalidParts || []
|
||
|
}
|
||
|
},
|
||
|
methods: {},
|
||
|
mounted() {}
|
||
|
}
|
||
|
</script>
|