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.

116 lines
3.6 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 API
  5. .subheading.grey--text Manage keys to access the API
  6. v-card
  7. v-card-title
  8. v-btn(color='green', dark)
  9. v-icon(left) power_settings_new
  10. | Enable API
  11. v-btn(color='primary', dark)
  12. v-icon(left) add
  13. | New API Key
  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.name }}
  54. td {{ props.item.key }}
  55. td {{ props.item.createdOn }}
  56. td {{ props.item.updatedOn }}
  57. td: v-btn(icon): v-icon.grey--text.text--darken-1 more_horiz
  58. template(slot='no-data')
  59. v-alert(icon='warning', :value='true') No users to display!
  60. .text-xs-center.py-2
  61. v-pagination(v-model='pagination.page', :length='pages')
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. selected: [],
  68. pagination: {},
  69. items: [
  70. { id: 1, key: 'xxxxxxxxxxxxx' },
  71. { id: 2, key: 'xxxxxxxxxxxxy' },
  72. { id: 3, key: 'xxxxxxxxxxxxz' }
  73. ],
  74. headers: [
  75. { text: 'Name', value: 'name' },
  76. { text: 'Key', value: 'key' },
  77. { text: 'Created On', value: 'createdOn' },
  78. { text: 'Updated On', value: 'updatedOn' },
  79. { text: '', value: 'actions', sortable: false, width: 50 }
  80. ],
  81. search: ''
  82. }
  83. },
  84. computed: {
  85. pages () {
  86. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  87. return 0
  88. }
  89. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  90. }
  91. },
  92. methods: {
  93. changeSort (column) {
  94. if (this.pagination.sortBy === column) {
  95. this.pagination.descending = !this.pagination.descending
  96. } else {
  97. this.pagination.sortBy = column
  98. this.pagination.descending = false
  99. }
  100. },
  101. toggleAll () {
  102. if (this.selected.length) {
  103. this.selected = []
  104. } else {
  105. this.selected = this.items.slice()
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang='scss'>
  112. </style>