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.

146 lines
4.6 KiB

  1. <app-users>
  2. <div class="buckets">
  3. <table class="table">
  4. <thead>
  5. <tr class="table__tr">
  6. <th class="table__th">
  7. Email
  8. </th>
  9. <th class="table__th">
  10. Display Name
  11. </th>
  12. <th class="table__th" colspan="2">
  13. Roles
  14. </th>
  15. </tr>
  16. </thead>
  17. <tbody>
  18. <tr class="table__tr" each={ user in state.users }>
  19. <td class="table__td">
  20. { user.email }
  21. </td>
  22. <td class="table__td">
  23. { user.display_name }
  24. </td>
  25. <td class="table__td">
  26. <div if={ user.roles && user.roles.indexOf('admin') >= 0 }>
  27. Admin
  28. <svg class="icon" aria-hidden="true">
  29. <use xlink:href="/symbol-defs.svg#icon-check"></use>
  30. </svg>
  31. </div>
  32. </td>
  33. <!-- actions -->
  34. <td class="table__td right">
  35. <button class="button button--small m-bottom-0 m-right-3">
  36. <svg class="icon" aria-hidden="true">
  37. <use xlink:href="/symbol-defs.svg#icon-edit"></use>
  38. </svg>
  39. </button>
  40. <button class="button button--small m-bottom-0" type="button" onclick={ (event) => { handleDelete(event, user) } }>
  41. <svg class="icon" aria-hidden="true">
  42. <use xlink:href="/symbol-defs.svg#icon-delete"></use>
  43. </svg>
  44. </button>
  45. </td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. <div class="modal">
  50. <div class="modal__inner">
  51. <div class="modal__title center">
  52. <svg class="icon fill-text-contrast" aria-hidden="true">
  53. <use xlink:href="/symbol-defs.svg#icon-close"></use>
  54. </svg>
  55. { title }
  56. </div>
  57. <div class="modal__body">
  58. { content }
  59. </div>
  60. <div class="modal__footer">
  61. <button class="button button--outline button--danger" onclick={ () => { handleConfirm(event, data) } }>
  62. Confirm
  63. </button>
  64. <button class="button button--outline float-right" onclick={ (event) => { handleClose(event) } }>
  65. Reject
  66. </button>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="grid" if={ state.maxLength > state.users.length }>
  71. <div class="col-12">
  72. <div class="buckets__more">
  73. <button type="button" class="button" onclick={ handleClick }>
  74. More
  75. <svg class="icon" aria-hidden="true">
  76. <use xlink:href="/symbol-defs.svg#icon-arrow-down"></use>
  77. </svg>
  78. </button>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <script>
  84. import axios from 'axios'
  85. import remove from 'lodash.remove'
  86. /**
  87. *
  88. *
  89. *
  90. * @author Björn Hase
  91. *
  92. */
  93. export default {
  94. state: {
  95. users: [],
  96. maxLength: 0
  97. },
  98. onBeforeMount() {
  99. this.fetch()
  100. },
  101. handleClick() {
  102. },
  103. handleDelete(event, user) {
  104. event.preventDefault()
  105. axios.delete('/api/users/' + user._id)
  106. .then((response) => {
  107. // removing from buckets
  108. remove(this.state.users, function(u) {
  109. return u._id === user._id
  110. })
  111. this.update()
  112. })
  113. },
  114. /**
  115. * getting all buckets
  116. *
  117. *
  118. */
  119. fetch() {
  120. axios.get('/api/users').then((response) => {
  121. this.state.users = response.data.data
  122. this.update()
  123. })
  124. }
  125. }
  126. </script>
  127. </app-users>