repod/src/components/Discover/TopList.vue
Michel Roux 72ef60f23c
All checks were successful
repod / nextcloud (push) Successful in 2m3s
repod / nodejs (push) Successful in 2m37s
Subscribe button working
2023-08-23 17:54:09 +02:00

73 lines
1.3 KiB
Vue

<template>
<fragment>
<p>
<span>{{ t('Discover') }}</span>
</p>
<p>
<NcLoadingIcon v-if="loading" />
<ul v-if="!loading" class="tops">
<li v-for="top in tops" :key="top.link">
<TopItem :author="top.author"
:image-url="top.imageUrl"
:link="top.link"
:title="top.title" />
</li>
</ul>
<span class="caption">{{ t('Suggests by fyyd') }}</span>
</p>
</fragment>
</template>
<script>
import { NcLoadingIcon } from '@nextcloud/vue'
import TopItem from './TopItem.vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
export default {
name: 'TopList',
components: {
NcLoadingIcon,
TopItem,
},
data() {
return {
tops: [],
loading: true,
}
},
async mounted() {
try {
this.loading = true
const toplist = await axios.get(generateUrl('/apps/repod/toplist'))
this.tops = toplist.data
} catch (e) {
console.error(e)
showError(t('Could not fetch tops'))
} finally {
this.loading = false
}
},
}
</script>
<style scoped>
.caption {
float: right;
font-size: small;
margin: .5rem;
}
.tops {
display: flex;
flex-wrap: wrap;
gap: 2rem 5%;
justify-content: center;
}
.tops li {
flex-basis: 15%;
}
</style>