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
4.4 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. img(src='/svg/icon-rest-api.svg', alt='API', style='width: 80px;')
  7. .admin-header-title
  8. .headline.blue--text.text--darken-2 API
  9. .subheading.grey--text Manage keys to access the API #[v-chip(label, color='primary', small).white--text coming soon]
  10. v-spacer
  11. v-btn(outline, color='grey', large, @click='refresh', disabled)
  12. v-icon refresh
  13. v-btn(color='green', disabled, depressed, large, @click='globalSwitch')
  14. v-icon(left) power_settings_new
  15. | Enable API
  16. v-btn(color='primary', depressed, large, @click='newKey', disabled)
  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.mt-3(icon='info', :value='true', outline, color='info') No API have been generated yet.
  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. headers: [
  73. { text: 'Name', value: 'name' },
  74. { text: 'Key', value: 'key' },
  75. { text: 'Created On', value: 'createdOn' },
  76. { text: 'Updated On', value: 'updatedOn' },
  77. { text: '', value: 'actions', sortable: false, width: 50 }
  78. ],
  79. search: ''
  80. }
  81. },
  82. computed: {
  83. pages () {
  84. if (this.pagination.rowsPerPage == null || this.pagination.totalItems == null) {
  85. return 0
  86. }
  87. return Math.ceil(this.pagination.totalItems / this.pagination.rowsPerPage)
  88. }
  89. },
  90. methods: {
  91. changeSort (column) {
  92. if (this.pagination.sortBy === column) {
  93. this.pagination.descending = !this.pagination.descending
  94. } else {
  95. this.pagination.sortBy = column
  96. this.pagination.descending = false
  97. }
  98. },
  99. toggleAll () {
  100. if (this.selected.length) {
  101. this.selected = []
  102. } else {
  103. this.selected = this.items.slice()
  104. }
  105. },
  106. async refresh() {
  107. this.$store.commit('showNotification', {
  108. style: 'indigo',
  109. message: `Coming soon...`,
  110. icon: 'directions_boat'
  111. })
  112. },
  113. async globalSwitch() {
  114. this.$store.commit('showNotification', {
  115. style: 'indigo',
  116. message: `Coming soon...`,
  117. icon: 'directions_boat'
  118. })
  119. },
  120. async newKey() {
  121. this.$store.commit('showNotification', {
  122. style: 'indigo',
  123. message: `Coming soon...`,
  124. icon: 'directions_boat'
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang='scss'>
  131. </style>