2021-10-05 05:11:42 +02:00
|
|
|
<template>
|
2022-12-15 23:51:37 +01:00
|
|
|
<div class="w-full h-full md:px-4 py-2 mb-4">
|
|
|
|
<div v-if="!showDirectoryPicker" class="w-full h-full md:py-4">
|
|
|
|
<div class="flex flex-wrap md:flex-nowrap -mx-1 mb-2">
|
2022-03-18 23:09:17 +01:00
|
|
|
<div class="w-2/5 md:w-72 px-1 py-1 md:py-0">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-dropdown v-model="mediaType" :items="mediaTypes" :label="$strings.LabelMediaType" :disabled="!isNew" small @input="changedMediaType" />
|
2022-03-18 23:09:17 +01:00
|
|
|
</div>
|
2022-03-04 02:03:34 +01:00
|
|
|
<div class="w-full md:flex-grow px-1 py-1 md:py-0">
|
2023-01-31 23:04:30 +01:00
|
|
|
<ui-text-input-with-label ref="nameInput" v-model="name" :label="$strings.LabelLibraryName" @blur="nameBlurred" />
|
2022-02-15 21:59:46 +01:00
|
|
|
</div>
|
2022-03-18 23:09:17 +01:00
|
|
|
<div class="w-1/5 md:w-18 px-1 py-1 md:py-0">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-media-icon-picker v-model="icon" :label="$strings.LabelIcon" @input="iconChanged" />
|
2022-03-04 02:03:34 +01:00
|
|
|
</div>
|
2022-03-18 23:09:17 +01:00
|
|
|
<div class="w-2/5 md:w-72 px-1 py-1 md:py-0">
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-dropdown v-model="provider" :items="providers" :label="$strings.LabelMetadataProvider" small @input="formUpdated" />
|
2022-02-15 21:59:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-05 05:11:42 +02:00
|
|
|
|
2022-12-15 23:51:37 +01:00
|
|
|
<div class="folders-container overflow-y-auto w-full py-2 mb-2">
|
2022-11-08 01:27:17 +01:00
|
|
|
<p class="px-1 text-sm font-semibold">{{ $strings.LabelFolders }}</p>
|
2021-10-05 05:11:42 +02:00
|
|
|
<div v-for="(folder, index) in folders" :key="index" class="w-full flex items-center py-1 px-2">
|
2024-07-10 23:38:58 +02:00
|
|
|
<span class="material-symbols fill bg-opacity-50 mr-2 text-yellow-200" style="font-size: 1.2rem">folder</span>
|
2023-09-28 00:50:32 +02:00
|
|
|
<ui-editable-text ref="folderInput" v-model="folder.fullPath" :readonly="!!folder.id" type="text" class="w-full" @blur="existingFolderInputBlurred(folder)" />
|
2024-07-08 18:36:37 +02:00
|
|
|
<span v-show="folders.length > 1" class="material-symbols text-2xl ml-2 cursor-pointer hover:text-error" @click="removeFolder(folder)">close</span>
|
2021-10-05 05:11:42 +02:00
|
|
|
</div>
|
2022-03-14 15:56:24 +01:00
|
|
|
<div class="flex py-1 px-2 items-center w-full">
|
2024-07-10 23:38:58 +02:00
|
|
|
<span class="material-symbols fill bg-opacity-50 mr-2 text-yellow-200" style="font-size: 1.2rem">folder</span>
|
2023-01-31 23:04:30 +01:00
|
|
|
<ui-editable-text ref="newFolderInput" v-model="newFolderPath" :placeholder="$strings.PlaceholderNewFolderPath" type="text" class="w-full" @blur="newFolderInputBlurred" />
|
2022-03-14 15:56:24 +01:00
|
|
|
</div>
|
|
|
|
|
2022-11-08 01:27:17 +01:00
|
|
|
<ui-btn class="w-full mt-2" color="primary" @click="browseForFolder">{{ $strings.ButtonBrowseForFolder }}</ui-btn>
|
2021-10-05 05:11:42 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-03 23:23:17 +01:00
|
|
|
<modals-libraries-lazy-folder-chooser v-else :paths="folderPaths" @back="showDirectoryPicker = false" @select="selectFolder" />
|
2021-10-05 05:11:42 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2022-04-15 00:15:52 +02:00
|
|
|
isNew: Boolean,
|
2021-10-05 05:11:42 +02:00
|
|
|
library: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
|
|
|
},
|
|
|
|
processing: Boolean
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
2022-03-14 15:56:24 +01:00
|
|
|
provider: 'google',
|
2022-03-18 23:09:17 +01:00
|
|
|
icon: '',
|
2021-10-05 05:11:42 +02:00
|
|
|
folders: [],
|
2022-02-26 23:34:54 +01:00
|
|
|
showDirectoryPicker: false,
|
2022-03-18 23:09:17 +01:00
|
|
|
newFolderPath: '',
|
2022-11-09 00:10:08 +01:00
|
|
|
mediaType: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
mediaTypes() {
|
|
|
|
return [
|
2022-03-18 23:09:17 +01:00
|
|
|
{
|
|
|
|
value: 'book',
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelBooks
|
2022-03-18 23:09:17 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'podcast',
|
2022-11-09 00:10:08 +01:00
|
|
|
text: this.$strings.LabelPodcasts
|
2022-03-18 23:09:17 +01:00
|
|
|
}
|
|
|
|
]
|
2022-11-09 00:10:08 +01:00
|
|
|
},
|
2021-10-05 05:11:42 +02:00
|
|
|
folderPaths() {
|
|
|
|
return this.folders.map((f) => f.fullPath)
|
2021-10-07 04:08:52 +02:00
|
|
|
},
|
2022-02-15 21:59:46 +01:00
|
|
|
providers() {
|
2022-03-18 23:09:17 +01:00
|
|
|
if (this.mediaType === 'podcast') return this.$store.state.scanners.podcastProviders
|
2022-02-15 21:59:46 +01:00
|
|
|
return this.$store.state.scanners.providers
|
2021-10-05 05:11:42 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2023-01-31 23:04:30 +01:00
|
|
|
checkBlurExpressionInput() {
|
|
|
|
if (this.$refs.nameInput) {
|
|
|
|
this.$refs.nameInput.blur()
|
|
|
|
}
|
|
|
|
if (this.$refs.folderInput && this.$refs.folderInput.length) {
|
|
|
|
this.$refs.folderInput.forEach((input) => {
|
|
|
|
if (input.blur) input.blur()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (this.$refs.newFolderInput) {
|
|
|
|
this.$refs.newFolderInput.blur()
|
|
|
|
}
|
|
|
|
},
|
2022-05-21 18:21:03 +02:00
|
|
|
browseForFolder() {
|
|
|
|
this.showDirectoryPicker = true
|
|
|
|
},
|
2022-04-15 00:15:52 +02:00
|
|
|
getLibraryData() {
|
|
|
|
return {
|
|
|
|
name: this.name,
|
|
|
|
provider: this.provider,
|
|
|
|
folders: this.folders,
|
|
|
|
icon: this.icon,
|
|
|
|
mediaType: this.mediaType
|
|
|
|
}
|
|
|
|
},
|
|
|
|
formUpdated() {
|
|
|
|
this.$emit('update', this.getLibraryData())
|
|
|
|
},
|
2023-09-28 00:50:32 +02:00
|
|
|
existingFolderInputBlurred(folder) {
|
|
|
|
if (!folder.fullPath) {
|
|
|
|
this.removeFolder(folder)
|
|
|
|
}
|
|
|
|
},
|
2022-04-15 00:15:52 +02:00
|
|
|
newFolderInputBlurred() {
|
|
|
|
if (this.newFolderPath) {
|
|
|
|
this.folders.push({ fullPath: this.newFolderPath })
|
|
|
|
this.newFolderPath = ''
|
|
|
|
this.formUpdated()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
iconChanged() {
|
|
|
|
this.formUpdated()
|
|
|
|
},
|
|
|
|
nameBlurred() {
|
|
|
|
if (this.name !== this.library.name) {
|
|
|
|
this.formUpdated()
|
|
|
|
}
|
|
|
|
},
|
2022-03-18 23:09:17 +01:00
|
|
|
changedMediaType() {
|
|
|
|
this.provider = this.providers[0].value
|
2022-04-15 00:15:52 +02:00
|
|
|
this.formUpdated()
|
|
|
|
},
|
|
|
|
selectFolder(fullPath) {
|
|
|
|
this.folders.push({ fullPath })
|
|
|
|
this.showDirectoryPicker = false
|
|
|
|
this.formUpdated()
|
2022-03-18 23:09:17 +01:00
|
|
|
},
|
2021-10-05 05:11:42 +02:00
|
|
|
removeFolder(folder) {
|
|
|
|
this.folders = this.folders.filter((f) => f.fullPath !== folder.fullPath)
|
2022-04-15 00:15:52 +02:00
|
|
|
this.formUpdated()
|
2021-10-05 05:11:42 +02:00
|
|
|
},
|
|
|
|
backArrowPress() {
|
|
|
|
if (this.showDirectoryPicker) {
|
|
|
|
this.showDirectoryPicker = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
init() {
|
|
|
|
this.name = this.library ? this.library.name : ''
|
2022-03-14 15:56:24 +01:00
|
|
|
this.provider = this.library ? this.library.provider : 'google'
|
2021-10-05 05:11:42 +02:00
|
|
|
this.folders = this.library ? this.library.folders.map((p) => ({ ...p })) : []
|
2022-03-18 23:09:17 +01:00
|
|
|
this.icon = this.library ? this.library.icon : 'default'
|
|
|
|
this.mediaType = this.library ? this.library.mediaType : 'book'
|
2023-09-28 00:50:32 +02:00
|
|
|
|
2021-10-05 05:11:42 +02:00
|
|
|
this.showDirectoryPicker = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2022-12-15 23:51:37 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.folders-container {
|
|
|
|
max-height: calc(80vh - 192px);
|
|
|
|
}
|
|
|
|
@media (max-device-width: 768px) {
|
|
|
|
.folders-container {
|
|
|
|
max-height: calc(80vh - 292px);
|
|
|
|
}
|
|
|
|
}
|
2024-07-10 23:38:58 +02:00
|
|
|
</style>
|