admin-pages.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template lang='pug'>
  2. v-card(flat)
  3. v-card(flat, tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"').pa-3.pt-4
  4. .admin-header-icon: v-icon(size='80', color='grey lighten-2') insert_drive_file
  5. .headline.blue--text.text--darken-2 Pages
  6. .subheading.grey--text Manage pages
  7. v-card
  8. v-card-title
  9. v-btn(color='primary', dark, slot='activator')
  10. v-icon(left) add
  11. | New Page
  12. v-btn(icon, @click='refresh')
  13. v-icon.grey--text refresh
  14. v-spacer
  15. v-text-field(solo, append-icon='search', label='Search', single-line, hide-details, v-model='search')
  16. v-data-table(
  17. :items='groups'
  18. :headers='headers'
  19. :search='search'
  20. :pagination.sync='pagination'
  21. :rows-per-page-items='[15]'
  22. hide-actions
  23. )
  24. template(slot='items', slot-scope='props')
  25. tr.is-clickable(:active='props.selected', @click='$router.push("/e/" + props.item.id)')
  26. td.text-xs-right {{ props.item.id }}
  27. td {{ props.item.name }}
  28. td {{ props.item.userCount }}
  29. td {{ props.item.createdAt | moment('calendar') }}
  30. td {{ props.item.updatedAt | moment('calendar') }}
  31. template(slot='no-data')
  32. v-alert.ma-3(icon='warning', :value='true', outline) No pages to display.
  33. .text-xs-center.py-2(v-if='groups.length > 15')
  34. v-pagination(v-model='pagination.page', :length='pages')
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. selectedGroup: {},
  41. pagination: {},
  42. groups: [],
  43. headers: [
  44. { text: 'ID', value: 'id', width: 50, align: 'right' },
  45. { text: 'Title', value: 'title' },
  46. { text: 'Path', value: 'path' },
  47. { text: 'Created', value: 'createdAt', width: 250 },
  48. { text: 'Last Updated', value: 'updatedAt', width: 250 }
  49. ],
  50. search: ''
  51. }
  52. },
  53. computed: {
  54. pages () {
  55. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  56. return 0
  57. }
  58. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  59. }
  60. },
  61. methods: {
  62. async refresh() {
  63. // await this.$apollo.queries.groups.refetch()
  64. this.$store.commit('showNotification', {
  65. message: 'Pages have been refreshed.',
  66. style: 'success',
  67. icon: 'cached'
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang='scss'>
  74. </style>