index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <div v-if="isUser">
  3. <edit-playlist v-if="modals.editPlaylist" />
  4. <report v-if="modals.report" />
  5. <view-report v-if="modals.viewReport" />
  6. <edit-song v-if="modals.editSong" song-type="songs" />
  7. <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 TabQueryHandler from "@/mixins/TabQueryHandler.vue";
  111. import ProfilePicture from "@/components/ProfilePicture";
  112. import MainHeader from "@/components/layout/MainHeader";
  113. import MainFooter from "@/components/layout/MainFooter.vue";
  114. import RecentActivity from "./Tabs/RecentActivity.vue";
  115. import Playlists from "./Tabs/Playlists.vue";
  116. export default {
  117. components: {
  118. MainHeader,
  119. MainFooter,
  120. ProfilePicture,
  121. RecentActivity,
  122. Playlists,
  123. EditPlaylist: defineAsyncComponent(() =>
  124. import("@/components/modals/EditPlaylist")
  125. ),
  126. Report: defineAsyncComponent(() =>
  127. import("@/components/modals/Report.vue")
  128. ),
  129. ViewReport: defineAsyncComponent(() =>
  130. import("@/components/modals/ViewReport.vue")
  131. ),
  132. EditSong: defineAsyncComponent(() =>
  133. import("@/components/modals/EditSong")
  134. )
  135. },
  136. mixins: [TabQueryHandler],
  137. data() {
  138. return {
  139. user: {},
  140. userId: "",
  141. isUser: false,
  142. tab: "recent-activity"
  143. };
  144. },
  145. computed: {
  146. ...mapState({
  147. role: state => state.user.auth.role,
  148. myUserId: state => state.user.auth.userId,
  149. ...mapState("modalVisibility", {
  150. modals: state => state.modals
  151. })
  152. }),
  153. ...mapGetters({
  154. socket: "websockets/getSocket"
  155. })
  156. },
  157. mounted() {
  158. if (
  159. this.$route.query.tab === "recent-activity" ||
  160. this.$route.query.tab === "playlists"
  161. )
  162. this.tab = this.$route.query.tab;
  163. this.socket.dispatch(
  164. "users.findByUsername",
  165. this.$route.params.username,
  166. res => {
  167. if (res.status === "error") this.$router.push("/404");
  168. else {
  169. this.user = res.data;
  170. this.user.createdAt = format(
  171. parseISO(this.user.createdAt),
  172. "MMMM do yyyy"
  173. );
  174. this.isUser = true;
  175. this.userId = this.user._id;
  176. }
  177. }
  178. );
  179. }
  180. };
  181. </script>
  182. <style lang="scss" scoped>
  183. @media only screen and (max-width: 1250px) {
  184. .bottom-section .content {
  185. width: 650px !important;
  186. }
  187. }
  188. @media only screen and (max-width: 900px) {
  189. .info-section {
  190. margin-top: 0 !important;
  191. .picture-name-row {
  192. flex-direction: column !important;
  193. .profile-picture {
  194. margin-right: 0 !important;
  195. }
  196. }
  197. .name-row {
  198. margin-top: 24px;
  199. }
  200. .username-row {
  201. justify-content: center;
  202. }
  203. .buttons .button:not(:last-of-type) {
  204. margin-bottom: 10px;
  205. margin-right: 5px;
  206. }
  207. .date-location-row {
  208. flex-direction: column;
  209. width: auto !important;
  210. row-gap: 24px;
  211. .date,
  212. .location {
  213. justify-content: center;
  214. }
  215. }
  216. .date-location-row > div:nth-child(2),
  217. .buttons .button:nth-child(2) {
  218. margin-left: 0 !important;
  219. }
  220. }
  221. .bottom-section {
  222. flex-direction: column;
  223. .buttons,
  224. .content {
  225. margin-left: auto;
  226. margin-right: auto !important;
  227. }
  228. }
  229. .content {
  230. margin: 24px 0;
  231. }
  232. }
  233. .info-section {
  234. width: 912px;
  235. max-width: 100%;
  236. margin-left: auto;
  237. margin-right: auto;
  238. margin-top: 32px;
  239. padding: 24px;
  240. .picture-name-row {
  241. display: flex;
  242. flex-direction: row;
  243. align-items: center;
  244. justify-content: center;
  245. margin-bottom: 24px;
  246. .profile-picture {
  247. margin-right: 32px;
  248. }
  249. }
  250. .name-row,
  251. .username-row {
  252. display: flex;
  253. flex-direction: row;
  254. align-items: center;
  255. }
  256. .name {
  257. font-size: 34px;
  258. line-height: 40px;
  259. color: var(--dark-grey-4);
  260. }
  261. .role {
  262. padding: 2px 24px;
  263. color: var(--white);
  264. text-transform: uppercase;
  265. font-size: 12px;
  266. line-height: 14px;
  267. height: 18px;
  268. border-radius: 5px;
  269. margin-left: 12px;
  270. &.admin {
  271. background-color: var(--red);
  272. }
  273. }
  274. .username {
  275. font-size: 24px;
  276. line-height: 28px;
  277. color: var(--dark-grey);
  278. margin: 0;
  279. }
  280. .buttons {
  281. width: 388px;
  282. max-width: 100%;
  283. display: flex;
  284. flex-direction: row;
  285. margin-left: auto;
  286. margin-right: auto;
  287. margin-bottom: 24px;
  288. .button {
  289. flex: 1;
  290. font-size: 17px;
  291. line-height: 20px;
  292. &:nth-child(2) {
  293. margin-left: 20px;
  294. }
  295. }
  296. }
  297. .bio-row,
  298. .date-location-row {
  299. i {
  300. font-size: 24px;
  301. color: var(--dark-grey-2);
  302. margin-right: 12px;
  303. }
  304. p {
  305. font-size: 17px;
  306. line-height: 20px;
  307. color: var(--dark-grey-2);
  308. word-break: break-word;
  309. }
  310. }
  311. .bio-row {
  312. max-width: 608px;
  313. margin-bottom: 24px;
  314. margin-left: auto;
  315. margin-right: auto;
  316. display: flex;
  317. width: max-content;
  318. }
  319. .date-location-row {
  320. max-width: 608px;
  321. margin-left: auto;
  322. margin-right: auto;
  323. margin-bottom: 24px;
  324. display: flex;
  325. width: max-content;
  326. margin-bottom: 24px;
  327. > div:nth-child(2) {
  328. margin-left: 48px;
  329. }
  330. }
  331. .date,
  332. .location {
  333. display: flex;
  334. }
  335. }
  336. .bottom-section {
  337. max-width: 100%;
  338. margin-left: auto;
  339. margin-right: auto;
  340. padding: 24px;
  341. display: flex;
  342. .buttons {
  343. height: 100%;
  344. width: 250px;
  345. margin-right: 64px;
  346. button {
  347. outline: none;
  348. border: none;
  349. box-shadow: none;
  350. color: var(--primary-color);
  351. font-size: 22px;
  352. line-height: 26px;
  353. padding: 7px 0 7px 12px;
  354. width: 100%;
  355. text-align: left;
  356. cursor: pointer;
  357. border-radius: 5px;
  358. background-color: transparent;
  359. &.active {
  360. color: var(--white);
  361. background-color: var(--primary-color);
  362. }
  363. }
  364. }
  365. .content /deep/ {
  366. width: 800px;
  367. max-width: 100%;
  368. background-color: var(--white);
  369. padding: 30px 50px;
  370. border-radius: 3px;
  371. h3 {
  372. font-weight: 400;
  373. }
  374. .item {
  375. overflow: initial;
  376. &:not(:last-of-type) {
  377. margin-bottom: 10px;
  378. }
  379. }
  380. #create-new-playlist-button {
  381. margin-top: 30px;
  382. width: 100%;
  383. }
  384. }
  385. }
  386. .night-mode {
  387. .name,
  388. .username,
  389. .bio-row i,
  390. .bio-row p,
  391. .date-location-row i,
  392. .date-location-row p,
  393. .item .left-part .top-text,
  394. .item .left-part .bottom-text,
  395. .bottom-section
  396. .content
  397. .item.activity-item
  398. .thumbnail
  399. .activity-type-icon {
  400. color: var(--light-grey-2);
  401. }
  402. }
  403. </style>