Home.vue 31 KB

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