Home.vue 31 KB

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