index.vue 7.2 KB

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