2023-07-10 00:25:32 +02:00
|
|
|
<template>
|
|
|
|
<NcAppNavigationItem :loading="loading"
|
2023-08-23 00:30:38 +02:00
|
|
|
:name="feed ? feed.title : url"
|
2023-08-02 11:33:48 +02:00
|
|
|
:to="toUrl">
|
2023-07-10 00:25:32 +02:00
|
|
|
<template #icon>
|
2023-07-29 17:53:51 +02:00
|
|
|
<NcAvatar v-if="feed"
|
|
|
|
:display-name="feed.author"
|
|
|
|
:is-no-user="true"
|
|
|
|
:url="feed.imageUrl" />
|
2023-07-10 00:25:32 +02:00
|
|
|
<Alert v-if="failed" />
|
|
|
|
</template>
|
2023-07-25 22:19:16 +02:00
|
|
|
<template #actions>
|
|
|
|
<NcActionButton @click="deleteSubscription">
|
|
|
|
<template #icon>
|
|
|
|
<Delete :size="20" />
|
|
|
|
</template>
|
2024-01-10 15:25:54 +01:00
|
|
|
{{ t('repod', 'Delete') }}
|
2023-07-25 22:19:16 +02:00
|
|
|
</NcActionButton>
|
|
|
|
</template>
|
2023-07-10 00:25:32 +02:00
|
|
|
</NcAppNavigationItem>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-29 17:53:51 +02:00
|
|
|
import { NcActionButton, NcAppNavigationItem, NcAvatar } from '@nextcloud/vue'
|
2023-07-10 00:25:32 +02:00
|
|
|
import Alert from 'vue-material-design-icons/Alert.vue'
|
2023-07-25 22:19:16 +02:00
|
|
|
import Delete from 'vue-material-design-icons/Delete.vue'
|
2023-07-10 00:25:32 +02:00
|
|
|
import axios from '@nextcloud/axios'
|
2024-01-11 21:41:37 +01:00
|
|
|
import { encodeUrl } from '../../utils/url.js'
|
2023-07-10 00:25:32 +02:00
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2023-07-25 22:19:16 +02:00
|
|
|
import { showError } from '@nextcloud/dialogs'
|
2023-07-10 00:25:32 +02:00
|
|
|
|
|
|
|
export default {
|
2023-08-23 10:11:39 +02:00
|
|
|
name: 'Item',
|
2023-07-10 00:25:32 +02:00
|
|
|
components: {
|
|
|
|
Alert,
|
2023-07-25 22:19:16 +02:00
|
|
|
Delete,
|
|
|
|
NcActionButton,
|
2023-07-10 00:25:32 +02:00
|
|
|
NcAppNavigationItem,
|
2023-07-29 17:53:51 +02:00
|
|
|
NcAvatar,
|
2023-07-10 00:25:32 +02:00
|
|
|
},
|
|
|
|
props: {
|
2023-08-01 23:18:37 +02:00
|
|
|
url: {
|
2023-07-10 00:25:32 +02:00
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
failed: false,
|
|
|
|
loading: true,
|
2023-07-29 17:53:51 +02:00
|
|
|
feed: null,
|
2023-07-10 00:25:32 +02:00
|
|
|
}
|
|
|
|
},
|
2023-08-02 11:33:48 +02:00
|
|
|
computed: {
|
|
|
|
toUrl() {
|
2024-01-11 21:41:37 +01:00
|
|
|
return `/${encodeUrl(this.url)}`
|
2023-08-02 11:33:48 +02:00
|
|
|
},
|
|
|
|
},
|
2023-07-10 00:25:32 +02:00
|
|
|
async mounted() {
|
|
|
|
try {
|
2023-08-01 23:18:37 +02:00
|
|
|
const podcastData = await axios.get(generateUrl('/apps/gpoddersync/personal_settings/podcast_data?url={url}', { url: this.url }))
|
2023-07-29 17:53:51 +02:00
|
|
|
this.feed = podcastData.data.data
|
2023-07-10 00:25:32 +02:00
|
|
|
} catch (e) {
|
|
|
|
this.failed = true
|
|
|
|
console.error(e)
|
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
}
|
|
|
|
},
|
2023-07-25 22:19:16 +02:00
|
|
|
methods: {
|
|
|
|
async deleteSubscription() {
|
2024-01-10 16:36:37 +01:00
|
|
|
if (confirm(t('repod', 'Are you sure you want to delete this subscription?'))) {
|
|
|
|
try {
|
|
|
|
this.loading = true
|
|
|
|
await axios.post(generateUrl('/apps/gpoddersync/subscription_change/create'), { add: [], remove: [this.url] })
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
showError(t('repod', 'Error while removing the feed'))
|
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
this.$store.dispatch('subscriptions/fetch')
|
|
|
|
}
|
2023-07-25 22:19:16 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2023-07-10 00:25:32 +02:00
|
|
|
}
|
|
|
|
</script>
|