2023-08-24 00:42:01 +02:00
|
|
|
<template>
|
2023-12-24 10:18:21 +01:00
|
|
|
<div>
|
2023-12-23 22:49:23 +01:00
|
|
|
<Loading v-if="loading" />
|
2023-12-24 10:18:21 +01:00
|
|
|
<AdaptativeList v-if="!loading">
|
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-30 09:27:12 +02:00
|
|
|
:active="isCurrentEpisode(episode)"
|
2023-08-30 19:59:20 +02:00
|
|
|
:class="episode.episodeAction && episode.episodeAction.position >= episode.episodeAction.total ? 'ended': ''"
|
2023-12-23 23:56:29 +01:00
|
|
|
:details="moment(episode.episodePubDate.date).fromNow()"
|
2023-08-24 20:53:54 +02:00
|
|
|
:force-display-actions="true"
|
|
|
|
:name="episode.episodeName"
|
2023-12-24 16:34:27 +01:00
|
|
|
:title="episode.episodeDescription"
|
|
|
|
@click="modalEpisode = episode">
|
2023-08-24 20:53:54 +02:00
|
|
|
<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-29 11:43:17 +02:00
|
|
|
<NcActionButton v-if="!isCurrentEpisode(episode)" @click="load(episode)">
|
2023-08-24 20:53:54 +02:00
|
|
|
<template #icon>
|
2023-08-29 11:43:17 +02:00
|
|
|
<PlayButton :size="20" />
|
2023-08-24 20:53:54 +02:00
|
|
|
</template>
|
2023-08-29 11:43:17 +02:00
|
|
|
{{ t('Play') }}
|
|
|
|
</NcActionButton>
|
|
|
|
<NcActionButton v-if="isCurrentEpisode(episode)" @click="load(null)">
|
|
|
|
<template #icon>
|
|
|
|
<StopButton :size="20" />
|
|
|
|
</template>
|
|
|
|
{{ t('Stop') }}
|
2023-08-24 20:53:54 +02:00
|
|
|
</NcActionButton>
|
|
|
|
</template>
|
|
|
|
</NcListItem>
|
2023-12-24 10:18:21 +01:00
|
|
|
</AdaptativeList>
|
2023-12-24 16:34:27 +01:00
|
|
|
<NcModal v-if="modalEpisode"
|
|
|
|
size="small"
|
|
|
|
@close="modalEpisode = null">
|
|
|
|
<div class="modal-content">
|
|
|
|
<NcAvatar :display-name="modalEpisode.episodeName"
|
|
|
|
:is-no-user="true"
|
|
|
|
size="256"
|
|
|
|
:url="modalEpisode.episodeImage" />
|
|
|
|
<h2>{{ modalEpisode.episodeName }}</h2>
|
|
|
|
{{ modalEpisode.episodeDescription }}
|
|
|
|
<div class="modal-buttons">
|
|
|
|
<NcButton v-if="modalEpisode.episodeLink" :href="modalEpisode.episodeLink" target="_blank">
|
|
|
|
<template #icon>
|
|
|
|
<OpenInNew :size="20" />
|
|
|
|
</template>
|
|
|
|
{{ modalEpisode.podcastName }}
|
|
|
|
</NcButton>
|
|
|
|
<NcButton v-if="modalEpisode.episodeUrl" :href="modalEpisode.episodeUrl" target="_blank">
|
|
|
|
<template #icon>
|
|
|
|
<Download :size="20" />
|
|
|
|
</template>
|
|
|
|
{{ t('Download') }}
|
|
|
|
</NcButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</NcModal>
|
2023-08-28 21:18:14 +02:00
|
|
|
</div>
|
2023-08-24 00:42:01 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-12-24 16:34:27 +01:00
|
|
|
import { NcActionButton, NcAvatar, NcButton, NcListItem, NcModal } from '@nextcloud/vue'
|
2023-12-24 10:18:21 +01:00
|
|
|
import AdaptativeList from '../Atoms/AdaptativeList.vue'
|
2023-12-24 16:34:27 +01:00
|
|
|
import Download from 'vue-material-design-icons/Download.vue'
|
2023-12-23 22:49:23 +01:00
|
|
|
import Loading from '../Atoms/Loading.vue'
|
2023-12-24 16:34:27 +01:00
|
|
|
import OpenInNew from 'vue-material-design-icons/OpenInNew.vue'
|
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'
|
2023-12-23 23:56:29 +01:00
|
|
|
import { formatTimer } from '../../utils/time.js'
|
2023-08-24 17:43:10 +02:00
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2023-12-23 23:56:29 +01:00
|
|
|
import moment from '@nextcloud/moment'
|
2023-08-24 17:43:10 +02:00
|
|
|
import { showError } from '@nextcloud/dialogs'
|
|
|
|
|
2023-08-24 00:42:01 +02:00
|
|
|
export default {
|
2023-08-30 09:27:12 +02:00
|
|
|
name: 'Episodes',
|
2023-08-24 17:43:10 +02:00
|
|
|
components: {
|
2023-12-24 10:18:21 +01:00
|
|
|
AdaptativeList,
|
2023-12-24 16:34:27 +01:00
|
|
|
Download,
|
2023-12-23 22:49:23 +01:00
|
|
|
Loading,
|
2023-08-24 20:53:54 +02:00
|
|
|
NcActionButton,
|
|
|
|
NcAvatar,
|
2023-12-24 16:34:27 +01:00
|
|
|
NcButton,
|
2023-08-24 17:43:10 +02:00
|
|
|
NcListItem,
|
2023-12-24 16:34:27 +01:00
|
|
|
NcModal,
|
|
|
|
OpenInNew,
|
2023-08-27 22:48:21 +02:00
|
|
|
PlayButton,
|
|
|
|
StopButton,
|
2023-08-24 17:43:10 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
episodes: [],
|
|
|
|
loading: true,
|
2023-12-24 16:34:27 +01:00
|
|
|
modalEpisode: null,
|
2023-08-24 17:43:10 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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
|
2023-08-29 08:48:54 +02:00
|
|
|
const episodes = await axios.get(generateUrl('/apps/repod/episodes/list?url={url}', { url: this.url }))
|
2023-08-24 17:43:10 +02:00
|
|
|
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-12-23 23:56:29 +01:00
|
|
|
moment,
|
2023-08-27 22:48:21 +02:00
|
|
|
isCurrentEpisode(episode) {
|
|
|
|
return this.currentEpisode && this.currentEpisode.episodeUrl === episode.episodeUrl
|
|
|
|
},
|
2023-08-29 00:47:22 +02:00
|
|
|
load(episode) {
|
2023-08-29 08:48:54 +02:00
|
|
|
this.$store.dispatch('player/load', episode)
|
2023-08-24 23:19:54 +02:00
|
|
|
},
|
2023-08-24 20:53:54 +02:00
|
|
|
},
|
2023-08-24 00:42:01 +02:00
|
|
|
}
|
|
|
|
</script>
|
2023-08-30 19:59:20 +02:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.ended {
|
|
|
|
opacity: .5;
|
|
|
|
}
|
2023-12-24 16:34:27 +01:00
|
|
|
|
|
|
|
.modal-content {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
gap: 2rem;
|
|
|
|
margin: 2rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal-buttons {
|
|
|
|
display: flex;
|
|
|
|
gap: 1rem;
|
|
|
|
}
|
2023-08-30 19:59:20 +02:00
|
|
|
</style>
|