index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <div v-if="isUser">
  3. <edit-playlist v-if="modals.editPlaylist" />
  4. <view-report v-if="modals.viewReport" />
  5. <edit-song v-if="modals.editSong" song-type="songs" />
  6. <report v-if="modals.report" />
  7. <page-metadata :title="`Profile | ${user.username}`" />
  8. <main-header />
  9. <div class="container">
  10. <div class="info-section">
  11. <div class="picture-name-row">
  12. <profile-picture
  13. :avatar="user.avatar"
  14. :name="user.name ? user.name : user.username"
  15. />
  16. <div>
  17. <div class="name-row" v-if="user.name">
  18. <p class="name">{{ user.name }}</p>
  19. <span
  20. class="role admin"
  21. v-if="user.role === 'admin'"
  22. >admin</span
  23. >
  24. </div>
  25. <div class="username-row">
  26. <h2 class="username">@{{ user.username }}</h2>
  27. <span
  28. class="role admin"
  29. v-if="user.role === 'admin' && !user.name"
  30. >admin</span
  31. >
  32. </div>
  33. </div>
  34. </div>
  35. <div
  36. class="buttons"
  37. v-if="myUserId === userId || role === 'admin'"
  38. >
  39. <router-link
  40. :to="`/admin/users?userId=${user._id}`"
  41. class="button is-primary"
  42. v-if="role === 'admin'"
  43. >
  44. Edit
  45. </router-link>
  46. <router-link
  47. to="/settings"
  48. class="button is-primary"
  49. v-if="myUserId === userId"
  50. >
  51. Settings
  52. </router-link>
  53. </div>
  54. <div class="bio-row" v-if="user.bio">
  55. <i class="material-icons">notes</i>
  56. <p>{{ user.bio }}</p>
  57. </div>
  58. <div
  59. class="date-location-row"
  60. v-if="user.createdAt || user.location"
  61. >
  62. <div class="date" v-if="user.createdAt">
  63. <i
  64. class="material-icons"
  65. content="Account Creation Date"
  66. v-tippy="{ theme: 'info' }"
  67. >calendar_today</i
  68. >
  69. <p>{{ user.createdAt }}</p>
  70. </div>
  71. <div class="location" v-if="user.location">
  72. <i class="material-icons">location_on</i>
  73. <p>{{ user.location }}</p>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="bottom-section">
  78. <div class="buttons">
  79. <button
  80. :class="{ active: tab === 'recent-activity' }"
  81. @click="showTab('recent-activity')"
  82. >
  83. Recent activity
  84. </button>
  85. <button
  86. :class="{ active: tab === 'playlists' }"
  87. @click="showTab('playlists')"
  88. >
  89. Playlists
  90. </button>
  91. </div>
  92. <playlists
  93. :user-id="userId"
  94. :username="user.name"
  95. v-show="tab === 'playlists'"
  96. />
  97. <recent-activity
  98. :user-id="userId"
  99. v-show="tab === 'recent-activity'"
  100. />
  101. </div>
  102. </div>
  103. <main-footer />
  104. </div>
  105. </template>
  106. <script>
  107. import { mapState, mapGetters } from "vuex";
  108. import { format, parseISO } from "date-fns";
  109. import { defineAsyncComponent } from "vue";
  110. import ws from "@/ws";
  111. import TabQueryHandler from "@/mixins/TabQueryHandler.vue";
  112. import ProfilePicture from "@/components/ProfilePicture";
  113. import MainHeader from "@/components/layout/MainHeader";
  114. import MainFooter from "@/components/layout/MainFooter.vue";
  115. import RecentActivity from "./Tabs/RecentActivity.vue";
  116. import Playlists from "./Tabs/Playlists.vue";
  117. export default {
  118. components: {
  119. MainHeader,
  120. MainFooter,
  121. ProfilePicture,
  122. RecentActivity,
  123. Playlists,
  124. EditPlaylist: defineAsyncComponent(() =>
  125. import("@/components/modals/EditPlaylist")
  126. ),
  127. Report: defineAsyncComponent(() =>
  128. import("@/components/modals/Report.vue")
  129. ),
  130. ViewReport: defineAsyncComponent(() =>
  131. import("@/components/modals/ViewReport.vue")
  132. ),
  133. EditSong: defineAsyncComponent(() =>
  134. import("@/components/modals/EditSong")
  135. )
  136. },
  137. mixins: [TabQueryHandler],
  138. data() {
  139. return {
  140. user: {},
  141. userId: "",
  142. isUser: false,
  143. tab: "recent-activity"
  144. };
  145. },
  146. computed: {
  147. ...mapState({
  148. role: state => state.user.auth.role,
  149. myUserId: state => state.user.auth.userId,
  150. ...mapState("modalVisibility", {
  151. modals: state => state.modals
  152. })
  153. }),
  154. ...mapGetters({
  155. socket: "websockets/getSocket"
  156. })
  157. },
  158. mounted() {
  159. if (
  160. this.$route.query.tab === "recent-activity" ||
  161. this.$route.query.tab === "playlists"
  162. )
  163. this.tab = this.$route.query.tab;
  164. ws.onConnect(this.init);
  165. },
  166. methods: {
  167. init() {
  168. this.socket.dispatch(
  169. "users.findByUsername",
  170. this.$route.params.username,
  171. res => {
  172. if (res.status === "error") this.$router.push("/404");
  173. else {
  174. this.user = res.data;
  175. this.user.createdAt = format(
  176. parseISO(this.user.createdAt),
  177. "MMMM do yyyy"
  178. );
  179. this.isUser = true;
  180. this.userId = this.user._id;
  181. }
  182. }
  183. );
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="scss" scoped>
  189. @media only screen and (max-width: 1250px) {
  190. .bottom-section .content {
  191. width: 650px !important;
  192. }
  193. }
  194. @media only screen and (max-width: 900px) {
  195. .info-section {
  196. margin-top: 0 !important;
  197. .picture-name-row {
  198. flex-direction: column !important;
  199. .profile-picture {
  200. margin-right: 0 !important;
  201. }
  202. }
  203. .name-row {
  204. margin-top: 24px;
  205. }
  206. .username-row {
  207. justify-content: center;
  208. }
  209. .buttons .button:not(:last-of-type) {
  210. margin-bottom: 10px;
  211. margin-right: 5px;
  212. }
  213. .date-location-row {
  214. flex-direction: column;
  215. width: auto !important;
  216. row-gap: 24px;
  217. .date,
  218. .location {
  219. justify-content: center;
  220. }
  221. }
  222. .date-location-row > div:nth-child(2),
  223. .buttons .button:nth-child(2) {
  224. margin-left: 0 !important;
  225. }
  226. }
  227. .bottom-section {
  228. flex-direction: column;
  229. .buttons,
  230. .content {
  231. margin-left: auto;
  232. margin-right: auto !important;
  233. }
  234. }
  235. .content {
  236. margin: 24px 0;
  237. }
  238. }
  239. .info-section {
  240. width: 912px;
  241. max-width: 100%;
  242. margin-left: auto;
  243. margin-right: auto;
  244. margin-top: 32px;
  245. padding: 24px;
  246. .picture-name-row {
  247. display: flex;
  248. flex-direction: row;
  249. align-items: center;
  250. justify-content: center;
  251. margin-bottom: 24px;
  252. .profile-picture {
  253. margin-right: 32px;
  254. }
  255. }
  256. .name-row,
  257. .username-row {
  258. display: flex;
  259. flex-direction: row;
  260. align-items: center;
  261. }
  262. .name {
  263. font-size: 34px;
  264. line-height: 40px;
  265. color: var(--dark-grey-4);
  266. }
  267. .role {
  268. padding: 2px 24px;
  269. color: var(--white);
  270. text-transform: uppercase;
  271. font-size: 12px;
  272. line-height: 14px;
  273. height: 18px;
  274. border-radius: 5px;
  275. margin-left: 12px;
  276. &.admin {
  277. background-color: var(--red);
  278. }
  279. }
  280. .username {
  281. font-size: 24px;
  282. line-height: 28px;
  283. color: var(--dark-grey);
  284. margin: 0;
  285. }
  286. .buttons {
  287. width: 388px;
  288. max-width: 100%;
  289. display: flex;
  290. flex-direction: row;
  291. margin-left: auto;
  292. margin-right: auto;
  293. margin-bottom: 24px;
  294. .button {
  295. flex: 1;
  296. font-size: 17px;
  297. line-height: 20px;
  298. &:nth-child(2) {
  299. margin-left: 20px;
  300. }
  301. }
  302. }
  303. .bio-row,
  304. .date-location-row {
  305. i {
  306. font-size: 24px;
  307. color: var(--dark-grey-2);
  308. margin-right: 12px;
  309. }
  310. p {
  311. font-size: 17px;
  312. line-height: 20px;
  313. color: var(--dark-grey-2);
  314. word-break: break-word;
  315. }
  316. }
  317. .bio-row {
  318. max-width: 608px;
  319. margin-bottom: 24px;
  320. margin-left: auto;
  321. margin-right: auto;
  322. display: flex;
  323. width: max-content;
  324. }
  325. .date-location-row {
  326. max-width: 608px;
  327. margin-left: auto;
  328. margin-right: auto;
  329. margin-bottom: 24px;
  330. display: flex;
  331. width: max-content;
  332. margin-bottom: 24px;
  333. > div:nth-child(2) {
  334. margin-left: 48px;
  335. }
  336. }
  337. .date,
  338. .location {
  339. display: flex;
  340. }
  341. }
  342. .bottom-section {
  343. max-width: 100%;
  344. margin-left: auto;
  345. margin-right: auto;
  346. padding: 24px;
  347. display: flex;
  348. .buttons {
  349. height: 100%;
  350. width: 250px;
  351. margin-right: 64px;
  352. button {
  353. outline: none;
  354. border: none;
  355. box-shadow: none;
  356. color: var(--primary-color);
  357. font-size: 22px;
  358. line-height: 26px;
  359. padding: 7px 0 7px 12px;
  360. width: 100%;
  361. text-align: left;
  362. cursor: pointer;
  363. border-radius: 5px;
  364. background-color: transparent;
  365. &.active {
  366. color: var(--white);
  367. background-color: var(--primary-color);
  368. }
  369. }
  370. }
  371. .content /deep/ {
  372. width: 800px;
  373. max-width: 100%;
  374. background-color: var(--white);
  375. padding: 30px 50px;
  376. border-radius: 3px;
  377. h3 {
  378. font-weight: 400;
  379. }
  380. .item {
  381. overflow: initial;
  382. &:not(:last-of-type) {
  383. margin-bottom: 10px;
  384. }
  385. }
  386. #create-new-playlist-button {
  387. margin-top: 30px;
  388. width: 100%;
  389. }
  390. }
  391. }
  392. .night-mode {
  393. .name,
  394. .username,
  395. .bio-row i,
  396. .bio-row p,
  397. .date-location-row i,
  398. .date-location-row p,
  399. .item .left-part .top-text,
  400. .item .left-part .bottom-text,
  401. .bottom-section
  402. .content
  403. .item.activity-item
  404. .thumbnail
  405. .activity-type-icon {
  406. color: var(--light-grey-2);
  407. }
  408. }
  409. </style>