2023-07-02 22:12:40 +00:00
|
|
|
<template>
|
|
|
|
<fragment>
|
2023-07-03 06:42:00 +00:00
|
|
|
<p class="more">
|
2023-07-03 15:30:09 +00:00
|
|
|
<span>{{ t('Discover') }}</span>
|
2023-07-25 19:44:25 +00:00
|
|
|
<NcSelect v-model="count"
|
|
|
|
class="select"
|
|
|
|
:components="{Deselect: {}}"
|
|
|
|
:options="[...Array(10).keys()].map(x=>(x+1)*10)"
|
|
|
|
@input="fetch" />
|
2023-07-03 06:42:00 +00:00
|
|
|
</p>
|
2023-07-02 22:12:40 +00:00
|
|
|
<p>
|
|
|
|
<NcLoadingIcon v-if="loading" />
|
|
|
|
<ul v-if="!loading" class="tops">
|
2023-07-25 19:44:25 +00:00
|
|
|
<li v-for="top in tops" :key="top.id">
|
|
|
|
<img :src="top.imgURL" :alt="top.author" :title="top.author">
|
2023-07-02 22:12:40 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
2023-07-25 19:44:25 +00:00
|
|
|
<span class="caption">{{ t('Suggests by fyyd') }}</span>
|
2023-07-02 22:12:40 +00:00
|
|
|
</p>
|
|
|
|
</fragment>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-25 19:44:25 +00:00
|
|
|
import { NcLoadingIcon, NcSelect } from '@nextcloud/vue'
|
2023-07-02 22:12:40 +00:00
|
|
|
import axios from '@nextcloud/axios'
|
|
|
|
import { generateUrl } from '@nextcloud/router'
|
|
|
|
import { showError } from '@nextcloud/dialogs'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Top',
|
|
|
|
components: {
|
|
|
|
NcLoadingIcon,
|
2023-07-25 19:44:25 +00:00
|
|
|
NcSelect,
|
2023-07-02 22:12:40 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
tops: [],
|
|
|
|
loading: true,
|
2023-07-25 19:44:25 +00:00
|
|
|
count: 10,
|
2023-07-02 22:12:40 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async mounted() {
|
2023-07-25 19:44:25 +00:00
|
|
|
await this.fetch()
|
2023-07-02 22:12:40 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-07-25 19:44:25 +00:00
|
|
|
async fetch() {
|
2023-07-02 22:12:40 +00:00
|
|
|
this.loading = true
|
|
|
|
|
|
|
|
try {
|
2023-07-25 19:44:25 +00:00
|
|
|
const top = await axios.get(generateUrl('/apps/repod/top/{count}', { count: this.count }))
|
|
|
|
this.tops = top.data.data
|
2023-07-02 22:12:40 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
2023-07-03 15:30:09 +00:00
|
|
|
showError(t('Could not fetch tops'))
|
2023-07-02 22:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.tops {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
gap: 2rem 5%;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tops li {
|
|
|
|
flex-basis: 15%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tops li img {
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2023-07-03 06:42:00 +00:00
|
|
|
|
2023-07-25 19:44:25 +00:00
|
|
|
.select {
|
|
|
|
min-width: 160px;
|
|
|
|
}
|
|
|
|
|
2023-07-03 06:42:00 +00:00
|
|
|
.more {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.caption {
|
|
|
|
float: right;
|
|
|
|
font-size: small;
|
|
|
|
margin: .5rem;
|
|
|
|
}
|
2023-07-02 22:12:40 +00:00
|
|
|
</style>
|