2024-01-14 01:07:55 +01:00
|
|
|
<template>
|
|
|
|
<div>
|
2024-01-15 10:11:03 +01:00
|
|
|
<h2>{{ title }}</h2>
|
2024-01-14 01:07:55 +01:00
|
|
|
<Loading v-if="loading" />
|
|
|
|
<ul v-if="!loading">
|
2024-01-17 22:38:47 +01:00
|
|
|
<li v-for="top in tops" :key="top.link">
|
2024-08-27 09:42:52 +02:00
|
|
|
<router-link :to="toFeedUrl(top.link)">
|
2024-04-30 00:48:47 +02:00
|
|
|
<img :src="top.imageUrl" :title="top.author" />
|
2024-01-14 01:07:55 +01:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2024-09-13 12:35:08 +02:00
|
|
|
<script lang="ts">
|
2024-01-14 01:07:55 +01:00
|
|
|
import Loading from '../Atoms/Loading.vue'
|
2024-09-13 12:35:08 +02:00
|
|
|
import type { PodcastDataInterface } from '../../utils/types.ts'
|
2024-01-14 01:07:55 +01:00
|
|
|
import axios from '@nextcloud/axios'
|
|
|
|
import { generateUrl } from '@nextcloud/router'
|
2024-09-13 08:56:04 +02:00
|
|
|
import { showError } from '../../utils/toast.ts'
|
2024-09-13 12:35:08 +02:00
|
|
|
import { t } from '@nextcloud/l10n'
|
2024-09-13 08:56:04 +02:00
|
|
|
import { toFeedUrl } from '../../utils/url.ts'
|
2024-01-14 01:07:55 +01:00
|
|
|
|
|
|
|
export default {
|
2024-02-20 21:31:38 +01:00
|
|
|
name: 'Toplist',
|
2024-01-14 01:07:55 +01:00
|
|
|
components: {
|
|
|
|
Loading,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2024-08-22 13:30:52 +02:00
|
|
|
data: () => ({
|
|
|
|
loading: true,
|
2024-09-13 12:35:08 +02:00
|
|
|
tops: [] as PodcastDataInterface[],
|
2024-08-22 13:30:52 +02:00
|
|
|
}),
|
2024-01-15 10:11:03 +01:00
|
|
|
computed: {
|
|
|
|
title() {
|
|
|
|
switch (this.type) {
|
2024-04-30 00:48:47 +02:00
|
|
|
case 'new':
|
|
|
|
return t('repod', 'New podcasts')
|
|
|
|
case 'hot':
|
|
|
|
return t('repod', 'Hot podcasts')
|
|
|
|
default:
|
|
|
|
return this.type
|
2024-01-15 10:11:03 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2024-01-14 01:07:55 +01:00
|
|
|
async mounted() {
|
2024-01-17 22:38:47 +01:00
|
|
|
try {
|
|
|
|
this.loading = true
|
2024-09-13 16:33:48 +02:00
|
|
|
const tops = await axios.get<PodcastDataInterface[]>(
|
|
|
|
generateUrl('/apps/repod/toplist/{type}', { type: this.type }),
|
2024-05-06 12:47:47 +00:00
|
|
|
)
|
2024-01-17 22:38:47 +01:00
|
|
|
this.tops = tops.data
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
showError(t('repod', 'Could not fetch tops'))
|
|
|
|
} finally {
|
|
|
|
this.loading = false
|
|
|
|
}
|
2024-01-14 01:07:55 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2024-08-27 09:42:52 +02:00
|
|
|
toFeedUrl,
|
2024-01-14 01:07:55 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2024-04-30 00:48:47 +02:00
|
|
|
h2 {
|
|
|
|
margin: 1rem 0;
|
|
|
|
}
|
2024-01-14 01:07:55 +01:00
|
|
|
|
2024-04-30 00:48:47 +02:00
|
|
|
img {
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2024-01-14 01:07:55 +01:00
|
|
|
|
2024-04-30 00:48:47 +02:00
|
|
|
li {
|
|
|
|
flex-basis: 10rem;
|
|
|
|
flex-shrink: 0;
|
|
|
|
}
|
2024-01-14 01:07:55 +01:00
|
|
|
|
2024-04-30 00:48:47 +02:00
|
|
|
ul {
|
|
|
|
display: flex;
|
|
|
|
gap: 2rem;
|
|
|
|
overflow: scroll hidden;
|
|
|
|
padding-bottom: 0.5rem;
|
|
|
|
}
|
2024-01-14 01:07:55 +01:00
|
|
|
</style>
|