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.

169 lines
5.4 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. img.animated.fadeInUp(src='/_assets/svg/icon-file.svg', alt='Page', style='width: 80px;')
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2.animated.fadeInLeft Pages
  9. .subtitle-1.grey--text.animated.fadeInLeft.wait-p2s Manage pages
  10. v-spacer
  11. v-btn.animated.fadeInDown.wait-p1s(icon, color='grey', outlined, @click='refresh')
  12. v-icon.grey--text mdi-refresh
  13. v-btn.animated.fadeInDown.mx-3(color='primary', outlined, @click='recyclebin', disabled)
  14. v-icon(left) mdi-delete-outline
  15. span Recycle Bin
  16. v-btn.animated.fadeInDown(color='primary', depressed, large, to='pages/visualize')
  17. v-icon(left) mdi-graph
  18. span Visualize
  19. v-card.mt-3.animated.fadeInUp
  20. .pa-2.d-flex.align-center(:class='$vuetify.theme.dark ? `grey darken-3-d5` : `grey lighten-3`')
  21. v-text-field(
  22. solo
  23. flat
  24. v-model='search'
  25. prepend-inner-icon='mdi-file-search-outline'
  26. label='Search Pages...'
  27. hide-details
  28. dense
  29. style='max-width: 400px;'
  30. )
  31. v-spacer
  32. v-select.ml-2(
  33. solo
  34. flat
  35. hide-details
  36. dense
  37. label='Locale'
  38. :items='langs'
  39. v-model='selectedLang'
  40. style='max-width: 250px;'
  41. )
  42. v-select.ml-2(
  43. solo
  44. flat
  45. hide-details
  46. dense
  47. label='Publish State'
  48. :items='states'
  49. v-model='selectedState'
  50. style='max-width: 250px;'
  51. )
  52. v-divider
  53. v-data-table(
  54. :items='filteredPages'
  55. :headers='headers'
  56. :search='search'
  57. :page.sync='pagination'
  58. :items-per-page='15'
  59. :loading='loading'
  60. must-sort,
  61. sort-by='updatedAt',
  62. sort-desc,
  63. hide-default-footer
  64. @page-count="pageTotal = $event"
  65. )
  66. template(slot='item', slot-scope='props')
  67. tr.is-clickable(:active='props.selected', @click='$router.push(`/pages/` + props.item.id)')
  68. td.text-xs-right {{ props.item.id }}
  69. td
  70. .body-2: strong {{ props.item.title }}
  71. .caption {{ props.item.description }}
  72. td.admin-pages-path
  73. v-chip(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`') {{ props.item.locale }}
  74. span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }}
  75. td {{ props.item.createdAt | moment('calendar') }}
  76. td {{ props.item.updatedAt | moment('calendar') }}
  77. template(slot='no-data')
  78. v-alert.ma-3(icon='mdi-alert', :value='true', outlined) No pages to display.
  79. .text-center.py-2.animated.fadeInDown(v-if='this.pageTotal > 1')
  80. v-pagination(v-model='pagination', :length='pageTotal')
  81. </template>
  82. <script>
  83. import _ from 'lodash'
  84. import pagesQuery from 'gql/admin/pages/pages-query-list.gql'
  85. export default {
  86. data() {
  87. return {
  88. selectedPage: {},
  89. pagination: 1,
  90. pages: [],
  91. pageTotal: 0,
  92. headers: [
  93. { text: 'ID', value: 'id', width: 80, sortable: true },
  94. { text: 'Title', value: 'title' },
  95. { text: 'Path', value: 'path' },
  96. { text: 'Created', value: 'createdAt', width: 250 },
  97. { text: 'Last Updated', value: 'updatedAt', width: 250 }
  98. ],
  99. search: '',
  100. selectedLang: null,
  101. selectedState: null,
  102. states: [
  103. { text: 'All Publishing States', value: null },
  104. { text: 'Published', value: true },
  105. { text: 'Not Published', value: false }
  106. ],
  107. loading: false
  108. }
  109. },
  110. computed: {
  111. filteredPages () {
  112. return _.filter(this.pages, pg => {
  113. if (this.selectedLang !== null && this.selectedLang !== pg.locale) {
  114. return false
  115. }
  116. if (this.selectedState !== null && this.selectedState !== pg.isPublished) {
  117. return false
  118. }
  119. return true
  120. })
  121. },
  122. langs () {
  123. return _.concat({
  124. text: 'All Locales',
  125. value: null
  126. }, _.uniqBy(this.pages, 'locale').map(pg => ({
  127. text: pg.locale,
  128. value: pg.locale
  129. })))
  130. }
  131. },
  132. methods: {
  133. async refresh() {
  134. await this.$apollo.queries.pages.refetch()
  135. this.$store.commit('showNotification', {
  136. message: 'Page list has been refreshed.',
  137. style: 'success',
  138. icon: 'cached'
  139. })
  140. },
  141. newpage() {
  142. this.pageSelectorShown = true
  143. },
  144. recyclebin () { }
  145. },
  146. apollo: {
  147. pages: {
  148. query: pagesQuery,
  149. fetchPolicy: 'network-only',
  150. update: (data) => data.pages.list,
  151. watchLoading (isLoading) {
  152. this.loading = isLoading
  153. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh')
  154. }
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang='scss'>
  160. .admin-pages-path {
  161. display: flex;
  162. justify-content: flex-start;
  163. align-items: center;
  164. font-family: 'Roboto Mono', monospace;
  165. }
  166. </style>