82 lines
1.9 KiB
Vue
Raw Normal View History

2023-08-24 00:42:01 +02:00
<template>
2023-08-24 17:43:10 +02:00
<fragment>
<NcLoadingIcon v-if="loading" />
<ul v-if="!loading">
<NcListItem v-for="episode in episodes"
:key="episode.episodeUrl"
2023-08-24 20:53:54 +02:00
:details="formatTimeAgo(new Date(episode.episodePubDate.date))"
:force-display-actions="true"
:name="episode.episodeName"
:title="episode.episodeDescription">
<template #icon>
<NcAvatar :display-name="episode.episodeName"
:is-no-user="true"
:url="episode.episodeImage" />
</template>
<template #subname>
2023-08-24 22:29:11 +02:00
{{ format(new Date(episode.episodeDuration*1000), 'H:mm:ss') }}
2023-08-24 20:53:54 +02:00
</template>
<template #actions>
2023-08-24 23:19:54 +02:00
<NcActionButton @click="play(episode)">
2023-08-24 20:53:54 +02:00
<template #icon>
<Play :size="20" />
</template>
2023-08-24 22:29:11 +02:00
{{ t('Play') }}
2023-08-24 20:53:54 +02:00
</NcActionButton>
</template>
</NcListItem>
2023-08-24 17:43:10 +02:00
</ul>
</fragment>
2023-08-24 00:42:01 +02:00
</template>
<script>
2023-08-24 20:53:54 +02:00
import { NcActionButton, NcAvatar, NcListItem, NcLoadingIcon } from '@nextcloud/vue'
import Play from 'vue-material-design-icons/Play.vue'
2023-08-24 17:43:10 +02:00
import axios from '@nextcloud/axios'
2023-08-24 20:53:54 +02:00
import { format } from 'date-format-parse'
import { formatTimeAgo } from '../../utils/time.js'
2023-08-24 17:43:10 +02:00
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
2023-08-24 00:42:01 +02:00
export default {
name: 'List',
2023-08-24 17:43:10 +02:00
components: {
2023-08-24 20:53:54 +02:00
NcActionButton,
NcAvatar,
2023-08-24 17:43:10 +02:00
NcListItem,
NcLoadingIcon,
2023-08-24 20:53:54 +02:00
Play,
2023-08-24 17:43:10 +02:00
},
data() {
return {
episodes: [],
loading: true,
}
},
computed: {
url() {
return atob(this.$route.params.url)
},
},
async mounted() {
try {
this.loading = true
const episodes = await axios.get(generateUrl('/apps/repod/episodes?url={url}', { url: this.url }))
this.episodes = episodes.data
} catch (e) {
console.error(e)
showError(t('Could not fetch episodes'))
} finally {
this.loading = false
}
},
2023-08-24 20:53:54 +02:00
methods: {
format,
formatTimeAgo,
2023-08-24 23:19:54 +02:00
play(episode) {
this.$store.commit('player/play', episode)
},
2023-08-24 20:53:54 +02:00
},
2023-08-24 00:42:01 +02:00
}
</script>