Show.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div v-if="isUser">
  3. <metadata v-bind:title="`Profile | ${user.username}`" />
  4. <main-header />
  5. <!--div class="container">
  6. <img
  7. class="avatar"
  8. :src="
  9. user.avatar
  10. ? `${user.avatar}?d=${notes}&s=250`
  11. : '/assets/notes.png'
  12. "
  13. onerror="this.src='/assets/notes.png'; this.onerror=''"
  14. />
  15. <h2 class="has-text-centered username">@{{ user.username }}</h2>
  16. <h5>A member since {{ user.createdAt }}</h5>
  17. <div
  18. v-if="role === 'admin' && userId !== user._id"
  19. class="admin-functionality"
  20. >
  21. <a
  22. v-if="user.role == 'default'"
  23. class="button is-small is-info is-outlined"
  24. @click="changeRank('admin')"
  25. >Promote to Admin</a
  26. >
  27. <a
  28. v-if="user.role == 'admin'"
  29. class="button is-small is-danger is-outlined"
  30. @click="changeRank('default')"
  31. >Demote to User</a
  32. >
  33. </div>
  34. <nav class="level">
  35. <div class="level-item has-text-centered">
  36. <p class="heading">
  37. Rank
  38. </p>
  39. <p class="title role">
  40. {{ user.role }}
  41. </p>
  42. </div>
  43. <div class="level-item has-text-centered">
  44. <p class="heading">
  45. Songs Requested
  46. </p>
  47. <p class="title">
  48. {{ user.statistics.songsRequested }}
  49. </p>
  50. </div>
  51. <div class="level-item has-text-centered">
  52. <p class="heading">
  53. Likes
  54. </p>
  55. <p class="title">
  56. {{ user.liked.length }}
  57. </p>
  58. </div>
  59. <div class="level-item has-text-centered">
  60. <p class="heading">
  61. Dislikes
  62. </p>
  63. <p class="title">
  64. {{ user.disliked.length }}
  65. </p>
  66. </div>
  67. </nav>
  68. </div-->
  69. <div class="info-section">
  70. <div class="picture-name-row">
  71. <img
  72. class="profile-picture"
  73. src="https://avatars3.githubusercontent.com/u/9784561?s=460&v=4"
  74. />
  75. <div>
  76. <div class="name-role-row">
  77. <p class="name">Kristian Vos</p>
  78. <span class="role admin">admin</span>
  79. </div>
  80. <p class="username">@Kris</p>
  81. </div>
  82. </div>
  83. <div class="buttons">
  84. <button class="button is-primary">Edit</button>
  85. <button class="button is-primary">Settings</button>
  86. </div>
  87. <div class="bio-row">
  88. <i class="material-icons">notes</i>
  89. <p>
  90. Test Test Test Test Test Test Test Test Test Test Test Test
  91. Test Test Test Test
  92. </p>
  93. </div>
  94. <div class="date-location-row">
  95. <div class="date">
  96. <i class="material-icons">calendar_today</i>
  97. <p>February 25, 2011</p>
  98. </div>
  99. <div class="location">
  100. <i class="material-icons">location_on</i>
  101. <p>The Netherlands</p>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="bottom-section">
  106. <div class="buttons">
  107. <button class="active">Recent activity</button>
  108. <button>Playlists</button>
  109. </div>
  110. <div class="content">
  111. Content here
  112. </div>
  113. </div>
  114. <main-footer />
  115. </div>
  116. </template>
  117. <script>
  118. import { mapState } from "vuex";
  119. import Toast from "toasters";
  120. import { format, parseISO } from "date-fns";
  121. import MainHeader from "../MainHeader.vue";
  122. import MainFooter from "../MainFooter.vue";
  123. import io from "../../io";
  124. export default {
  125. components: { MainHeader, MainFooter },
  126. data() {
  127. return {
  128. user: {},
  129. notes: "",
  130. isUser: false
  131. };
  132. },
  133. computed: mapState({
  134. role: state => state.user.auth.role,
  135. userId: state => state.user.auth.userId
  136. }),
  137. mounted() {
  138. lofig.get("frontendDomain").then(frontendDomain => {
  139. this.frontendDomain = frontendDomain;
  140. this.notes = encodeURI(`${this.frontendDomain}/assets/notes.png`);
  141. });
  142. io.getSocket(socket => {
  143. this.socket = socket;
  144. this.socket.emit(
  145. "users.findByUsername",
  146. this.$route.params.username,
  147. res => {
  148. if (res.status === "error") this.$router.go("/404");
  149. else {
  150. this.user = res.data;
  151. this.user.createdAt = format(
  152. parseISO(this.user.createdAt),
  153. "MMMM do yyyy"
  154. );
  155. this.isUser = true;
  156. }
  157. }
  158. );
  159. });
  160. },
  161. methods: {
  162. changeRank(newRank) {
  163. this.socket.emit(
  164. "users.updateRole",
  165. this.user._id,
  166. newRank === "admin" ? "admin" : "default",
  167. res => {
  168. if (res.status === "error")
  169. new Toast({ content: res.message, timeout: 2000 });
  170. else this.user.role = newRank;
  171. new Toast({
  172. content: `User ${this.$route.params.username}'s rank has been changed to: ${newRank}`,
  173. timeout: 2000
  174. });
  175. }
  176. );
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. @import "styles/global.scss";
  183. .info-section {
  184. width: 912px;
  185. margin-left: auto;
  186. margin-right: auto;
  187. margin-top: 32px;
  188. padding: 24px;
  189. .picture-name-row {
  190. display: flex;
  191. flex-direction: row;
  192. align-items: center;
  193. column-gap: 32px;
  194. justify-content: center;
  195. margin-bottom: 24px;
  196. }
  197. .profile-picture {
  198. width: 100px;
  199. height: 100px;
  200. border-radius: 100%;
  201. }
  202. .name-role-row {
  203. display: flex;
  204. flex-direction: row;
  205. align-items: center;
  206. column-gap: 12px;
  207. }
  208. .name {
  209. font-size: 34px;
  210. line-height: 40px;
  211. color: $dark-grey-3;
  212. }
  213. .role {
  214. padding: 2px 24px;
  215. color: $white;
  216. text-transform: uppercase;
  217. font-size: 12px;
  218. line-height: 14px;
  219. height: 18px;
  220. border-radius: 5px;
  221. &.admin {
  222. background-color: $red;
  223. }
  224. }
  225. .username {
  226. font-size: 24px;
  227. line-height: 28px;
  228. color: $dark-grey;
  229. }
  230. .buttons {
  231. width: 388px;
  232. display: flex;
  233. flex-direction: row;
  234. column-gap: 20px;
  235. margin-left: auto;
  236. margin-right: auto;
  237. margin-bottom: 24px;
  238. .button {
  239. flex: 1;
  240. font-size: 17px;
  241. line-height: 20px;
  242. }
  243. }
  244. .bio-row,
  245. .date-location-row {
  246. i {
  247. font-size: 24px;
  248. color: $dark-grey-2;
  249. margin-right: 12px;
  250. }
  251. p {
  252. font-size: 17px;
  253. line-height: 20px;
  254. color: $dark-grey-2;
  255. word-break: break-word;
  256. }
  257. }
  258. .bio-row {
  259. max-width: 608px;
  260. margin-bottom: 24px;
  261. margin-left: auto;
  262. margin-right: auto;
  263. display: flex;
  264. width: max-content;
  265. }
  266. .date-location-row {
  267. max-width: 608px;
  268. margin-left: auto;
  269. margin-right: auto;
  270. margin-bottom: 24px;
  271. display: flex;
  272. width: max-content;
  273. margin-bottom: 24px;
  274. column-gap: 48px;
  275. }
  276. .date,
  277. .location {
  278. display: flex;
  279. }
  280. }
  281. .bottom-section {
  282. width: 960px;
  283. margin-left: auto;
  284. margin-right: auto;
  285. margin-top: 32px;
  286. padding: 24px;
  287. display: flex;
  288. column-gap: 64px;
  289. .buttons {
  290. height: 100%;
  291. width: 251px;
  292. button {
  293. outline: none;
  294. border: none;
  295. box-shadow: none;
  296. color: $musareBlue;
  297. font-size: 22px;
  298. line-height: 26px;
  299. padding: 7px 0 7px 12px;
  300. width: 100%;
  301. text-align: left;
  302. cursor: pointer;
  303. border-radius: 5px;
  304. background-color: transparent;
  305. &.active {
  306. color: $white;
  307. background-color: $musareBlue;
  308. }
  309. }
  310. }
  311. .content {
  312. outline: 1px solid black;
  313. width: 597px;
  314. }
  315. }
  316. .night-mode {
  317. .name,
  318. .username,
  319. .bio-row i,
  320. .bio-row p,
  321. .date-location-row i,
  322. .date-location-row p {
  323. color: $light-grey;
  324. }
  325. }
  326. </style>