Home.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298
  1. <template>
  2. <div>
  3. <page-metadata title="Home" />
  4. <div class="app home-page">
  5. <main-header
  6. :hide-logo="true"
  7. :transparent="true"
  8. :hide-logged-out="true"
  9. />
  10. <div class="header" :class="{ loggedIn }">
  11. <img class="background" src="/assets/homebg.jpeg" />
  12. <div class="overlay"></div>
  13. <div class="content-container">
  14. <div class="content">
  15. <img
  16. class="logo"
  17. src="/assets/white_wordmark.png"
  18. :alt="`${this.siteSettings.sitename}` || `Musare`"
  19. />
  20. <div v-if="!loggedIn" class="buttons">
  21. <button
  22. class="button login"
  23. @click="openModal('login')"
  24. >
  25. Login
  26. </button>
  27. <button
  28. v-if="!siteSettings.registrationDisabled"
  29. class="button register"
  30. @click="openModal('register')"
  31. >
  32. Register
  33. </button>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="group" v-show="favoriteStations.length > 0">
  39. <div class="group-title">
  40. <div>
  41. <h2>My Favorites</h2>
  42. </div>
  43. </div>
  44. <draggable
  45. item-key="_id"
  46. v-model="favoriteStations"
  47. v-bind="dragOptions"
  48. @change="changeFavoriteOrder"
  49. >
  50. <template #item="{ element }">
  51. <router-link
  52. :to="{
  53. name: 'station',
  54. params: { id: element.name }
  55. }"
  56. :class="{
  57. 'station-card': true,
  58. 'item-draggable': true,
  59. isPrivate: element.privacy === 'private',
  60. isMine: isOwner(element)
  61. }"
  62. :style="
  63. '--primary-color: var(--' + element.theme + ')'
  64. "
  65. >
  66. <div class="card-content">
  67. <song-thumbnail :song="element.currentSong">
  68. <template #icon>
  69. <div class="icon-container">
  70. <div
  71. v-if="isOwnerOrAdmin(element)"
  72. class="material-icons manage-station"
  73. @click.prevent="
  74. manageStation(element._id)
  75. "
  76. content="Manage Station"
  77. v-tippy
  78. >
  79. settings
  80. </div>
  81. <div
  82. v-else
  83. class="material-icons manage-station"
  84. @click.prevent="
  85. manageStation(element._id)
  86. "
  87. content="View Queue"
  88. v-tippy
  89. >
  90. queue_music
  91. </div>
  92. </div>
  93. </template>
  94. </song-thumbnail>
  95. <div class="media">
  96. <div class="displayName">
  97. <i
  98. v-if="
  99. loggedIn && !element.isFavorited
  100. "
  101. @click.prevent="
  102. favoriteStation(element._id)
  103. "
  104. class="favorite material-icons"
  105. content="Favorite Station"
  106. v-tippy
  107. >star_border</i
  108. >
  109. <i
  110. v-if="
  111. loggedIn && element.isFavorited
  112. "
  113. @click.prevent="
  114. unfavoriteStation(element._id)
  115. "
  116. class="favorite material-icons"
  117. content="Unfavorite Station"
  118. v-tippy
  119. >star</i
  120. >
  121. <h5>{{ element.displayName }}</h5>
  122. <i
  123. v-if="element.type === 'official'"
  124. class="material-icons verified-station"
  125. content="Verified Station"
  126. v-tippy="{
  127. theme: 'info'
  128. }"
  129. >
  130. check_circle
  131. </i>
  132. </div>
  133. <div class="content">
  134. {{ element.description }}
  135. </div>
  136. <div class="under-content">
  137. <p class="hostedBy">
  138. Hosted by
  139. <span class="host">
  140. <span
  141. v-if="
  142. element.type ===
  143. 'official'
  144. "
  145. title="Musare"
  146. >Musare</span
  147. >
  148. <user-id-to-username
  149. v-else
  150. :user-id="element.owner"
  151. :link="true"
  152. />
  153. </span>
  154. </p>
  155. <div class="icons">
  156. <i
  157. v-if="
  158. element.type ===
  159. 'community' &&
  160. isOwner(element)
  161. "
  162. class="homeIcon material-icons"
  163. content="This is your station."
  164. v-tippy="{ theme: 'info' }"
  165. >home</i
  166. >
  167. <i
  168. v-if="
  169. element.privacy ===
  170. 'private'
  171. "
  172. class="privateIcon material-icons"
  173. content="This station is not visible to other users."
  174. v-tippy="{ theme: 'info' }"
  175. >lock</i
  176. >
  177. <i
  178. v-if="
  179. element.privacy ===
  180. 'unlisted'
  181. "
  182. class="unlistedIcon material-icons"
  183. content="Unlisted Station"
  184. v-tippy="{ theme: 'info' }"
  185. >link</i
  186. >
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. <div class="bottomBar">
  192. <i
  193. v-if="
  194. element.paused &&
  195. element.currentSong.title
  196. "
  197. class="material-icons"
  198. content="Station Paused"
  199. v-tippy="{ theme: 'info' }"
  200. >pause</i
  201. >
  202. <i
  203. v-else-if="element.currentSong.title"
  204. class="material-icons"
  205. >music_note</i
  206. >
  207. <i v-else class="material-icons">music_off</i>
  208. <span
  209. v-if="element.currentSong.title"
  210. class="songTitle"
  211. :title="
  212. element.currentSong.artists.length > 0
  213. ? 'Now Playing: ' +
  214. element.currentSong.title +
  215. ' by ' +
  216. element.currentSong.artists.join(
  217. ', '
  218. )
  219. : 'Now Playing: ' +
  220. element.currentSong.title
  221. "
  222. >{{ element.currentSong.title }}
  223. {{
  224. element.currentSong.artists.length > 0
  225. ? " by " +
  226. element.currentSong.artists.join(
  227. ", "
  228. )
  229. : ""
  230. }}</span
  231. >
  232. <span v-else class="songTitle"
  233. >No Songs Playing</span
  234. >
  235. </div>
  236. </router-link>
  237. </template>
  238. </draggable>
  239. </div>
  240. <div class="group bottom">
  241. <div class="group-title">
  242. <div>
  243. <h1>Stations</h1>
  244. </div>
  245. </div>
  246. <a
  247. v-if="loggedIn"
  248. @click="openModal('createStation')"
  249. class="station-card createStation"
  250. >
  251. <div class="card-content">
  252. <div class="thumbnail">
  253. <figure class="image">
  254. <i class="material-icons">radio</i>
  255. </figure>
  256. </div>
  257. <div class="media">
  258. <div class="displayName">
  259. <h5>Create Station</h5>
  260. </div>
  261. <div class="content">
  262. Click here to create your own station!
  263. </div>
  264. </div>
  265. </div>
  266. <div class="bottomBar"></div>
  267. </a>
  268. <a
  269. v-else
  270. @click="openModal('login')"
  271. class="station-card createStation"
  272. >
  273. <div class="card-content">
  274. <div class="thumbnail">
  275. <figure class="image">
  276. <i class="material-icons">radio</i>
  277. </figure>
  278. </div>
  279. <div class="media">
  280. <div class="displayName">
  281. <h5>Create Station</h5>
  282. </div>
  283. <div class="content">
  284. Login to create a station!
  285. </div>
  286. </div>
  287. </div>
  288. <div class="bottomBar"></div>
  289. </a>
  290. <router-link
  291. v-for="station in filteredStations"
  292. :key="station._id"
  293. :to="{
  294. name: 'station',
  295. params: { id: station.name }
  296. }"
  297. class="station-card"
  298. :class="{
  299. isPrivate: station.privacy === 'private',
  300. isMine: isOwner(station)
  301. }"
  302. :style="'--primary-color: var(--' + station.theme + ')'"
  303. >
  304. <div class="card-content">
  305. <song-thumbnail :song="station.currentSong">
  306. <template #icon>
  307. <div class="icon-container">
  308. <div
  309. v-if="isOwnerOrAdmin(station)"
  310. class="material-icons manage-station"
  311. @click.prevent="
  312. manageStation(station._id)
  313. "
  314. content="Manage Station"
  315. v-tippy
  316. >
  317. settings
  318. </div>
  319. <div
  320. v-else
  321. class="material-icons manage-station"
  322. @click.prevent="
  323. manageStation(station._id)
  324. "
  325. content="View Queue"
  326. v-tippy
  327. >
  328. queue_music
  329. </div>
  330. </div>
  331. </template>
  332. </song-thumbnail>
  333. <div class="media">
  334. <div class="displayName">
  335. <i
  336. v-if="loggedIn && !station.isFavorited"
  337. @click.prevent="
  338. favoriteStation(station._id)
  339. "
  340. class="favorite material-icons"
  341. content="Favorite Station"
  342. v-tippy
  343. >star_border</i
  344. >
  345. <i
  346. v-if="loggedIn && station.isFavorited"
  347. @click.prevent="
  348. unfavoriteStation(station._id)
  349. "
  350. class="favorite material-icons"
  351. content="Unfavorite Station"
  352. v-tippy
  353. >star</i
  354. >
  355. <h5>{{ station.displayName }}</h5>
  356. <i
  357. v-if="station.type === 'official'"
  358. class="material-icons verified-station"
  359. content="Verified Station"
  360. v-tippy="{ theme: 'info' }"
  361. >
  362. check_circle
  363. </i>
  364. </div>
  365. <div class="content">
  366. {{ station.description }}
  367. </div>
  368. <div class="under-content">
  369. <p class="hostedBy">
  370. Hosted by
  371. <span class="host">
  372. <span
  373. v-if="station.type === 'official'"
  374. title="Musare"
  375. >Musare</span
  376. >
  377. <user-id-to-username
  378. v-else
  379. :user-id="station.owner"
  380. :link="true"
  381. />
  382. </span>
  383. </p>
  384. <div class="icons">
  385. <i
  386. v-if="
  387. station.type === 'community' &&
  388. isOwner(station)
  389. "
  390. class="homeIcon material-icons"
  391. content="This is your station."
  392. v-tippy="{ theme: 'info' }"
  393. >home</i
  394. >
  395. <i
  396. v-if="station.privacy === 'private'"
  397. class="privateIcon material-icons"
  398. content="This station is not visible to other users."
  399. v-tippy="{ theme: 'info' }"
  400. >lock</i
  401. >
  402. <i
  403. v-if="station.privacy === 'unlisted'"
  404. class="unlistedIcon material-icons"
  405. content="Unlisted Station"
  406. v-tippy="{ theme: 'info' }"
  407. >link</i
  408. >
  409. </div>
  410. </div>
  411. </div>
  412. </div>
  413. <div class="bottomBar">
  414. <i
  415. v-if="station.paused && station.currentSong.title"
  416. class="material-icons"
  417. content="Station Paused"
  418. v-tippy="{ theme: 'info' }"
  419. >pause</i
  420. >
  421. <i
  422. v-else-if="station.currentSong.title"
  423. class="material-icons"
  424. >music_note</i
  425. >
  426. <i v-else class="material-icons">music_off</i>
  427. <span
  428. v-if="station.currentSong.title"
  429. class="songTitle"
  430. :title="
  431. station.currentSong.artists.length > 0
  432. ? 'Now Playing: ' +
  433. station.currentSong.title +
  434. ' by ' +
  435. station.currentSong.artists.join(', ')
  436. : 'Now Playing: ' +
  437. station.currentSong.title
  438. "
  439. >{{ station.currentSong.title }}
  440. {{
  441. station.currentSong.artists.length > 0
  442. ? " by " +
  443. station.currentSong.artists.join(", ")
  444. : ""
  445. }}</span
  446. >
  447. <span v-else class="songTitle">No Songs Playing</span>
  448. </div>
  449. </router-link>
  450. <h4 v-if="stations.length === 0">
  451. There are no stations to display
  452. </h4>
  453. </div>
  454. <main-footer />
  455. </div>
  456. <create-station v-if="modals.createStation" />
  457. <manage-station
  458. v-if="modals.manageStation"
  459. :station-id="editingStationId"
  460. sector="home"
  461. />
  462. <create-playlist v-if="modals.createPlaylist" />
  463. <edit-playlist v-if="modals.editPlaylist" />
  464. <edit-song v-if="modals.editSong" song-type="songs" sector="home" />
  465. <report v-if="modals.report" />
  466. </div>
  467. </template>
  468. <script>
  469. import { mapState, mapGetters, mapActions } from "vuex";
  470. import { defineAsyncComponent } from "vue";
  471. import draggable from "vuedraggable";
  472. import Toast from "toasters";
  473. import MainHeader from "@/components/layout/MainHeader.vue";
  474. import MainFooter from "@/components/layout/MainFooter.vue";
  475. import SongThumbnail from "@/components/SongThumbnail.vue";
  476. import UserIdToUsername from "@/components/UserIdToUsername.vue";
  477. import ws from "@/ws";
  478. export default {
  479. components: {
  480. MainHeader,
  481. MainFooter,
  482. SongThumbnail,
  483. CreateStation: defineAsyncComponent(() =>
  484. import("@/components/modals/CreateStation.vue")
  485. ),
  486. ManageStation: defineAsyncComponent(() =>
  487. import("@/components/modals/ManageStation/index.vue")
  488. ),
  489. EditPlaylist: defineAsyncComponent(() =>
  490. import("@/components/modals/EditPlaylist")
  491. ),
  492. CreatePlaylist: defineAsyncComponent(() =>
  493. import("@/components/modals/CreatePlaylist.vue")
  494. ),
  495. Report: defineAsyncComponent(() =>
  496. import("@/components/modals/Report.vue")
  497. ),
  498. EditSong: defineAsyncComponent(() =>
  499. import("@/components/modals/EditSong")
  500. ),
  501. UserIdToUsername,
  502. draggable
  503. },
  504. data() {
  505. return {
  506. recaptcha: { key: "" },
  507. stations: [],
  508. favoriteStations: [],
  509. searchQuery: "",
  510. siteSettings: {
  511. sitename: "Musare",
  512. registrationDisabled: false
  513. },
  514. orderOfFavoriteStations: [],
  515. handledLoginRegisterRedirect: false,
  516. editingStationId: null
  517. };
  518. },
  519. computed: {
  520. ...mapState({
  521. loggedIn: state => state.user.auth.loggedIn,
  522. userId: state => state.user.auth.userId,
  523. role: state => state.user.auth.role,
  524. modals: state => state.modalVisibility.modals
  525. }),
  526. ...mapGetters({
  527. socket: "websockets/getSocket"
  528. }),
  529. filteredStations() {
  530. const privacyOrder = ["public", "unlisted", "private"];
  531. return this.stations
  532. .filter(
  533. station =>
  534. JSON.stringify(Object.values(station)).indexOf(
  535. this.searchQuery
  536. ) !== -1
  537. )
  538. .sort(
  539. (a, b) =>
  540. this.isOwner(b) - this.isOwner(a) ||
  541. this.isPlaying(b) - this.isPlaying(a) ||
  542. a.paused - b.paused ||
  543. privacyOrder.indexOf(a.privacy) -
  544. privacyOrder.indexOf(b.privacy) ||
  545. b.userCount - a.userCount
  546. );
  547. },
  548. dragOptions() {
  549. return {
  550. animation: 200,
  551. group: "favoriteStations",
  552. disabled: false,
  553. ghostClass: "draggable-list-ghost",
  554. filter: ".ignore-elements",
  555. fallbackTolerance: 50
  556. };
  557. }
  558. },
  559. watch: {
  560. orderOfFavoriteStations: {
  561. deep: true,
  562. handler() {
  563. this.calculateFavoriteStations();
  564. }
  565. }
  566. },
  567. async mounted() {
  568. this.siteSettings = await lofig.get("siteSettings");
  569. if (
  570. !this.loggedIn &&
  571. this.$route.redirectedFrom &&
  572. (this.$route.redirectedFrom.name === "login" ||
  573. this.$route.redirectedFrom.name === "register") &&
  574. !this.handledLoginRegisterRedirect
  575. ) {
  576. // Makes sure the login/register modal isn't opened whenever the home page gets remounted due to a code change
  577. this.handledLoginRegisterRedirect = true;
  578. this.openModal(this.$route.redirectedFrom.name);
  579. }
  580. ws.onConnect(this.init);
  581. this.socket.on("event:station.created", res => {
  582. const { station } = res.data;
  583. if (this.stations.find(_station => _station._id === station._id)) {
  584. this.stations.forEach(s => {
  585. const _station = s;
  586. if (_station._id === station._id) {
  587. _station.privacy = station.privacy;
  588. }
  589. });
  590. } else {
  591. if (!station.currentSong)
  592. station.currentSong = {
  593. thumbnail: "/assets/notes-transparent.png"
  594. };
  595. if (station.currentSong && !station.currentSong.thumbnail)
  596. station.currentSong.ytThumbnail = `https://img.youtube.com/vi/${station.currentSong.youtubeId}/mqdefault.jpg`;
  597. this.stations.push(station);
  598. }
  599. });
  600. this.socket.on("event:station.deleted", res => {
  601. const { stationId } = res.data;
  602. const station = this.stations.find(
  603. station => station._id === stationId
  604. );
  605. if (station) {
  606. const stationIndex = this.stations.indexOf(station);
  607. this.stations.splice(stationIndex, 1);
  608. if (station.isFavorited)
  609. this.orderOfFavoriteStations =
  610. this.orderOfFavoriteStations.filter(
  611. favoritedId => favoritedId !== stationId
  612. );
  613. }
  614. });
  615. this.socket.on("event:station.userCount.updated", res => {
  616. const station = this.stations.find(
  617. station => station._id === res.data.stationId
  618. );
  619. if (station) station.userCount = res.data.userCount;
  620. });
  621. this.socket.on("event:station.updated", res => {
  622. const stationIndex = this.stations
  623. .map(station => station._id)
  624. .indexOf(res.data.station._id);
  625. if (stationIndex !== -1) {
  626. this.stations[stationIndex] = {
  627. ...this.stations[stationIndex],
  628. ...res.data.station
  629. };
  630. this.calculateFavoriteStations();
  631. }
  632. });
  633. this.socket.on("event:station.nextSong", res => {
  634. const station = this.stations.find(
  635. station => station._id === res.data.stationId
  636. );
  637. if (station) {
  638. let newSong = res.data.currentSong;
  639. if (!newSong)
  640. newSong = {
  641. thumbnail: "/assets/notes-transparent.png"
  642. };
  643. station.currentSong = newSong;
  644. }
  645. });
  646. this.socket.on("event:station.pause", res => {
  647. const station = this.stations.find(
  648. station => station._id === res.data.stationId
  649. );
  650. if (station) station.paused = true;
  651. });
  652. this.socket.on("event:station.resume", res => {
  653. const station = this.stations.find(
  654. station => station._id === res.data.stationId
  655. );
  656. if (station) station.paused = false;
  657. });
  658. this.socket.on("event:user.station.favorited", res => {
  659. const { stationId } = res.data;
  660. const station = this.stations.find(
  661. station => station._id === stationId
  662. );
  663. if (station) {
  664. station.isFavorited = true;
  665. this.orderOfFavoriteStations.push(stationId);
  666. }
  667. });
  668. this.socket.on("event:user.station.unfavorited", res => {
  669. const { stationId } = res.data;
  670. const station = this.stations.find(
  671. station => station._id === stationId
  672. );
  673. if (station) {
  674. station.isFavorited = false;
  675. this.orderOfFavoriteStations =
  676. this.orderOfFavoriteStations.filter(
  677. favoritedId => favoritedId !== stationId
  678. );
  679. }
  680. });
  681. this.socket.on("event:user.orderOfFavoriteStations.updated", res => {
  682. this.orderOfFavoriteStations = res.data.order;
  683. });
  684. },
  685. beforeUnmount() {
  686. this.socket.dispatch("apis.leaveRoom", "home", () => {});
  687. },
  688. methods: {
  689. init() {
  690. this.socket.dispatch("stations.index", res => {
  691. this.stations = [];
  692. if (res.status === "success") {
  693. res.data.stations.forEach(station => {
  694. const modifiableStation = station;
  695. if (!modifiableStation.currentSong)
  696. modifiableStation.currentSong = {
  697. thumbnail: "/assets/notes-transparent.png"
  698. };
  699. if (
  700. modifiableStation.currentSong &&
  701. !modifiableStation.currentSong.thumbnail
  702. )
  703. modifiableStation.currentSong.ytThumbnail = `https://img.youtube.com/vi/${station.currentSong.youtubeId}/mqdefault.jpg`;
  704. this.stations.push(modifiableStation);
  705. });
  706. this.orderOfFavoriteStations = res.data.favorited;
  707. }
  708. });
  709. this.socket.dispatch("apis.joinRoom", "home");
  710. },
  711. isOwner(station) {
  712. return this.loggedIn && station.owner === this.userId;
  713. },
  714. isAdmin() {
  715. return this.loggedIn && this.role === "admin";
  716. },
  717. isOwnerOrAdmin(station) {
  718. return this.isOwner(station) || this.isAdmin();
  719. },
  720. isPlaying(station) {
  721. return typeof station.currentSong.title !== "undefined";
  722. },
  723. favoriteStation(stationId) {
  724. this.socket.dispatch("stations.favoriteStation", stationId, res => {
  725. if (res.status === "success") {
  726. new Toast("Successfully favorited station.");
  727. } else new Toast(res.message);
  728. });
  729. },
  730. unfavoriteStation(stationId) {
  731. this.socket.dispatch(
  732. "stations.unfavoriteStation",
  733. stationId,
  734. res => {
  735. if (res.status === "success") {
  736. new Toast("Successfully unfavorited station.");
  737. } else new Toast(res.message);
  738. }
  739. );
  740. },
  741. calculateFavoriteStations() {
  742. this.favoriteStations = this.filteredStations
  743. .filter(station => station.isFavorited === true)
  744. .sort(
  745. (a, b) =>
  746. this.orderOfFavoriteStations.indexOf(a._id) -
  747. this.orderOfFavoriteStations.indexOf(b._id)
  748. );
  749. },
  750. changeFavoriteOrder() {
  751. const recalculatedOrder = [];
  752. this.favoriteStations.forEach(station =>
  753. recalculatedOrder.push(station._id)
  754. );
  755. this.socket.dispatch(
  756. "users.updateOrderOfFavoriteStations",
  757. recalculatedOrder,
  758. res => new Toast(res.message)
  759. );
  760. },
  761. manageStation(stationId) {
  762. this.editingStationId = stationId;
  763. this.openModal("manageStation");
  764. },
  765. ...mapActions("modalVisibility", ["openModal"]),
  766. ...mapActions("station", ["updateIfStationIsFavorited"])
  767. }
  768. };
  769. </script>
  770. <style lang="less">
  771. .christmas-mode .home-page {
  772. .header .overlay {
  773. background: linear-gradient(
  774. 180deg,
  775. rgba(231, 77, 60, 0.8) 0%,
  776. rgba(231, 77, 60, 0.95) 31.25%,
  777. rgba(231, 77, 60, 0.9) 54.17%,
  778. rgba(231, 77, 60, 0.8) 100%
  779. );
  780. }
  781. .christmas-lights {
  782. top: 300px !important;
  783. &.loggedIn {
  784. top: 200px !important;
  785. }
  786. }
  787. .header {
  788. &,
  789. .background,
  790. .overlay {
  791. border-radius: unset;
  792. }
  793. }
  794. }
  795. </style>
  796. <style lang="less" scoped>
  797. * {
  798. box-sizing: border-box;
  799. }
  800. html {
  801. width: 100%;
  802. height: 100%;
  803. color: rgba(0, 0, 0, 0.87);
  804. body {
  805. width: 100%;
  806. height: 100%;
  807. margin: 0;
  808. padding: 0;
  809. }
  810. @media only screen and (min-width: 1200px) {
  811. font-size: 15px;
  812. }
  813. @media only screen and (min-width: 992px) {
  814. font-size: 14.5px;
  815. }
  816. @media only screen and (min-width: 0) {
  817. font-size: 14px;
  818. }
  819. }
  820. .night-mode {
  821. .header .overlay {
  822. background: linear-gradient(
  823. 180deg,
  824. rgba(34, 34, 34, 0.8) 0%,
  825. rgba(34, 34, 34, 0.95) 31.25%,
  826. rgba(34, 34, 34, 0.9) 54.17%,
  827. rgba(34, 34, 34, 0.8) 100%
  828. );
  829. }
  830. .station-card {
  831. background-color: var(--dark-grey-3);
  832. .thumbnail {
  833. background-color: var(--dark-grey-2);
  834. i {
  835. user-select: none;
  836. -webkit-user-select: none;
  837. }
  838. }
  839. .card-content .media {
  840. .icons i,
  841. .under-content .hostedBy {
  842. color: var(--light-grey-2) !important;
  843. }
  844. }
  845. }
  846. .group-title i {
  847. color: var(--light-grey-2);
  848. }
  849. }
  850. .header {
  851. display: flex;
  852. height: 300px;
  853. margin-top: -64px;
  854. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  855. img.background {
  856. height: 300px;
  857. width: 100%;
  858. object-fit: cover;
  859. object-position: center;
  860. filter: blur(1px);
  861. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  862. overflow: hidden;
  863. user-select: none;
  864. }
  865. .overlay {
  866. background: linear-gradient(
  867. 180deg,
  868. rgba(3, 169, 244, 0.8) 0%,
  869. rgba(3, 169, 244, 0.95) 31.25%,
  870. rgba(3, 169, 244, 0.9) 54.17%,
  871. rgba(3, 169, 244, 0.8) 100%
  872. );
  873. position: absolute;
  874. height: 300px;
  875. width: 100%;
  876. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  877. overflow: hidden;
  878. }
  879. .content-container {
  880. position: absolute;
  881. left: 0;
  882. right: 0;
  883. margin-left: auto;
  884. margin-right: auto;
  885. text-align: center;
  886. height: 300px;
  887. .content {
  888. position: absolute;
  889. top: 50%;
  890. left: 0;
  891. right: 0;
  892. transform: translateY(-50%);
  893. background-color: transparent !important;
  894. img.logo {
  895. max-height: 90px;
  896. font-size: 40px;
  897. color: var(--white);
  898. font-family: Pacifico, cursive;
  899. user-select: none;
  900. }
  901. .buttons {
  902. display: flex;
  903. justify-content: center;
  904. margin-top: 20px;
  905. flex-wrap: wrap;
  906. .login,
  907. .register {
  908. margin: 5px 10px;
  909. padding: 10px 15px;
  910. border-radius: @border-radius;
  911. font-size: 18px;
  912. width: 100%;
  913. max-width: 250px;
  914. font-weight: 600;
  915. border: 0;
  916. height: inherit;
  917. }
  918. .login {
  919. background: var(--white);
  920. color: var(--primary-color);
  921. }
  922. .register {
  923. background: var(--purple);
  924. color: var(--white);
  925. }
  926. }
  927. }
  928. }
  929. &.loggedIn {
  930. height: 200px;
  931. .overlay,
  932. .content-container,
  933. img.background {
  934. height: 200px;
  935. }
  936. }
  937. }
  938. .app {
  939. display: flex;
  940. flex-direction: column;
  941. }
  942. .station-card {
  943. display: inline-flex;
  944. position: relative;
  945. background-color: var(--white);
  946. color: var(--dark-grey);
  947. flex-direction: row;
  948. overflow: hidden;
  949. margin: 10px;
  950. cursor: pointer;
  951. filter: none;
  952. height: 150px;
  953. width: calc(100% - 30px);
  954. max-width: 400px;
  955. flex-wrap: wrap;
  956. border-radius: @border-radius;
  957. box-shadow: @box-shadow;
  958. .card-content {
  959. display: flex;
  960. flex-direction: row;
  961. flex-grow: 1;
  962. .thumbnail {
  963. display: flex;
  964. position: relative;
  965. min-width: 120px;
  966. width: 120px;
  967. height: 120px;
  968. margin: 0;
  969. .image {
  970. display: flex;
  971. position: relative;
  972. padding-top: 100%;
  973. }
  974. .icon-container {
  975. display: flex;
  976. position: absolute;
  977. z-index: 2;
  978. top: 0;
  979. bottom: 0;
  980. left: 0;
  981. right: 0;
  982. .material-icons.manage-station {
  983. display: inline-flex;
  984. opacity: 0;
  985. background: var(--primary-color);
  986. color: var(--white);
  987. margin: auto;
  988. font-size: 40px;
  989. border-radius: 100%;
  990. padding: 10px;
  991. transition: all 0.2s ease-in-out;
  992. }
  993. &:hover,
  994. &:focus {
  995. .material-icons.manage-station {
  996. opacity: 1;
  997. &:hover,
  998. &:focus {
  999. filter: brightness(90%);
  1000. }
  1001. }
  1002. }
  1003. }
  1004. }
  1005. .media {
  1006. display: flex;
  1007. position: relative;
  1008. padding: 10px 10px 10px 15px;
  1009. flex-direction: column;
  1010. flex-grow: 1;
  1011. -webkit-line-clamp: 2;
  1012. .displayName {
  1013. display: flex;
  1014. align-items: center;
  1015. width: 100%;
  1016. overflow: hidden;
  1017. text-overflow: ellipsis;
  1018. display: flex;
  1019. line-height: 30px;
  1020. max-height: 30px;
  1021. .favorite {
  1022. position: absolute;
  1023. color: var(--yellow);
  1024. right: 10px;
  1025. top: 10px;
  1026. font-size: 28px;
  1027. }
  1028. h5 {
  1029. font-size: 20px;
  1030. font-weight: 400;
  1031. margin: 0;
  1032. display: inline;
  1033. margin-right: 6px;
  1034. line-height: 30px;
  1035. text-overflow: ellipsis;
  1036. overflow: hidden;
  1037. white-space: nowrap;
  1038. max-width: 200px;
  1039. }
  1040. i {
  1041. font-size: 22px;
  1042. }
  1043. .verified-station {
  1044. color: var(--primary-color);
  1045. }
  1046. }
  1047. .content {
  1048. word-wrap: break-word;
  1049. overflow: hidden;
  1050. text-overflow: ellipsis;
  1051. display: -webkit-box;
  1052. -webkit-box-orient: vertical;
  1053. -webkit-line-clamp: 3;
  1054. line-height: 20px;
  1055. flex-grow: 1;
  1056. text-align: left;
  1057. word-wrap: break-word;
  1058. margin-bottom: 0;
  1059. }
  1060. .under-content {
  1061. height: 20px;
  1062. position: relative;
  1063. line-height: 1;
  1064. font-size: 24px;
  1065. display: flex;
  1066. align-items: center;
  1067. text-align: left;
  1068. margin-top: 10px;
  1069. p {
  1070. font-size: 15px;
  1071. line-height: 15px;
  1072. display: inline;
  1073. }
  1074. i {
  1075. font-size: 20px;
  1076. }
  1077. * {
  1078. z-index: 10;
  1079. position: relative;
  1080. }
  1081. .icons {
  1082. position: absolute;
  1083. right: 0;
  1084. .material-icons {
  1085. font-size: 22px;
  1086. }
  1087. .material-icons:first-child {
  1088. margin-left: 5px;
  1089. }
  1090. .unlistedIcon {
  1091. color: var(--orange);
  1092. }
  1093. .privateIcon {
  1094. color: var(--dark-pink);
  1095. }
  1096. .homeIcon {
  1097. color: var(--light-purple);
  1098. }
  1099. }
  1100. .hostedBy {
  1101. font-weight: 400;
  1102. font-size: 12px;
  1103. color: var(--black);
  1104. .host,
  1105. .host a {
  1106. font-weight: 400;
  1107. color: var(--primary-color);
  1108. &:hover,
  1109. &:focus {
  1110. filter: brightness(90%);
  1111. }
  1112. }
  1113. }
  1114. }
  1115. }
  1116. }
  1117. .bottomBar {
  1118. position: relative;
  1119. display: flex;
  1120. align-items: center;
  1121. background: var(--primary-color);
  1122. width: 100%;
  1123. height: 30px;
  1124. line-height: 30px;
  1125. color: var(--white);
  1126. font-weight: 400;
  1127. font-size: 12px;
  1128. padding: 0 5px;
  1129. flex-basis: 100%;
  1130. i.material-icons {
  1131. vertical-align: middle;
  1132. margin-left: 5px;
  1133. font-size: 22px;
  1134. }
  1135. .songTitle {
  1136. text-align: left;
  1137. vertical-align: middle;
  1138. margin-left: 5px;
  1139. line-height: 30px;
  1140. flex: 2 1 0;
  1141. overflow: hidden;
  1142. text-overflow: ellipsis;
  1143. white-space: nowrap;
  1144. }
  1145. }
  1146. &.createStation {
  1147. .card-content {
  1148. .thumbnail {
  1149. .image {
  1150. width: 120px;
  1151. .material-icons {
  1152. position: absolute;
  1153. top: 25px;
  1154. bottom: 25px;
  1155. left: 0;
  1156. right: 0;
  1157. text-align: center;
  1158. font-size: 70px;
  1159. color: var(--primary-color);
  1160. }
  1161. }
  1162. }
  1163. .media {
  1164. margin: auto 0;
  1165. .displayName h5 {
  1166. font-weight: 600;
  1167. }
  1168. .content {
  1169. flex-grow: unset;
  1170. margin-bottom: auto;
  1171. }
  1172. }
  1173. }
  1174. }
  1175. &:hover {
  1176. box-shadow: @box-shadow-hover;
  1177. transition: all ease-in-out 0.2s;
  1178. }
  1179. }
  1180. .group {
  1181. flex: 1 0 auto;
  1182. text-align: center;
  1183. width: 100%;
  1184. margin: 10px 0;
  1185. min-height: 64px;
  1186. .group-title {
  1187. display: flex;
  1188. align-items: center;
  1189. justify-content: center;
  1190. margin: 25px 0;
  1191. h1 {
  1192. display: inline-block;
  1193. font-size: 45px;
  1194. margin: 0;
  1195. }
  1196. h2 {
  1197. font-size: 35px;
  1198. margin: 0;
  1199. }
  1200. a {
  1201. display: flex;
  1202. margin-left: 8px;
  1203. }
  1204. }
  1205. &.bottom {
  1206. margin-bottom: 40px;
  1207. }
  1208. }
  1209. </style>