2022-05-02 23:42:30 +02:00
|
|
|
<template>
|
|
|
|
<modals-modal v-model="show" name="rss-feed-modal" :width="600" :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-02 23:42:30 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div ref="wrapper" class="px-8 py-6 w-full text-sm rounded-lg bg-bg shadow-lg border border-black-300 relative overflow-hidden">
|
2022-12-26 23:58:36 +01:00
|
|
|
<div v-if="currentFeed" class="w-full">
|
2022-11-09 00:10:08 +01:00
|
|
|
<p class="text-lg font-semibold mb-4">{{ $strings.HeaderRSSFeedIsOpen }}</p>
|
2022-05-02 23:42:30 +02:00
|
|
|
|
|
|
|
<div class="w-full relative">
|
2022-12-26 23:58:36 +01:00
|
|
|
<ui-text-input v-model="currentFeed.feedUrl" readonly />
|
2022-05-02 23:42:30 +02:00
|
|
|
|
2022-12-26 23:58:36 +01:00
|
|
|
<span class="material-icons absolute right-2 bottom-2 p-0.5 text-base transition-transform duration-100 text-gray-300 hover:text-white transform hover:scale-125 cursor-pointer" @click="copyToClipboard(currentFeed.feedUrl)">content_copy</span>
|
2022-05-04 01:52:34 +02:00
|
|
|
</div>
|
2023-02-25 14:20:26 +01:00
|
|
|
|
|
|
|
<div v-if="currentFeed.meta" class="mt-5">
|
|
|
|
<div class="flex py-0.5">
|
2023-03-07 17:28:10 +01:00
|
|
|
<div class="w-48">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">{{ $strings.LabelRSSFeedPreventIndexing }}</span>
|
|
|
|
</div>
|
|
|
|
<div>{{ currentFeed.meta.preventIndexing ? 'Yes' : 'No' }}</div>
|
2023-02-25 14:20:26 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="currentFeed.meta.ownerName" class="flex py-0.5">
|
2023-03-07 17:28:10 +01:00
|
|
|
<div class="w-48">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">{{ $strings.LabelRSSFeedCustomOwnerName }}</span>
|
|
|
|
</div>
|
|
|
|
<div>{{ currentFeed.meta.ownerName }}</div>
|
2023-02-25 14:20:26 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="currentFeed.meta.ownerEmail" class="flex py-0.5">
|
2023-03-07 17:28:10 +01:00
|
|
|
<div class="w-48">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">{{ $strings.LabelRSSFeedCustomOwnerEmail }}</span>
|
|
|
|
</div>
|
|
|
|
<div>{{ currentFeed.meta.ownerEmail }}</div>
|
2023-02-25 14:20:26 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-04 01:52:34 +02:00
|
|
|
</div>
|
|
|
|
<div v-else class="w-full">
|
2022-11-09 00:10:08 +01:00
|
|
|
<p class="text-lg font-semibold mb-4">{{ $strings.HeaderOpenRSSFeed }}</p>
|
2022-05-04 01:52:34 +02:00
|
|
|
|
2022-05-12 01:34:17 +02:00
|
|
|
<div class="w-full relative mb-2">
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-text-input-with-label v-model="newFeedSlug" :label="$strings.LabelRSSFeedSlug" />
|
|
|
|
<p class="text-xs text-gray-400 py-0.5 px-1">{{ $getString('MessageFeedURLWillBe', [demoFeedUrl]) }}</p>
|
2022-05-02 23:42:30 +02:00
|
|
|
</div>
|
2023-02-25 14:20:26 +01:00
|
|
|
<widgets-rss-feed-metadata-builder v-model="metadataDetails" />
|
2022-05-12 01:34:17 +02:00
|
|
|
|
2022-11-09 00:10:08 +01:00
|
|
|
<p v-if="isHttp" class="w-full pt-2 text-warning text-xs">{{ $strings.NoteRSSFeedPodcastAppsHttps }}</p>
|
|
|
|
<p v-if="hasEpisodesWithoutPubDate" class="w-full pt-2 text-warning text-xs">{{ $strings.NoteRSSFeedPodcastAppsPubDate }}</p>
|
2022-05-02 23:42:30 +02:00
|
|
|
</div>
|
|
|
|
<div v-show="userIsAdminOrUp" class="flex items-center pt-6">
|
|
|
|
<div class="flex-grow" />
|
2022-12-26 23:58:36 +01:00
|
|
|
<ui-btn v-if="currentFeed" color="error" small @click="closeFeed">{{ $strings.ButtonCloseFeed }}</ui-btn>
|
2022-11-09 00:10:08 +01:00
|
|
|
<ui-btn v-else color="success" small @click="openFeed">{{ $strings.ButtonOpenFeed }}</ui-btn>
|
2022-05-02 23:42:30 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2022-05-04 01:52:34 +02:00
|
|
|
processing: false,
|
|
|
|
newFeedSlug: null,
|
2023-02-25 14:20:26 +01:00
|
|
|
currentFeed: null,
|
|
|
|
metadataDetails: {
|
|
|
|
preventIndexing: true,
|
|
|
|
ownerName: '',
|
|
|
|
ownerEmail: ''
|
2023-03-07 17:28:10 +01:00
|
|
|
}
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
show: {
|
|
|
|
immediate: true,
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
2022-12-31 22:26:37 +01:00
|
|
|
return this.$store.state.globals.showRSSFeedOpenCloseModal
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
set(val) {
|
2022-12-31 22:26:37 +01:00
|
|
|
this.$store.commit('globals/setShowRSSFeedOpenCloseModal', val)
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
|
|
|
},
|
2022-12-31 22:26:37 +01:00
|
|
|
rssFeedEntity() {
|
|
|
|
return this.$store.state.globals.rssFeedEntity || {}
|
2022-05-04 01:52:34 +02:00
|
|
|
},
|
2022-12-31 22:26:37 +01:00
|
|
|
entityId() {
|
|
|
|
return this.rssFeedEntity.id
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
2022-12-31 22:26:37 +01:00
|
|
|
entityType() {
|
|
|
|
return this.rssFeedEntity.type
|
|
|
|
},
|
|
|
|
entityFeed() {
|
|
|
|
return this.rssFeedEntity.feed
|
|
|
|
},
|
|
|
|
hasEpisodesWithoutPubDate() {
|
|
|
|
return !!this.rssFeedEntity.hasEpisodesWithoutPubDate
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
title() {
|
2022-12-31 22:26:37 +01:00
|
|
|
return this.rssFeedEntity.name
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
2022-05-04 01:52:34 +02:00
|
|
|
},
|
|
|
|
demoFeedUrl() {
|
|
|
|
return `${window.origin}/feed/${this.newFeedSlug}`
|
2022-05-12 01:34:17 +02:00
|
|
|
},
|
|
|
|
isHttp() {
|
|
|
|
return window.origin.startsWith('http://')
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-05-04 01:52:34 +02:00
|
|
|
openFeed() {
|
|
|
|
if (!this.newFeedSlug) {
|
|
|
|
this.$toast.error('Must set a feed slug')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-26 23:58:36 +01:00
|
|
|
const sanitized = this.$sanitizeSlug(this.newFeedSlug)
|
2022-05-04 01:52:34 +02:00
|
|
|
if (this.newFeedSlug !== sanitized) {
|
|
|
|
this.newFeedSlug = sanitized
|
|
|
|
this.$toast.warning('Slug had to be modified - Run again')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
serverAddress: window.origin,
|
2023-02-25 14:20:26 +01:00
|
|
|
slug: this.newFeedSlug,
|
|
|
|
metadataDetails: this.metadataDetails
|
2022-05-04 01:52:34 +02:00
|
|
|
}
|
2022-10-01 23:07:30 +02:00
|
|
|
if (this.$isDev) payload.serverAddress = `http://localhost:3333${this.$config.routerBasePath}`
|
2022-05-04 01:52:34 +02:00
|
|
|
|
|
|
|
console.log('Payload', payload)
|
|
|
|
this.$axios
|
2022-12-31 22:26:37 +01:00
|
|
|
.$post(`/api/feeds/${this.entityType}/${this.entityId}/open`, payload)
|
2022-05-04 01:52:34 +02:00
|
|
|
.then((data) => {
|
2022-12-26 23:58:36 +01:00
|
|
|
console.log('Opened RSS Feed', data)
|
|
|
|
this.currentFeed = data.feed
|
2022-05-04 01:52:34 +02:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to open RSS Feed', error)
|
2022-12-26 23:58:36 +01:00
|
|
|
const errorMsg = error.response ? error.response.data : null
|
|
|
|
this.$toast.error(errorMsg || 'Failed to open RSS Feed')
|
2022-05-04 01:52:34 +02:00
|
|
|
})
|
|
|
|
},
|
2022-05-02 23:42:30 +02:00
|
|
|
copyToClipboard(str) {
|
|
|
|
this.$copyToClipboard(str, this)
|
|
|
|
},
|
|
|
|
closeFeed() {
|
|
|
|
this.processing = true
|
|
|
|
this.$axios
|
2022-12-26 23:58:36 +01:00
|
|
|
.$post(`/api/feeds/${this.currentFeed.id}/close`)
|
2022-05-02 23:42:30 +02:00
|
|
|
.then(() => {
|
2022-11-09 00:10:08 +01:00
|
|
|
this.$toast.success(this.$strings.ToastRSSFeedCloseSuccess)
|
2022-05-02 23:42:30 +02:00
|
|
|
this.show = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to close RSS feed', error)
|
2022-11-09 00:10:08 +01:00
|
|
|
this.$toast.error(this.$strings.ToastRSSFeedCloseFailed)
|
2022-05-02 23:42:30 +02:00
|
|
|
})
|
2022-12-26 23:58:36 +01:00
|
|
|
.finally(() => {
|
|
|
|
this.processing = false
|
|
|
|
})
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
2022-05-04 01:52:34 +02:00
|
|
|
init() {
|
2022-12-31 22:26:37 +01:00
|
|
|
if (!this.entityId) return
|
|
|
|
this.newFeedSlug = this.entityId
|
|
|
|
this.currentFeed = this.entityFeed
|
2022-05-04 01:52:34 +02:00
|
|
|
}
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|