Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

HomeView.vue 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template lang="pug">
  2. main.view--home.f-col.start.w-full
  3. header
  4. h2 home - profile: {{ pid }}
  5. article(v-if="cards.length && !loading")
  6. ProfileCardList(:profiles="cards" :pid="pid" @reload="getCards")
  7. p(v-else) Loading...
  8. MainNav(@show-sidebar="$emit('show-sidebar')")
  9. </template>
  10. <script>
  11. import ProfileCardList from '../components/ProfileCardList.vue'
  12. import { Card } from '../entities'
  13. import { fetchQueueByProfileId } from '../services'
  14. import { mixins } from '../utils'
  15. /** Callback used to format incoming into card */
  16. const convertToCard = profile => {
  17. if(profile.type !== 'profile') {
  18. console.error(`Cannot convert ${profile} to Card. Invalid entity.`)
  19. }
  20. if(!profile.isValid()) {
  21. console.warn(`Profile ${profile.profile_id} is not a valid profile.`)
  22. }
  23. return new Card({
  24. pid: profile.profile_id,
  25. name: profile.user_name,
  26. avatar: profile.profile_media[0],
  27. })
  28. }
  29. export default {
  30. name: 'HomeView',
  31. components: { ProfileCardList },
  32. mixins: [ mixins.pidMixin, mixins.cardMixin ],
  33. methods: {
  34. /** Gets called from cardMixin */
  35. async getCards() {
  36. this.loading = true
  37. try {
  38. const queueList = await fetchQueueByProfileId(this.pid)
  39. this.cards = this._reformat(queueList, convertToCard)
  40. } catch (err) { console.error(err) }
  41. this.loading = false
  42. },
  43. },
  44. }
  45. </script>
  46. <style lang="postcss">
  47. main
  48. position: relative
  49. height: 100%
  50. > article
  51. height: 100%
  52. width: 100%
  53. flex-direction: column
  54. input, button
  55. position: relative
  56. z-index: 1000
  57. </style>