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.

135 lines
5.1 KiB

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