123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template>
- <div>
- <metadata title="Admin | Users" />
- <div class="container">
- <table class="table is-striped">
- <thead>
- <tr>
- <td>Profile Picture</td>
- <td>User ID</td>
- <td>GitHub ID</td>
- <td>Password</td>
- <td>Username</td>
- <td>Role</td>
- <td>Email Address</td>
- <td>Email Verified</td>
- <td>Likes</td>
- <td>Dislikes</td>
- <td>Songs Requested</td>
- <td>Options</td>
- </tr>
- </thead>
- <tbody>
- <tr v-for="(user, index) in users" :key="index">
- <td>
- <img
- class="user-avatar"
- src="/assets/notes-transparent.png"
- />
- </td>
- <td>{{ user._id }}</td>
- <td v-if="user.services.github">
- {{ user.services.github.id }}
- </td>
- <td v-else>
- Not Linked
- </td>
- <td v-if="user.hasPassword">
- Yes
- </td>
- <td v-else>
- Not Linked
- </td>
- <td>{{ user.username }}</td>
- <td>{{ user.role }}</td>
- <td>{{ user.email.address }}</td>
- <td>{{ user.email.verified }}</td>
- <td>{{ user.liked.length }}</td>
- <td>{{ user.disliked.length }}</td>
- <td>{{ user.songsRequested }}</td>
- <td>
- <button
- class="button is-primary"
- @click="edit(user)"
- >
- Edit
- </button>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <edit-user v-if="modals.editUser" />
- </div>
- </template>
- <script>
- import { mapState, mapActions } from "vuex";
- import EditUser from "../Modals/EditUser.vue";
- import io from "../../io";
- export default {
- components: { EditUser },
- data() {
- return {
- users: []
- };
- },
- computed: {
- ...mapState("modals", {
- modals: state => state.modals.admin
- })
- },
- methods: {
- edit(user) {
- this.editUser(user);
- this.openModal({ sector: "admin", modal: "editUser" });
- },
- init() {
- this.socket.emit("users.index", result => {
- if (result.status === "success") {
- this.users = result.data;
- if (this.$route.query.userId) {
- const user = this.users.find(
- user => user._id === this.$route.query.userId
- );
- if (user) this.edit(user);
- }
- }
- });
- this.socket.emit("apis.joinAdminRoom", "users", () => {});
- },
- ...mapActions("admin/users", ["editUser"]),
- ...mapActions("modals", ["openModal"])
- },
- mounted() {
- io.getSocket(socket => {
- this.socket = socket;
- if (this.socket.connected) this.init();
- io.onConnect(() => this.init());
- });
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "styles/global.scss";
- .night-mode {
- .table {
- color: #ddd;
- background-color: #222;
- thead tr {
- background: $night-mode-secondary;
- td {
- color: #fff;
- }
- }
- tbody tr:hover {
- background-color: #111 !important;
- }
- tbody tr:nth-child(even) {
- background-color: #444;
- }
- strong {
- color: #ddd;
- }
- }
- }
- body {
- font-family: "Roboto", sans-serif;
- }
- .user-avatar {
- display: block;
- max-width: 50px;
- margin: 0 auto;
- }
- td {
- vertical-align: middle;
- }
- .is-primary:focus {
- background-color: $primary-color !important;
- }
- </style>
|