Home.vue 31 KB

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