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.

170 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. )
  65. template(slot='item', slot-scope='props')
  66. tr.is-clickable(:active='props.selected', @click='$router.push(`/pages/` + props.item.id)')
  67. td.text-xs-right {{ props.item.id }}
  68. td
  69. .body-2: strong {{ props.item.title }}
  70. .caption {{ props.item.description }}
  71. td.admin-pages-path
  72. v-chip(label, small, :color='$vuetify.theme.dark ? `grey darken-4` : `grey lighten-4`') {{ props.item.locale }}
  73. span.ml-2.grey--text(:class='$vuetify.theme.dark ? `text--lighten-1` : `text--darken-2`') / {{ props.item.path }}
  74. td {{ props.item.createdAt | moment('calendar') }}
  75. td {{ props.item.updatedAt | moment('calendar') }}
  76. template(slot='no-data')
  77. v-alert.ma-3(icon='mdi-alert', :value='true', outlined) No pages to display.
  78. .text-center.py-2.animated.fadeInDown(v-if='this.pageTotal > 1')
  79. v-pagination(v-model='pagination', :length='pageTotal')
  80. </template>
  81. <script>
  82. import _ from 'lodash'
  83. import pagesQuery from 'gql/admin/pages/pages-query-list.gql'
  84. export default {
  85. data() {
  86. return {
  87. selectedPage: {},
  88. pagination: 1,
  89. pages: [],
  90. headers: [
  91. { text: 'ID', value: 'id', width: 80, sortable: true },
  92. { text: 'Title', value: 'title' },
  93. { text: 'Path', value: 'path' },
  94. { text: 'Created', value: 'createdAt', width: 250 },
  95. { text: 'Last Updated', value: 'updatedAt', width: 250 }
  96. ],
  97. search: '',
  98. selectedLang: null,
  99. selectedState: null,
  100. states: [
  101. { text: 'All Publishing States', value: null },
  102. { text: 'Published', value: true },
  103. { text: 'Not Published', value: false }
  104. ],
  105. loading: false
  106. }
  107. },
  108. computed: {
  109. pageTotal () {
  110. return Math.ceil(this.filteredPages.length / 15)
  111. },
  112. filteredPages () {
  113. return _.filter(this.pages, pg => {
  114. if (this.selectedLang !== null && this.selectedLang !== pg.locale) {
  115. return false
  116. }
  117. if (this.selectedState !== null && this.selectedState !== pg.isPublished) {
  118. return false
  119. }
  120. return true
  121. })
  122. },
  123. langs () {
  124. return _.concat({
  125. text: 'All Locales',
  126. value: null
  127. }, _.uniqBy(this.pages, 'locale').map(pg => ({
  128. text: pg.locale,
  129. value: pg.locale
  130. })))
  131. }
  132. },
  133. methods: {
  134. async refresh() {
  135. await this.$apollo.queries.pages.refetch()
  136. this.$store.commit('showNotification', {
  137. message: 'Page list has been refreshed.',
  138. style: 'success',
  139. icon: 'cached'
  140. })
  141. },
  142. newpage() {
  143. this.pageSelectorShown = true
  144. },
  145. recyclebin () { }
  146. },
  147. apollo: {
  148. pages: {
  149. query: pagesQuery,
  150. fetchPolicy: 'network-only',
  151. update: (data) => data.pages.list,
  152. watchLoading (isLoading) {
  153. this.loading = isLoading
  154. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-pages-refresh')
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang='scss'>
  161. .admin-pages-path {
  162. display: flex;
  163. justify-content: flex-start;
  164. align-items: center;
  165. font-family: 'Roboto Mono', monospace;
  166. }
  167. </style>