2023-08-24 00:42:01 +02:00
|
|
|
<template>
|
2023-08-28 21:18:14 +02:00
|
|
|
<div>
|
2023-08-24 17:43:10 +02:00
|
|
|
<NcLoadingIcon v-if="loading" />
|
2023-08-28 08:14:16 +02:00
|
|
|
<ul v-if="!loading" :style="{marginBottom: currentEpisode ? '6rem' : 'auto'}">
|
2023-08-24 17:43:10 +02:00
|
|
|
<NcListItem v-for="episode in episodes"
|
2023-08-28 17:44:17 +02:00
|
|
|
:key="episode.episodeGuid"
|
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-27 20:29:54 +02:00
|
|
|
{{ formatTimer(new Date(episode.episodeDuration*1000)) }}
|
2023-08-24 20:53:54 +02:00
|
|
|
</template>
|
|
|
|
<template #actions>
|
2023-08-27 22:48:21 +02:00
|
|
|
<NcActionButton @click="isCurrentEpisode(episode) ? play(null) : play(episode)">
|
2023-08-24 20:53:54 +02:00
|
|
|
<template #icon>
|
2023-08-27 22:48:21 +02:00
|
|
|
<PlayButton v-if="!isCurrentEpisode(episode)" :size="20" />
|
|
|
|
<StopButton v-if="isCurrentEpisode(episode)" :size="20" />
|
2023-08-24 20:53:54 +02:00
|
|
|
</template>
|
2023-08-27 22:48:21 +02:00
|
|
|
{{ isCurrentEpisode(episode) ? t('Stop') : t('Play') }}
|
2023-08-24 20:53:54 +02:00
|
|
|
</NcActionButton>
|
|
|
|
</template>
|
|
|
|
</NcListItem>
|
2023-08-24 17:43:10 +02:00
|
|
|
</ul>
|
2023-08-28 21:18:14 +02:00
|
|
|
</div>
|
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'
|
2023-08-27 20:29:54 +02:00
|
|
|
import { formatTimeAgo, formatTimer } from '../../utils/time.js'
|
2023-08-27 22:48:21 +02:00
|
|
|
import PlayButton from 'vue-material-design-icons/Play.vue'
|
|
|
|
import StopButton from 'vue-material-design-icons/Stop.vue'
|
2023-08-24 17:43:10 +02:00
|
|
|
import axios from '@nextcloud/axios'
|
|
|
|
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-27 22:48:21 +02:00
|
|
|
PlayButton,
|
|
|
|
StopButton,
|
2023-08-24 17:43:10 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
episodes: [],
|
|
|
|
loading: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2023-08-27 22:48:21 +02:00
|
|
|
currentEpisode() {
|
2023-08-24 23:59:55 +02:00
|
|
|
return this.$store.state.player.episode
|
|
|
|
},
|
2023-08-24 17:43:10 +02:00
|
|
|
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: {
|
2023-08-27 20:29:54 +02:00
|
|
|
formatTimer,
|
2023-08-24 20:53:54 +02:00
|
|
|
formatTimeAgo,
|
2023-08-27 22:48:21 +02:00
|
|
|
isCurrentEpisode(episode) {
|
|
|
|
return this.currentEpisode && this.currentEpisode.episodeUrl === episode.episodeUrl
|
|
|
|
},
|
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>
|