Home.vue 29 KB

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