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.

113 lines
3.5 KiB

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