Users.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class='container'>
  3. <table class='table is-striped'>
  4. <thead>
  5. <tr>
  6. <td>Profile Picture</td>
  7. <td>User ID</td>
  8. <td>GitHub ID</td>
  9. <td>Password</td>
  10. <td>Username</td>
  11. <td>Role</td>
  12. <td>Email Address</td>
  13. <td>Email Verified</td>
  14. <td>Likes</td>
  15. <td>Dislikes</td>
  16. <td>Songs Requested</td>
  17. <td>Options</td>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. <tr v-for='(index, user) in users' track-by='$index'>
  22. <td>
  23. <img class='user-avatar' src='/assets/notes-transparent.png'>
  24. </td>
  25. <td>{{ user._id }}</td>
  26. <td v-if='user.services.github'>{{ user.services.github.id }}</td>
  27. <td v-else>Not Linked</td>
  28. <td v-if='user.hasPassword'>Yes</td>
  29. <td v-else>Not Linked</td>
  30. <td>{{ user.username }}</td>
  31. <td>{{ user.role }}</td>
  32. <td>{{ user.email.address }}</td>
  33. <td>{{ user.email.verified }}</td>
  34. <td>{{ user.liked.length }}</td>
  35. <td>{{ user.disliked.length }}</td>
  36. <td>{{ user.songsRequested }}</td>
  37. <td>
  38. <button class='button is-primary' @click='edit(user)'>Edit</button>
  39. </td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. </div>
  44. <edit-user v-show='modals.editUser'></edit-user>
  45. </template>
  46. <script>
  47. import EditUser from '../Modals/EditUser.vue';
  48. import io from '../../io';
  49. export default {
  50. components: { EditUser },
  51. data() {
  52. return {
  53. users: [],
  54. modals: { editUser: false }
  55. }
  56. },
  57. methods: {
  58. toggleModal: function () {
  59. this.modals.editUser = !this.modals.editUser;
  60. },
  61. edit: function (user) {
  62. this.$broadcast('editUser', user);
  63. },
  64. init: function () {
  65. let _this = this;
  66. _this.socket.emit('users.index', result => {
  67. if (result.status === 'success') _this.users = result.data;
  68. });
  69. _this.socket.emit('apis.joinAdminRoom', 'users', () => {});
  70. _this.socket.on('event:user.username.changed', username => {
  71. _this.$parent.$parent.username = username;
  72. });
  73. }
  74. },
  75. ready: function () {
  76. let _this = this;
  77. io.getSocket(socket => {
  78. _this.socket = socket;
  79. if (_this.socket.connected) _this.init();
  80. io.onConnect(() => _this.init());
  81. });
  82. }
  83. }
  84. </script>
  85. <style lang='scss' scoped>
  86. body { font-family: 'Roboto', sans-serif; }
  87. .user-avatar {
  88. display: block;
  89. max-width: 50px;
  90. margin: 0 auto;
  91. }
  92. td { vertical-align: middle; }
  93. .is-primary:focus { background-color: #029ce3 !important; }
  94. </style>