repod/src/components/AddRss.vue

48 lines
1.0 KiB
Vue
Raw Normal View History

2023-07-07 14:35:14 +00:00
<template>
<ul>
2023-07-08 22:07:21 +00:00
<NcAppNavigationNewItem :loading="loading"
:title="t('Add a RSS link')"
@new-item="addSubscription">
2023-07-07 14:35:14 +00:00
<template #icon>
2023-07-07 16:38:53 +00:00
<Plus :size="20" />
2023-07-07 14:35:14 +00:00
</template>
</NcAppNavigationNewItem>
</ul>
</template>
<script>
import { NcAppNavigationNewItem } from '@nextcloud/vue'
import Plus from 'vue-material-design-icons/Plus.vue'
2023-07-08 22:07:21 +00:00
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
2023-07-07 14:35:14 +00:00
export default {
name: 'AddRss',
components: {
NcAppNavigationNewItem,
Plus,
},
2023-07-08 22:07:21 +00:00
data() {
return {
loading: false,
feedUrl: '',
}
},
2023-07-07 14:35:14 +00:00
methods: {
2023-07-08 22:07:21 +00:00
async addSubscription(feedUrl) {
try {
2023-07-27 23:52:48 +00:00
this.loading = true
2023-07-08 22:07:21 +00:00
await axios.post(generateUrl('/apps/gpoddersync/subscription_change/create'), { add: [feedUrl], remove: [] })
} catch (e) {
console.error(e)
showError(t('Error while adding the feed'))
2023-07-27 23:52:48 +00:00
} finally {
this.loading = false
this.$store.dispatch('subscriptions/fetch')
2023-07-08 22:07:21 +00:00
}
},
2023-07-07 14:35:14 +00:00
},
}
</script>