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.

118 lines
3.8 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') call_split
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2 API
  9. .subheading.grey--text Manage keys to access the API
  10. v-spacer
  11. v-btn(outline, color='grey', large)
  12. v-icon refresh
  13. v-btn(color='green', dark, depressed, large)
  14. v-icon(left) power_settings_new
  15. | Enable API
  16. v-btn(color='primary', depressed, large)
  17. v-icon(left) add
  18. | New API Key
  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.name }}
  56. td {{ props.item.key }}
  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, key: 'xxxxxxxxxxxxx' },
  73. { id: 2, key: 'xxxxxxxxxxxxy' },
  74. { id: 3, key: 'xxxxxxxxxxxxz' }
  75. ],
  76. headers: [
  77. { text: 'Name', value: 'name' },
  78. { text: 'Key', value: 'key' },
  79. { text: 'Created On', value: 'createdOn' },
  80. { text: 'Updated On', value: 'updatedOn' },
  81. { text: '', value: 'actions', sortable: false, width: 50 }
  82. ],
  83. search: ''
  84. }
  85. },
  86. computed: {
  87. pages () {
  88. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  89. return 0
  90. }
  91. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  92. }
  93. },
  94. methods: {
  95. changeSort (column) {
  96. if (this.pagination.sortBy === column) {
  97. this.pagination.descending = !this.pagination.descending
  98. } else {
  99. this.pagination.sortBy = column
  100. this.pagination.descending = false
  101. }
  102. },
  103. toggleAll () {
  104. if (this.selected.length) {
  105. this.selected = []
  106. } else {
  107. this.selected = this.items.slice()
  108. }
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang='scss'>
  114. </style>