84 lines
1.9 KiB
Vue
Raw Normal View History

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"
:to="toUrl(url)">
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 || feed.title"
2023-07-29 17:53:51 +02:00
: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'
import { generateUrl } from '@nextcloud/router'
2023-07-25 22:19:16 +02:00
import { showError } from '@nextcloud/dialogs'
import { toUrl } from '../../utils/url.js'
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: {
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
}
},
async mounted() {
try {
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: {
toUrl,
2023-07-25 22:19:16 +02:00
async deleteSubscription() {
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>