admin-api.vue 3.7 KB

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