2021-10-05 05:11:42 +02:00
|
|
|
<template>
|
2022-02-26 23:34:54 +01:00
|
|
|
<div class="w-full h-full px-4 py-2 mb-4">
|
2021-10-05 05:11:42 +02:00
|
|
|
<div v-if="!showDirectoryPicker" class="w-full h-full py-4">
|
2022-03-04 02:03:34 +01:00
|
|
|
<div class="flex flex-wrap md:flex-nowrap -mx-1">
|
2022-03-18 23:09:17 +01:00
|
|
|
<div class="w-2/5 md:w-72 px-1 py-1 md:py-0">
|
2022-04-15 00:15:52 +02:00
|
|
|
<ui-dropdown v-model="mediaType" :items="mediaTypes" label="Media Type" :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">
|
2022-04-15 00:15:52 +02:00
|
|
|
<ui-text-input-with-label v-model="name" label="Library Name" @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-04-15 00:15:52 +02:00
|
|
|
<ui-media-icon-picker v-model="icon" @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-04-15 00:15:52 +02:00
|
|
|
<ui-dropdown v-model="provider" :items="providers" label="Metadata Provider" small @input="formUpdated" />
|
2022-02-15 21:59:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-05 05:11:42 +02:00
|
|
|
|
|
|
|
<div class="w-full py-4">
|
|
|
|
<p class="px-1 text-sm font-semibold">Folders</p>
|
|
|
|
<div v-for="(folder, index) in folders" :key="index" class="w-full flex items-center py-1 px-2">
|
|
|
|
<span class="material-icons bg-opacity-50 mr-2 text-yellow-200" style="font-size: 1.2rem">folder</span>
|
2022-03-14 15:56:24 +01:00
|
|
|
<ui-editable-text v-model="folder.fullPath" readonly type="text" class="w-full" />
|
2021-10-07 04:08:52 +02:00
|
|
|
<span v-show="folders.length > 1" class="material-icons 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">
|
|
|
|
<span class="material-icons bg-opacity-50 mr-2 text-yellow-200" style="font-size: 1.2rem">folder</span>
|
2022-04-15 00:15:52 +02:00
|
|
|
<ui-editable-text v-model="newFolderPath" placeholder="New folder path" type="text" class="w-full" @blur="newFolderInputBlurred" />
|
2022-03-14 15:56:24 +01:00
|
|
|
</div>
|
|
|
|
|
2022-05-21 18:21:03 +02:00
|
|
|
<ui-btn class="w-full mt-2" color="primary" @click="browseForFolder">Browse for Folder</ui-btn>
|
2021-10-05 05:11:42 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-04-15 00:15:52 +02:00
|
|
|
<modals-libraries-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: '',
|
|
|
|
mediaType: null,
|
|
|
|
mediaTypes: [
|
|
|
|
{
|
|
|
|
value: 'book',
|
|
|
|
text: 'Books'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'podcast',
|
|
|
|
text: 'Podcasts'
|
|
|
|
}
|
|
|
|
]
|
2021-10-05 05:11:42 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
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: {
|
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())
|
|
|
|
},
|
|
|
|
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'
|
2021-10-05 05:11:42 +02:00
|
|
|
this.showDirectoryPicker = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|