1
0

index.vue 7.5 KB

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