123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- <template>
- <div v-if="isUser">
- <metadata v-bind:title="`Profile | ${user.username}`" />
- <main-header />
- <!--div class="container">
- <img class="avatar" src="/assets/notes.png" />
- <h2 class="has-text-centered username">@{{ user.username }}</h2>
- <h5>A member since {{ user.createdAt }}</h5>
- <div
- v-if="role === 'admin' && userId !== user._id"
- class="admin-functionality"
- >
- <a
- v-if="user.role == 'default'"
- class="button is-small is-info is-outlined"
- @click="changeRank('admin')"
- >Promote to Admin</a
- >
- <a
- v-if="user.role == 'admin'"
- class="button is-small is-danger is-outlined"
- @click="changeRank('default')"
- >Demote to User</a
- >
- </div>
- <nav class="level">
- <div class="level-item has-text-centered">
- <p class="heading">
- Rank
- </p>
- <p class="title role">
- {{ user.role }}
- </p>
- </div>
- <div class="level-item has-text-centered">
- <p class="heading">
- Songs Requested
- </p>
- <p class="title">
- {{ user.statistics.songsRequested }}
- </p>
- </div>
- <div class="level-item has-text-centered">
- <p class="heading">
- Likes
- </p>
- <p class="title">
- {{ user.liked.length }}
- </p>
- </div>
- <div class="level-item has-text-centered">
- <p class="heading">
- Dislikes
- </p>
- <p class="title">
- {{ user.disliked.length }}
- </p>
- </div>
- </nav>
- </div-->
- <div class="info-section">
- <div class="picture-name-row">
- <img
- class="profile-picture"
- src="https://avatars3.githubusercontent.com/u/9784561?s=460&v=4"
- />
- <div>
- <div class="name-role-row">
- <p class="name">Kristian Vos</p>
- <span class="role admin">admin</span>
- </div>
- <p class="username">@Kris</p>
- </div>
- </div>
- <div class="buttons">
- <button class="button is-primary">Edit</button>
- <button class="button is-primary">Settings</button>
- </div>
- <div class="bio-row">
- <i class="material-icons">notes</i>
- <p>
- Test Test Test Test Test Test Test Test Test Test Test Test
- Test Test Test Test
- </p>
- </div>
- <div class="date-location-row">
- <div class="date">
- <i class="material-icons">calendar_today</i>
- <p>February 25, 2011</p>
- </div>
- <div class="location">
- <i class="material-icons">location_on</i>
- <p>The Netherlands</p>
- </div>
- </div>
- </div>
- <div class="bottom-section">
- <div class="buttons">
- <button class="active">Recent activity</button>
- <button>Playlists</button>
- </div>
- <div class="content">
- Content here
- </div>
- </div>
- <main-footer />
- </div>
- </template>
- <script>
- import { mapState } from "vuex";
- import Toast from "toasters";
- import { format, parseISO } from "date-fns";
- import MainHeader from "../MainHeader.vue";
- import MainFooter from "../MainFooter.vue";
- import io from "../../io";
- export default {
- components: { MainHeader, MainFooter },
- data() {
- return {
- user: {},
- isUser: false
- };
- },
- computed: mapState({
- role: state => state.user.auth.role,
- userId: state => state.user.auth.userId
- }),
- mounted() {
- io.getSocket(socket => {
- this.socket = socket;
- this.socket.emit(
- "users.findByUsername",
- this.$route.params.username,
- res => {
- if (res.status === "error") this.$router.go("/404");
- else {
- this.user = res.data;
- this.user.createdAt = format(
- parseISO(this.user.createdAt),
- "MMMM do yyyy"
- );
- this.isUser = true;
- }
- }
- );
- });
- },
- methods: {
- changeRank(newRank) {
- this.socket.emit(
- "users.updateRole",
- this.user._id,
- newRank === "admin" ? "admin" : "default",
- res => {
- if (res.status === "error")
- new Toast({ content: res.message, timeout: 2000 });
- else this.user.role = newRank;
- new Toast({
- content: `User ${this.$route.params.username}'s rank has been changed to: ${newRank}`,
- timeout: 2000
- });
- }
- );
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "styles/global.scss";
- .info-section {
- width: 912px;
- margin-left: auto;
- margin-right: auto;
- margin-top: 32px;
- padding: 24px;
- .picture-name-row {
- display: flex;
- flex-direction: row;
- align-items: center;
- column-gap: 32px;
- justify-content: center;
- margin-bottom: 24px;
- }
- .profile-picture {
- width: 100px;
- height: 100px;
- border-radius: 100%;
- }
- .name-role-row {
- display: flex;
- flex-direction: row;
- align-items: center;
- column-gap: 12px;
- }
- .name {
- font-size: 34px;
- line-height: 40px;
- color: $dark-grey-3;
- }
- .role {
- padding: 2px 24px;
- color: $white;
- text-transform: uppercase;
- font-size: 12px;
- line-height: 14px;
- height: 18px;
- border-radius: 5px;
- &.admin {
- background-color: $red;
- }
- }
- .username {
- font-size: 24px;
- line-height: 28px;
- color: $dark-grey;
- }
- .buttons {
- width: 388px;
- display: flex;
- flex-direction: row;
- column-gap: 20px;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 24px;
- .button {
- flex: 1;
- font-size: 17px;
- line-height: 20px;
- }
- }
- .bio-row,
- .date-location-row {
- i {
- font-size: 24px;
- color: $dark-grey-2;
- margin-right: 12px;
- }
- p {
- font-size: 17px;
- line-height: 20px;
- color: $dark-grey-2;
- word-break: break-word;
- }
- }
- .bio-row {
- max-width: 608px;
- margin-bottom: 24px;
- margin-left: auto;
- margin-right: auto;
- display: flex;
- width: max-content;
- }
- .date-location-row {
- max-width: 608px;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 24px;
- display: flex;
- width: max-content;
- margin-bottom: 24px;
- column-gap: 48px;
- }
- .date,
- .location {
- display: flex;
- }
- }
- .bottom-section {
- width: 960px;
- margin-left: auto;
- margin-right: auto;
- margin-top: 32px;
- padding: 24px;
- display: flex;
- column-gap: 64px;
- .buttons {
- height: 100%;
- width: 251px;
- button {
- outline: none;
- border: none;
- box-shadow: none;
- color: $musareBlue;
- font-size: 22px;
- line-height: 26px;
- padding: 7px 0 7px 12px;
- width: 100%;
- text-align: left;
- cursor: pointer;
- border-radius: 5px;
- background-color: transparent;
- &.active {
- color: $white;
- background-color: $musareBlue;
- }
- }
- }
- .content {
- outline: 1px solid black;
- width: 597px;
- }
- }
- .night-mode {
- .name,
- .username,
- .bio-row i,
- .bio-row p,
- .date-location-row i,
- .date-location-row p {
- color: $light-grey;
- }
- }
- </style>
|