Home.vue 31 KB

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