2022-02-26 23:19:22 +01:00
|
|
|
<template>
|
|
|
|
<div class="relative w-full py-4 px-6 border border-white border-opacity-10 shadow-lg rounded-md my-6">
|
|
|
|
<div class="absolute -top-3 -left-3 w-8 h-8 bg-bg border border-white border-opacity-10 flex items-center justify-center rounded-full">
|
2022-04-15 01:24:24 +02:00
|
|
|
<p class="text-base text-white text-opacity-80 font-mono">#{{ item.index }}</p>
|
2022-02-26 23:19:22 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="!processing && !uploadFailed && !uploadSuccess" class="absolute -top-3 -right-3 w-8 h-8 bg-bg border border-white border-opacity-10 flex items-center justify-center rounded-full hover:bg-error cursor-pointer" @click="$emit('remove')">
|
|
|
|
<span class="text-base text-white text-opacity-80 font-mono material-icons">close</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<template v-if="!uploadSuccess && !uploadFailed">
|
|
|
|
<widgets-alert v-if="error" type="error">
|
|
|
|
<p class="text-base">{{ error }}</p>
|
|
|
|
</widgets-alert>
|
|
|
|
|
|
|
|
<div class="flex my-2 -mx-2">
|
|
|
|
<div class="w-1/2 px-2">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-text-input-with-label v-model="itemData.title" :disabled="processing" :label="$strings.LabelTitle" @input="titleUpdated" />
|
2022-02-26 23:19:22 +01:00
|
|
|
</div>
|
|
|
|
<div class="w-1/2 px-2">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-text-input-with-label v-if="!isPodcast" v-model="itemData.author" :disabled="processing" :label="$strings.LabelAuthor" />
|
2022-04-15 01:24:24 +02:00
|
|
|
<div v-else class="w-full">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="px-1 text-sm font-semibold">{{ $strings.LabelDirectory }} <em class="font-normal text-xs pl-2">(auto)</em></p>
|
2022-04-15 01:24:24 +02:00
|
|
|
<ui-text-input :value="directory" disabled class="w-full font-mono text-xs" style="height: 38px" />
|
|
|
|
</div>
|
2022-02-26 23:19:22 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-04-15 01:24:24 +02:00
|
|
|
<div v-if="!isPodcast" class="flex my-2 -mx-2">
|
2022-02-26 23:19:22 +01:00
|
|
|
<div class="w-1/2 px-2">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-text-input-with-label v-model="itemData.series" :disabled="processing" :label="$strings.LabelSeries" note="(optional)" />
|
2022-02-26 23:19:22 +01:00
|
|
|
</div>
|
|
|
|
<div class="w-1/2 px-2">
|
|
|
|
<div class="w-full">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="px-1 text-sm font-semibold">{{ $strings.LabelDirectory }} <em class="font-normal text-xs pl-2">(auto)</em></p>
|
2022-02-26 23:19:22 +01:00
|
|
|
<ui-text-input :value="directory" disabled class="w-full font-mono text-xs" style="height: 38px" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-11-08 01:27:17 +01:00
|
|
|
<tables-uploaded-files-table :files="item.itemFiles" :title="$strings.HeaderItemFiles" class="mt-8" />
|
|
|
|
<tables-uploaded-files-table v-if="item.otherFiles.length" :title="$strings.HeaderOtherFiles" :files="item.otherFiles" />
|
|
|
|
<tables-uploaded-files-table v-if="item.ignoredFiles.length" :title="$strings.HeaderIgnoredFiles" :files="item.ignoredFiles" />
|
2022-02-26 23:19:22 +01:00
|
|
|
</template>
|
|
|
|
<widgets-alert v-if="uploadSuccess" type="success">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-base">{{ $strings.MessageUploaderItemSuccess }}</p>
|
2022-02-26 23:19:22 +01:00
|
|
|
</widgets-alert>
|
|
|
|
<widgets-alert v-if="uploadFailed" type="error">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="text-base">{{ $strings.MessageUploaderItemFailed }}</p>
|
2022-02-26 23:19:22 +01:00
|
|
|
</widgets-alert>
|
|
|
|
|
|
|
|
<div v-if="isUploading" class="absolute top-0 left-0 w-full h-full bg-black bg-opacity-50 flex items-center justify-center z-20">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-loading-indicator :text="$strings.MessageUploading" />
|
2022-02-26 23:19:22 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Path from 'path'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
2022-04-15 01:24:24 +02:00
|
|
|
item: {
|
2022-02-26 23:19:22 +01:00
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
},
|
2022-04-15 01:24:24 +02:00
|
|
|
mediaType: String,
|
2022-02-26 23:19:22 +01:00
|
|
|
processing: Boolean
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-04-15 01:24:24 +02:00
|
|
|
itemData: {
|
2022-02-26 23:19:22 +01:00
|
|
|
title: '',
|
|
|
|
author: '',
|
|
|
|
series: ''
|
|
|
|
},
|
|
|
|
error: '',
|
|
|
|
isUploading: false,
|
|
|
|
uploadFailed: false,
|
|
|
|
uploadSuccess: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-04-15 01:24:24 +02:00
|
|
|
isPodcast() {
|
|
|
|
return this.mediaType === 'podcast'
|
|
|
|
},
|
2022-02-26 23:19:22 +01:00
|
|
|
directory() {
|
2022-04-15 01:24:24 +02:00
|
|
|
if (!this.itemData.title) return ''
|
|
|
|
if (this.isPodcast) return this.itemData.title
|
|
|
|
|
|
|
|
if (this.itemData.series && this.itemData.author) {
|
|
|
|
return Path.join(this.itemData.author, this.itemData.series, this.itemData.title)
|
|
|
|
} else if (this.itemData.author) {
|
|
|
|
return Path.join(this.itemData.author, this.itemData.title)
|
2022-02-26 23:19:22 +01:00
|
|
|
} else {
|
2022-04-15 01:24:24 +02:00
|
|
|
return this.itemData.title
|
2022-02-26 23:19:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setUploadStatus(status) {
|
|
|
|
this.isUploading = status === 'uploading'
|
|
|
|
this.uploadFailed = status === 'failed'
|
|
|
|
this.uploadSuccess = status === 'success'
|
|
|
|
},
|
|
|
|
titleUpdated() {
|
|
|
|
this.error = ''
|
|
|
|
},
|
|
|
|
getData() {
|
2022-04-15 01:24:24 +02:00
|
|
|
if (!this.itemData.title) {
|
2022-02-26 23:19:22 +01:00
|
|
|
this.error = 'Must have a title'
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
this.error = ''
|
2022-04-15 01:24:24 +02:00
|
|
|
var files = this.item.itemFiles.concat(this.item.otherFiles)
|
2022-02-26 23:19:22 +01:00
|
|
|
return {
|
2022-04-15 01:24:24 +02:00
|
|
|
index: this.item.index,
|
|
|
|
...this.itemData,
|
2022-02-26 23:19:22 +01:00
|
|
|
files
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-04-15 01:24:24 +02:00
|
|
|
if (this.item) {
|
|
|
|
this.itemData.title = this.item.title
|
|
|
|
this.itemData.author = this.item.author
|
|
|
|
this.itemData.series = this.item.series
|
2022-02-26 23:19:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|