2023-06-22 18:10:30 +00:00
|
|
|
<template>
|
2023-06-24 15:18:27 +00:00
|
|
|
<NcContent app-name="repod">
|
2023-06-23 07:44:48 +00:00
|
|
|
<NcAppNavigation>
|
2023-06-24 22:34:02 +00:00
|
|
|
<NcAppContentList>
|
2023-07-02 16:30:42 +00:00
|
|
|
<router-link to="/discover">
|
|
|
|
<NcAppNavigationNew :text="t('repod', 'Add a podcast')">
|
|
|
|
<template #icon>
|
2023-07-03 14:57:35 +00:00
|
|
|
<Plus size="20" />
|
2023-07-02 16:30:42 +00:00
|
|
|
</template>
|
|
|
|
</NcAppNavigationNew>
|
|
|
|
</router-link>
|
|
|
|
<NcLoadingIcon v-if="loading" />
|
|
|
|
<ul v-if="!loading">
|
2023-06-24 22:34:02 +00:00
|
|
|
<NcAppNavigationItem v-for="subscription in subscriptions"
|
|
|
|
:key="subscription.id"
|
|
|
|
:loading="subscription.loading"
|
|
|
|
:title="subscription.title ?? subscription.url">
|
|
|
|
<template #icon>
|
|
|
|
<img :src="subscription.imageUrl" alt="">
|
|
|
|
</template>
|
|
|
|
</NcAppNavigationItem>
|
|
|
|
</ul>
|
|
|
|
</NcAppContentList>
|
2023-06-23 07:44:48 +00:00
|
|
|
</NcAppNavigation>
|
2023-07-02 16:30:42 +00:00
|
|
|
<NcAppContent>
|
|
|
|
<router-view />
|
|
|
|
</NcAppContent>
|
2023-06-24 15:18:27 +00:00
|
|
|
</NcContent>
|
2023-06-22 18:10:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-02 16:30:42 +00:00
|
|
|
import '@nextcloud/dialogs/dist/index.css'
|
|
|
|
import {
|
|
|
|
NcAppContent,
|
|
|
|
NcAppContentList,
|
|
|
|
NcAppNavigation,
|
|
|
|
NcAppNavigationItem,
|
|
|
|
NcAppNavigationNew,
|
|
|
|
NcContent,
|
|
|
|
NcLoadingIcon,
|
|
|
|
} from '@nextcloud/vue'
|
2023-06-24 22:34:02 +00:00
|
|
|
import Plus from 'vue-material-design-icons/Plus.vue'
|
|
|
|
import axios from '@nextcloud/axios'
|
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2023-07-02 16:30:42 +00:00
|
|
|
import { showError } from '@nextcloud/dialogs'
|
2023-06-22 18:10:30 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'App',
|
|
|
|
components: {
|
2023-06-23 07:44:48 +00:00
|
|
|
NcAppContent,
|
2023-06-24 22:34:02 +00:00
|
|
|
NcAppContentList,
|
2023-06-23 07:44:48 +00:00
|
|
|
NcAppNavigation,
|
|
|
|
NcAppNavigationItem,
|
|
|
|
NcAppNavigationNew,
|
2023-06-24 22:34:02 +00:00
|
|
|
NcContent,
|
2023-07-02 16:30:42 +00:00
|
|
|
NcLoadingIcon,
|
2023-06-24 22:34:02 +00:00
|
|
|
Plus,
|
2023-06-22 18:10:30 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-06-24 22:34:02 +00:00
|
|
|
subscriptions: [],
|
|
|
|
loading: true,
|
2023-06-22 18:10:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
},
|
|
|
|
async mounted() {
|
2023-06-24 22:34:02 +00:00
|
|
|
try {
|
|
|
|
const metrics = await axios.get(generateUrl('/apps/gpoddersync/personal_settings/metrics'))
|
|
|
|
for (const subscriptionId in metrics.data.subscriptions) {
|
|
|
|
this.addSubscription({
|
|
|
|
id: subscriptionId,
|
|
|
|
url: metrics.data.subscriptions[subscriptionId].url,
|
|
|
|
loading: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for (const subscription of this.subscriptions) {
|
|
|
|
this.updateSubscriptionMeta(subscription)
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
showError(t('repod', 'Could not fetch subscriptions'))
|
|
|
|
}
|
|
|
|
this.loading = false
|
2023-06-22 18:10:30 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-06-24 22:34:02 +00:00
|
|
|
addSubscription(subscription) {
|
|
|
|
const subscriptionId = this.subscriptions.findIndex(sub => sub.url === subscription.url)
|
|
|
|
|
|
|
|
if (subscriptionId === -1) {
|
|
|
|
this.subscriptions.push(subscription)
|
|
|
|
} else {
|
|
|
|
this.subscriptions[subscriptionId] = subscription
|
|
|
|
}
|
|
|
|
|
|
|
|
this.subscriptions.sort((a, b) => {
|
|
|
|
if (a.title && b.title) return a.title.localeCompare(b.title)
|
|
|
|
return a.id - b.id
|
|
|
|
})
|
|
|
|
},
|
|
|
|
async updateSubscriptionMeta(subscription) {
|
|
|
|
try {
|
|
|
|
const podcasts = await axios.get(generateUrl('/apps/gpoddersync/personal_settings/podcast_data?url={url}', { url: subscription.url }))
|
|
|
|
this.addSubscription({ ...podcasts.data.data, ...subscription, ...{ loading: false } })
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
},
|
2023-06-22 18:10:30 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|