Home.vue 29 KB

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