You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.8 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row wrap)
  4. v-flex(xs12)
  5. .profile-header
  6. img.animated.fadeInUp(src='/_assets/svg/icon-file.svg', alt='Users', style='width: 80px;')
  7. .profile-header-title
  8. .headline.primary--text.animated.fadeInLeft {{$t('profile:pages.title')}}
  9. .subheading.grey--text.animated.fadeInLeft {{$t('profile:pages.subtitle')}}
  10. v-spacer
  11. v-btn.animated.fadeInDown.wait-p1s(color='grey', outlined, @click='refresh', large)
  12. v-icon.grey--text mdi-refresh
  13. v-flex(xs12)
  14. v-card.animated.fadeInUp
  15. v-data-table(
  16. :items='pages'
  17. :headers='headers'
  18. :page.sync='pagination'
  19. :items-per-page='15'
  20. :loading='loading'
  21. must-sort,
  22. sort-by='updatedAt',
  23. sort-desc,
  24. hide-default-footer
  25. )
  26. template(slot='item', slot-scope='props')
  27. tr.is-clickable(:active='props.selected', @click='goToPage(props.item.id)')
  28. td
  29. .body-2: strong {{ props.item.title }}
  30. .caption {{ props.item.description }}
  31. td.admin-pages-path
  32. v-chip(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`') {{ props.item.locale }}
  33. span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }}
  34. td {{ props.item.createdAt | moment('calendar') }}
  35. td {{ props.item.updatedAt | moment('calendar') }}
  36. template(slot='no-data')
  37. v-alert.ma-3(icon='mdi-alert', :value='true', outlined, color='grey')
  38. em.caption {{$t('profile:pages.emptyList')}}
  39. .text-center.py-2.animated.fadeInDown(v-if='this.pageTotal > 1')
  40. v-pagination(v-model='pagination', :length='pageTotal')
  41. </template>
  42. <script>
  43. import gql from 'graphql-tag'
  44. export default {
  45. data() {
  46. return {
  47. selectedPage: {},
  48. pagination: 1,
  49. pages: [],
  50. loading: false
  51. }
  52. },
  53. computed: {
  54. headers () {
  55. return [
  56. { text: this.$t('profile:pages.headerTitle'), value: 'title' },
  57. { text: this.$t('profile:pages.headerPath'), value: 'path' },
  58. { text: this.$t('profile:pages.headerCreatedAt'), value: 'createdAt', width: 250 },
  59. { text: this.$t('profile:pages.headerUpdatedAt'), value: 'updatedAt', width: 250 }
  60. ]
  61. },
  62. pageTotal () {
  63. return Math.ceil(this.pages.length / 15)
  64. }
  65. },
  66. methods: {
  67. async refresh() {
  68. await this.$apollo.queries.pages.refetch()
  69. this.$store.commit('showNotification', {
  70. message: this.$t('profile:pages.refreshSuccess'),
  71. style: 'success',
  72. icon: 'cached'
  73. })
  74. },
  75. goToPage(id) {
  76. window.location.assign(`/i/` + id)
  77. }
  78. },
  79. apollo: {
  80. pages: {
  81. query: gql`
  82. query($creatorId: Int, $authorId: Int) {
  83. pages {
  84. list(creatorId: $creatorId, authorId: $authorId) {
  85. id
  86. locale
  87. path
  88. title
  89. description
  90. contentType
  91. isPublished
  92. isPrivate
  93. privateNS
  94. createdAt
  95. updatedAt
  96. }
  97. }
  98. }
  99. `,
  100. variables () {
  101. return {
  102. creatorId: this.$store.get('user/id'),
  103. authorId: this.$store.get('user/id')
  104. }
  105. },
  106. fetchPolicy: 'network-only',
  107. update: (data) => data.pages.list,
  108. watchLoading (isLoading) {
  109. this.loading = isLoading
  110. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'profile-pages-refresh')
  111. }
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang='scss'>
  117. </style>