Home.vue 30 KB

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