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.

85 lines
2.2 KiB

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