index.vue 7.9 KB

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