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.

99 lines
2.9 KiB

  1. <app-users>
  2. <div class="buckets">
  3. <table class="table">
  4. <tbody>
  5. <tr each={ user in state.users }>
  6. <td class="table__td">
  7. { user.display_name }
  8. </td>
  9. <td class="table__td">
  10. { user.email }
  11. </td>
  12. <td class="table__td">
  13. { user.is_admin }
  14. </td>
  15. <td class="table__td">
  16. <button class="button button--small m-bottom-0 m-right-3">
  17. <svg class="icon" aria-hidden="true">
  18. <use xlink:href="/symbol-defs.svg#icon-edit"></use>
  19. </svg>
  20. </button>
  21. <button class="button button--small m-bottom-0" type="button">
  22. <svg class="icon" aria-hidden="true">
  23. <use xlink:href="/symbol-defs.svg#icon-delete"></use>
  24. </svg>
  25. </button>
  26. </td>
  27. </tr>
  28. </tbody>
  29. </table>
  30. <div class="grid" if={ state.maxLength > state.users.length }>
  31. <div class="col-12">
  32. <div class="buckets__more">
  33. <button type="button" class="button" onclick={ handleClick }>
  34. More
  35. <svg class="icon" aria-hidden="true">
  36. <use xlink:href="/symbol-defs.svg#icon-arrow-down"></use>
  37. </svg>
  38. </button>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <script>
  44. import axios from 'axios'
  45. import remove from 'lodash.remove'
  46. /**
  47. *
  48. *
  49. *
  50. * @author Björn Hase
  51. *
  52. */
  53. export default {
  54. state: {
  55. users: [],
  56. maxLength: 0
  57. },
  58. onBeforeMount() {
  59. this.fetch()
  60. },
  61. handleClick() {
  62. },
  63. handleDelete(event, bucket) {
  64. event.preventDefault()
  65. axios.delete('/api/bucket/' + bucket._id)
  66. .then((response) => {
  67. // removing from buckets
  68. remove(this.state.buckets, function(b) {
  69. return b._id === bucket._id
  70. })
  71. this.update()
  72. })
  73. },
  74. /**
  75. * getting all buckets
  76. *
  77. *
  78. */
  79. fetch() {
  80. axios.get('/api/users').then((response) => {
  81. this.state.users = response.data.data
  82. this.update()
  83. })
  84. }
  85. }
  86. </script>
  87. </app-users>