admin-users.vue 5.2 KB

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