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.

137 lines
5.3 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. v-icon(size='80', color='grey lighten-2') perm_identity
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2 Users
  9. .subheading.grey--text Manage users
  10. v-spacer
  11. v-btn(outline, color='grey', large)
  12. v-icon refresh
  13. v-btn(color='primary', large, depressed)
  14. v-icon(left) lock_outline
  15. span Authorize User
  16. v-btn(color='primary', large, depressed)
  17. v-icon(left) add
  18. span New User
  19. v-card.mt-3
  20. v-data-table(
  21. v-model='selected'
  22. :items='items',
  23. :headers='headers',
  24. :search='search',
  25. :pagination.sync='pagination',
  26. :rows-per-page-items='[15]'
  27. select-all,
  28. hide-actions,
  29. disable-initial-sort
  30. )
  31. template(slot='headers', slot-scope='props')
  32. tr
  33. th(width='50')
  34. th.text-xs-right(
  35. width='80'
  36. :class='[`column sortable`, pagination.descending ? `desc` : `asc`, pagination.sortBy === `id` ? `active` : ``]'
  37. @click='changeSort(`id`)'
  38. )
  39. v-icon(small) arrow_upward
  40. | ID
  41. th.text-xs-left(
  42. v-for='header in props.headers'
  43. :key='header.text'
  44. :width='header.width'
  45. :class='[`column sortable`, pagination.descending ? `desc` : `asc`, header.value === pagination.sortBy ? `active` : ``]'
  46. @click='changeSort(header.value)'
  47. )
  48. | {{ header.text }}
  49. v-icon(small) arrow_upward
  50. template(slot='items', slot-scope='props')
  51. tr(:active='props.selected')
  52. td
  53. v-checkbox(hide-details, :input-value='props.selected', color='blue darken-2', @click='props.selected = !props.selected')
  54. td.text-xs-right {{ props.item.id }}
  55. td {{ props.item.email }}
  56. td {{ props.item.name }}
  57. td {{ props.item.provider }}
  58. td {{ props.item.createdOn }}
  59. td {{ props.item.updatedOn }}
  60. td: v-btn(icon): v-icon.grey--text.text--darken-1 more_horiz
  61. template(slot='no-data')
  62. v-alert(icon='warning', :value='true') No users to display!
  63. .text-xs-center.py-2
  64. v-pagination(v-model='pagination.page', :length='pages')
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return {
  70. selected: [],
  71. pagination: {},
  72. items: [
  73. { id: 1, email: 'user@test.com', name: 'John Doe', provider: 'local' },
  74. { id: 2, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  75. { id: 3, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  76. { id: 4, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  77. { id: 5, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  78. { id: 6, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  79. { id: 7, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  80. { id: 8, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  81. { id: 9, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  82. { id: 10, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  83. { id: 11, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  84. { id: 12, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  85. { id: 13, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  86. { id: 14, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  87. { id: 15, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  88. { id: 16, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  89. { id: 17, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  90. { id: 18, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  91. { id: 19, email: 'dude@test.com', name: 'John Doe', provider: 'local' },
  92. { id: 20, email: 'dude@test.com', name: 'John Doe', provider: 'local' }
  93. ],
  94. headers: [
  95. { text: 'Email', value: 'email' },
  96. { text: 'Name', value: 'name' },
  97. { text: 'Provider', value: 'provider' },
  98. { text: 'Created On', value: 'createdOn' },
  99. { text: 'Updated On', value: 'updatedOn' },
  100. { text: '', value: 'actions', sortable: false, width: 50 }
  101. ],
  102. search: ''
  103. }
  104. },
  105. computed: {
  106. pages () {
  107. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  108. return 0
  109. }
  110. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  111. }
  112. },
  113. methods: {
  114. changeSort (column) {
  115. if (this.pagination.sortBy === column) {
  116. this.pagination.descending = !this.pagination.descending
  117. } else {
  118. this.pagination.sortBy = column
  119. this.pagination.descending = false
  120. }
  121. },
  122. toggleAll () {
  123. if (this.selected.length) {
  124. this.selected = []
  125. } else {
  126. this.selected = this.items.slice()
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang='scss'>
  133. </style>