Home.vue 31 KB

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