Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

HomeView.vue 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template lang="pug">
  2. main.view--home
  3. article(v-if='cards.length && !loading')
  4. ProfileCardList(:pid='pid' :cards='cards' @reload='getCards')
  5. p(v-else-if='cards.length === 0') No profiles in match_queue.
  6. w-spinner(v-else bounce)
  7. footer
  8. w-form
  9. w-input.mb2(
  10. inner-icon-left='mdi mdi-account'
  11. label='Full Name'
  12. label-position='inside'
  13. outline
  14. )
  15. w-input.mb2(
  16. inner-icon-left='mdi mdi-mail'
  17. label='E-mail'
  18. label-position='inside'
  19. outline
  20. )
  21. w-input.mb2(
  22. inner-icon-left='mdi mdi-lock'
  23. label='Password'
  24. label-position='inside'
  25. outline
  26. type='password'
  27. )
  28. MainNav
  29. </template>
  30. <script>
  31. import 'wave-ui/dist/wave-ui.css'
  32. import ProfileCardList from '../components/ProfileCardList.vue'
  33. import TagList from '../components/TagList.vue'
  34. import AspectBar from '../components/AspectBar.vue'
  35. import SummaryBar from '../components/SummaryBar.vue'
  36. import PairingButton from '../components/PairingButton.vue'
  37. import { Card } from '../entities'
  38. import {
  39. fetchQueueByProfileId,
  40. fetchMembershipsByProfileId,
  41. currentProfile,
  42. } from '../services'
  43. import { mixins } from '../utils'
  44. /** Callback used to format incoming into card */
  45. const convertToCard = profile => {
  46. if (profile.type !== 'profile') {
  47. console.error(`Cannot convert ${profile} to Card. Invalid entity.`)
  48. }
  49. if (!profile.isValid()) {
  50. console.warn(`Profile ${profile.profile_id} is not a valid profile.`)
  51. }
  52. return new Card({
  53. pid: profile.profile_id,
  54. name: profile.user_name,
  55. avatar: profile.profile_media[0],
  56. })
  57. }
  58. const converGroupingToCard = grouping => {
  59. if (grouping.type !== 'grouping') {
  60. console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
  61. }
  62. if (!grouping.profile.isValid()) {
  63. console.warn(`Profile in ${grouping} is not a valid profile.`)
  64. }
  65. return new Card({
  66. pid: grouping.profile.profile_id,
  67. name: grouping.profile.user_name,
  68. avatar: grouping.profile.profile_media[0],
  69. })
  70. }
  71. export default {
  72. name: 'HomeView',
  73. components: {
  74. ProfileCardList,
  75. AspectBar,
  76. TagList,
  77. SummaryBar,
  78. PairingButton,
  79. },
  80. mixins: [mixins.pidMixin, mixins.cardMixin],
  81. methods: {
  82. /** Gets called from cardMixin */
  83. async getCards() {
  84. this.loading = true
  85. try {
  86. const queueList = await fetchQueueByProfileId(this.pid)
  87. this.cards = this._reformat(queueList, convertToCard)
  88. const matchList = await fetchMembershipsByProfileId(this.pid)
  89. this.matches = this._reformat(matchList, converGroupingToCard)
  90. } catch (err) {
  91. console.error(err)
  92. }
  93. this.loading = false
  94. },
  95. // this can be placed in utils/notification.js
  96. notify(payload) {
  97. this.$waveui.notify({
  98. message: payload,
  99. timeout: 6000,
  100. bgColor: 'white',
  101. color: 'success',
  102. dismiss: false,
  103. shadow: true,
  104. round: true,
  105. sm: true,
  106. icon: 'wi-star',
  107. })
  108. },
  109. // a way to send a message to a user for development purposes and testing
  110. async chat() {
  111. const chatter = currentProfile.chatter
  112. const res = await chatter.publish(chatter.subscriptions[0], {
  113. title: 'New Message',
  114. description: 'This is a new message',
  115. })
  116. this.notify(res)
  117. },
  118. },
  119. }
  120. </script>