2022-05-29 18:46:45 +02:00
|
|
|
<template>
|
|
|
|
<modals-modal v-model="show" name="opml-feeds-modal" :width="1000" :height="'unset'" :processing="processing">
|
|
|
|
<template #outer>
|
|
|
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
2023-02-11 22:02:56 +01:00
|
|
|
<p class="text-3xl text-white truncate">{{ title }}</p>
|
2022-05-29 18:46:45 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div ref="wrapper" class="p-4 w-full text-sm py-2 rounded-lg bg-bg shadow-lg border border-black-300 relative overflow-hidden">
|
|
|
|
<div class="w-full p-4">
|
|
|
|
<div class="flex items-center -mx-2 mb-2">
|
|
|
|
<div class="w-full md:w-2/3 p-2">
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-dropdown v-model="selectedFolderId" :items="folderItems" :disabled="processing" :label="$strings.LabelFolder" />
|
2022-05-29 18:46:45 +02:00
|
|
|
</div>
|
|
|
|
<div class="w-full md:w-1/3 p-2 pt-6">
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-checkbox v-model="autoDownloadEpisodes" :label="$strings.LabelAutoDownloadEpisodes" checkbox-bg="primary" border-color="gray-600" label-class="text-sm font-semibold pl-2" />
|
2022-05-29 18:46:45 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-07-17 00:05:52 +02:00
|
|
|
<p class="text-lg font-semibold mb-1">{{ $strings.HeaderPodcastsToAdd }}</p>
|
|
|
|
<p class="text-sm text-gray-300 mb-4">{{ $strings.MessageOpmlPreviewNote }}</p>
|
2022-05-29 18:46:45 +02:00
|
|
|
|
|
|
|
<div class="w-full overflow-y-auto" style="max-height: 50vh">
|
2024-07-17 00:05:52 +02:00
|
|
|
<template v-for="(feed, index) in feeds">
|
|
|
|
<div :key="index" class="py-1 flex items-center">
|
|
|
|
<p class="text-lg font-semibold">{{ index + 1 }}.</p>
|
|
|
|
<div class="pl-2">
|
|
|
|
<p v-if="feed.title" class="text-sm font-semibold">{{ feed.title }}</p>
|
|
|
|
<p class="text-xs text-gray-400">{{ feed.feedUrl }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-29 18:46:45 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex items-center py-4">
|
|
|
|
<div class="flex-grow" />
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-btn color="success" @click="submit">{{ $strings.ButtonAddPodcasts }}</ui-btn>
|
2022-05-29 18:46:45 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Boolean,
|
|
|
|
feeds: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
processing: false,
|
|
|
|
selectedFolderId: null,
|
2024-07-17 00:05:52 +02:00
|
|
|
autoDownloadEpisodes: false
|
2022-05-29 18:46:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
show: {
|
|
|
|
immediate: true,
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
title() {
|
|
|
|
return 'OPML Feeds'
|
|
|
|
},
|
|
|
|
currentLibrary() {
|
|
|
|
return this.$store.getters['libraries/getCurrentLibrary']
|
|
|
|
},
|
|
|
|
folders() {
|
|
|
|
if (!this.currentLibrary) return []
|
|
|
|
return this.currentLibrary.folders || []
|
|
|
|
},
|
|
|
|
folderItems() {
|
|
|
|
return this.folders.map((fold) => {
|
|
|
|
return {
|
|
|
|
value: fold.id,
|
|
|
|
text: fold.fullPath
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
selectedFolder() {
|
|
|
|
return this.folders.find((f) => f.id === this.selectedFolderId)
|
|
|
|
},
|
|
|
|
selectedFolderPath() {
|
|
|
|
if (!this.selectedFolder) return ''
|
|
|
|
return this.selectedFolder.fullPath
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init() {
|
|
|
|
if (this.folderItems[0]) {
|
|
|
|
this.selectedFolderId = this.folderItems[0].value
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async submit() {
|
|
|
|
this.processing = true
|
|
|
|
|
2024-07-17 00:05:52 +02:00
|
|
|
const payload = {
|
|
|
|
feeds: this.feeds.map((f) => f.feedUrl),
|
|
|
|
folderId: this.selectedFolderId,
|
|
|
|
libraryId: this.currentLibrary.id,
|
|
|
|
autoDownloadEpisodes: this.autoDownloadEpisodes
|
2022-05-29 18:46:45 +02:00
|
|
|
}
|
2024-07-17 00:05:52 +02:00
|
|
|
this.$axios
|
|
|
|
.$post('/api/podcasts/opml/create', payload)
|
|
|
|
.then(() => {
|
|
|
|
this.show = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
const errorMsg = error.response?.data || this.$strings.ToastPodcastCreateFailed
|
|
|
|
console.error('Failed to create podcast', payload, error)
|
|
|
|
this.$toast.error(errorMsg)
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.processing = false
|
|
|
|
})
|
2022-05-29 18:46:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|