Users.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div>
  3. <metadata title="Admin | Users" />
  4. <div class="container">
  5. <table class="table is-striped">
  6. <thead>
  7. <tr>
  8. <td class="ppRow">Profile Picture</td>
  9. <td>User ID</td>
  10. <td>GitHub ID</td>
  11. <td>Password</td>
  12. <td>Username</td>
  13. <td>Role</td>
  14. <td>Email Address</td>
  15. <td>Email Verified</td>
  16. <!-- <td>Likes</td>
  17. <td>Dislikes</td> -->
  18. <td>Songs Requested</td>
  19. <td>Options</td>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <tr v-for="(user, index) in users" :key="index">
  24. <td>
  25. <profile-picture
  26. :avatar="user.avatar"
  27. :name="user.name"
  28. />
  29. </td>
  30. <td>{{ user._id }}</td>
  31. <td v-if="user.services.github">
  32. {{ user.services.github.id }}
  33. </td>
  34. <td v-else>Not Linked</td>
  35. <td v-if="user.hasPassword">Yes</td>
  36. <td v-else>Not Linked</td>
  37. <td>
  38. <a :href="'/u/' + user.username" target="_blank">{{
  39. user.username
  40. }}</a>
  41. </td>
  42. <td>{{ user.role }}</td>
  43. <td>{{ user.email.address }}</td>
  44. <td>{{ user.email.verified }}</td>
  45. <!-- <td>{{ user.liked.length }}</td>
  46. <td>{{ user.disliked.length }}</td> -->
  47. <td>{{ user.songsRequested }}</td>
  48. <td>
  49. <button
  50. class="button is-primary"
  51. @click="edit(user)"
  52. >
  53. Edit
  54. </button>
  55. </td>
  56. </tr>
  57. </tbody>
  58. </table>
  59. </div>
  60. <edit-user
  61. v-if="modals.editUser"
  62. :user-id="editingUserId"
  63. sector="admin"
  64. />
  65. </div>
  66. </template>
  67. <script>
  68. import { mapState, mapActions, mapGetters } from "vuex";
  69. import ProfilePicture from "../../../components/ui/ProfilePicture.vue";
  70. import ws from "../../../ws";
  71. export default {
  72. components: {
  73. EditUser: () => import("../../../components/modals/EditUser.vue"),
  74. ProfilePicture
  75. },
  76. data() {
  77. return {
  78. editingUserId: "",
  79. users: []
  80. };
  81. },
  82. computed: {
  83. ...mapState("modalVisibility", {
  84. modals: state => state.modals.admin
  85. }),
  86. ...mapGetters({
  87. socket: "websockets/getSocket"
  88. })
  89. },
  90. mounted() {
  91. if (this.socket.readyState === 1) this.init();
  92. ws.onConnect(() => this.init());
  93. },
  94. methods: {
  95. edit(user) {
  96. this.editingUserId = user._id;
  97. this.openModal({ sector: "admin", modal: "editUser" });
  98. },
  99. init() {
  100. this.socket.dispatch("users.index", res => {
  101. console.log(res);
  102. if (res.status === "success") {
  103. this.users = res.data;
  104. if (this.$route.query.userId) {
  105. const user = this.users.find(
  106. user => user._id === this.$route.query.userId
  107. );
  108. if (user) this.edit(user);
  109. }
  110. }
  111. });
  112. this.socket.dispatch("apis.joinAdminRoom", "users", () => {});
  113. },
  114. ...mapActions("modalVisibility", ["openModal"])
  115. }
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .night-mode {
  120. .table {
  121. color: var(--light-grey-2);
  122. background-color: var(--dark-grey-3);
  123. thead tr {
  124. background: var(--dark-grey-3);
  125. td {
  126. color: var(--white);
  127. }
  128. }
  129. tbody tr:hover {
  130. background-color: var(--dark-grey-4) !important;
  131. }
  132. tbody tr:nth-child(even) {
  133. background-color: var(--dark-grey-2);
  134. }
  135. strong {
  136. color: var(--light-grey-2);
  137. }
  138. }
  139. }
  140. body {
  141. font-family: "Hind", sans-serif;
  142. }
  143. .profile-picture {
  144. max-width: 50px !important;
  145. max-height: 50px !important;
  146. font-size: 25px !important;
  147. }
  148. td {
  149. vertical-align: middle;
  150. &.ppRow {
  151. max-width: 50px;
  152. }
  153. }
  154. .is-primary:focus {
  155. background-color: var(--primary-color) !important;
  156. }
  157. </style>