Home.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  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: linear-gradient(
  877. 180deg,
  878. rgba(231, 77, 60, 0.8) 0%,
  879. rgba(231, 77, 60, 0.95) 31.25%,
  880. rgba(231, 77, 60, 0.9) 54.17%,
  881. rgba(231, 77, 60, 0.8) 100%
  882. );
  883. }
  884. .christmas-lights {
  885. top: 300px !important;
  886. &.loggedIn {
  887. top: 200px !important;
  888. }
  889. }
  890. .header {
  891. &,
  892. .background,
  893. .overlay {
  894. border-radius: unset;
  895. }
  896. }
  897. }
  898. </style>
  899. <style lang="less" scoped>
  900. * {
  901. box-sizing: border-box;
  902. }
  903. html {
  904. width: 100%;
  905. height: 100%;
  906. color: rgba(0, 0, 0, 0.87);
  907. body {
  908. width: 100%;
  909. height: 100%;
  910. margin: 0;
  911. padding: 0;
  912. }
  913. @media only screen and (min-width: 1200px) {
  914. font-size: 15px;
  915. }
  916. @media only screen and (min-width: 992px) {
  917. font-size: 14.5px;
  918. }
  919. @media only screen and (min-width: 0) {
  920. font-size: 14px;
  921. }
  922. }
  923. .night-mode {
  924. .header .overlay {
  925. background: linear-gradient(
  926. 180deg,
  927. rgba(34, 34, 34, 0.8) 0%,
  928. rgba(34, 34, 34, 0.95) 31.25%,
  929. rgba(34, 34, 34, 0.9) 54.17%,
  930. rgba(34, 34, 34, 0.8) 100%
  931. );
  932. }
  933. .station-card {
  934. background-color: var(--dark-grey-3);
  935. .thumbnail {
  936. background-color: var(--dark-grey-2);
  937. i {
  938. user-select: none;
  939. -webkit-user-select: none;
  940. }
  941. }
  942. .card-content .media {
  943. .icons i,
  944. .under-content .hostedBy {
  945. color: var(--light-grey-2) !important;
  946. }
  947. }
  948. }
  949. .group-title i {
  950. color: var(--light-grey-2);
  951. }
  952. }
  953. .header {
  954. display: flex;
  955. height: 300px;
  956. margin-top: -64px;
  957. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  958. img.background {
  959. height: 300px;
  960. width: 100%;
  961. object-fit: cover;
  962. object-position: center;
  963. filter: blur(1px);
  964. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  965. overflow: hidden;
  966. user-select: none;
  967. }
  968. .overlay {
  969. background: linear-gradient(
  970. 180deg,
  971. rgba(3, 169, 244, 0.8) 0%,
  972. rgba(3, 169, 244, 0.95) 31.25%,
  973. rgba(3, 169, 244, 0.9) 54.17%,
  974. rgba(3, 169, 244, 0.8) 100%
  975. );
  976. position: absolute;
  977. height: 300px;
  978. width: 100%;
  979. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  980. overflow: hidden;
  981. }
  982. .content-container {
  983. position: absolute;
  984. left: 0;
  985. right: 0;
  986. margin-left: auto;
  987. margin-right: auto;
  988. text-align: center;
  989. height: 300px;
  990. .content {
  991. position: absolute;
  992. top: 50%;
  993. left: 0;
  994. right: 0;
  995. transform: translateY(-50%);
  996. background-color: transparent !important;
  997. .logo {
  998. max-height: 90px;
  999. font-size: 50px;
  1000. color: var(--white);
  1001. font-family: Pacifico, cursive;
  1002. user-select: none;
  1003. white-space: nowrap;
  1004. }
  1005. .buttons {
  1006. display: flex;
  1007. justify-content: center;
  1008. margin-top: 20px;
  1009. flex-wrap: wrap;
  1010. .login,
  1011. .register {
  1012. margin: 5px 10px;
  1013. padding: 10px 15px;
  1014. border-radius: @border-radius;
  1015. font-size: 18px;
  1016. width: 100%;
  1017. max-width: 250px;
  1018. font-weight: 600;
  1019. border: 0;
  1020. height: inherit;
  1021. }
  1022. .login {
  1023. background: var(--white);
  1024. color: var(--primary-color);
  1025. }
  1026. .register {
  1027. background: var(--purple);
  1028. color: var(--white);
  1029. }
  1030. }
  1031. }
  1032. }
  1033. &.loggedIn {
  1034. height: 200px;
  1035. .overlay,
  1036. .content-container,
  1037. img.background {
  1038. height: 200px;
  1039. }
  1040. }
  1041. }
  1042. .app {
  1043. display: flex;
  1044. flex-direction: column;
  1045. }
  1046. .station-card {
  1047. display: inline-flex;
  1048. position: relative;
  1049. background-color: var(--white);
  1050. color: var(--dark-grey);
  1051. flex-direction: row;
  1052. overflow: hidden;
  1053. margin: 10px;
  1054. cursor: pointer;
  1055. filter: none;
  1056. height: 150px;
  1057. width: calc(100% - 30px);
  1058. max-width: 400px;
  1059. flex-wrap: wrap;
  1060. border-radius: @border-radius;
  1061. box-shadow: @box-shadow;
  1062. .card-content {
  1063. display: flex;
  1064. flex-direction: row;
  1065. flex-grow: 1;
  1066. .thumbnail {
  1067. display: flex;
  1068. position: relative;
  1069. min-width: 120px;
  1070. width: 120px;
  1071. height: 120px;
  1072. margin: 0;
  1073. .image {
  1074. display: flex;
  1075. position: relative;
  1076. padding-top: 100%;
  1077. }
  1078. .icon-container {
  1079. display: flex;
  1080. position: absolute;
  1081. z-index: 2;
  1082. top: 0;
  1083. bottom: 0;
  1084. left: 0;
  1085. right: 0;
  1086. .material-icons.manage-station {
  1087. display: inline-flex;
  1088. opacity: 0;
  1089. background: var(--primary-color);
  1090. color: var(--white);
  1091. margin: auto;
  1092. font-size: 40px;
  1093. border-radius: 100%;
  1094. padding: 10px;
  1095. transition: all 0.2s ease-in-out;
  1096. }
  1097. &:hover,
  1098. &:focus {
  1099. .material-icons.manage-station {
  1100. opacity: 1;
  1101. &:hover,
  1102. &:focus {
  1103. filter: brightness(90%);
  1104. }
  1105. }
  1106. }
  1107. }
  1108. }
  1109. .media {
  1110. display: flex;
  1111. position: relative;
  1112. padding: 10px 10px 10px 15px;
  1113. flex-direction: column;
  1114. flex-grow: 1;
  1115. -webkit-line-clamp: 2;
  1116. .displayName {
  1117. display: flex;
  1118. align-items: center;
  1119. width: 100%;
  1120. overflow: hidden;
  1121. text-overflow: ellipsis;
  1122. display: flex;
  1123. line-height: 30px;
  1124. max-height: 30px;
  1125. .favorite {
  1126. position: absolute;
  1127. color: var(--yellow);
  1128. right: 10px;
  1129. top: 10px;
  1130. font-size: 28px;
  1131. }
  1132. h5 {
  1133. font-size: 20px;
  1134. font-weight: 400;
  1135. margin: 0;
  1136. display: inline;
  1137. margin-right: 6px;
  1138. line-height: 30px;
  1139. text-overflow: ellipsis;
  1140. overflow: hidden;
  1141. white-space: nowrap;
  1142. max-width: 200px;
  1143. }
  1144. i {
  1145. font-size: 22px;
  1146. }
  1147. .verified-station {
  1148. color: var(--primary-color);
  1149. }
  1150. }
  1151. .content {
  1152. word-wrap: break-word;
  1153. overflow: hidden;
  1154. text-overflow: ellipsis;
  1155. display: -webkit-box;
  1156. -webkit-box-orient: vertical;
  1157. -webkit-line-clamp: 3;
  1158. line-height: 20px;
  1159. flex-grow: 1;
  1160. text-align: left;
  1161. word-wrap: break-word;
  1162. margin-bottom: 0;
  1163. }
  1164. .under-content {
  1165. height: 20px;
  1166. position: relative;
  1167. line-height: 1;
  1168. font-size: 24px;
  1169. display: flex;
  1170. align-items: center;
  1171. text-align: left;
  1172. margin-top: 10px;
  1173. p {
  1174. font-size: 15px;
  1175. line-height: 15px;
  1176. display: inline;
  1177. }
  1178. i {
  1179. font-size: 20px;
  1180. }
  1181. * {
  1182. z-index: 10;
  1183. position: relative;
  1184. }
  1185. .icons {
  1186. position: absolute;
  1187. right: 0;
  1188. .material-icons {
  1189. font-size: 22px;
  1190. }
  1191. .material-icons:first-child {
  1192. margin-left: 5px;
  1193. }
  1194. .unlistedIcon {
  1195. color: var(--orange);
  1196. }
  1197. .privateIcon {
  1198. color: var(--dark-pink);
  1199. }
  1200. .homeIcon {
  1201. color: var(--light-purple);
  1202. }
  1203. .djIcon {
  1204. color: var(--primary-color);
  1205. }
  1206. }
  1207. .hostedBy {
  1208. font-weight: 400;
  1209. font-size: 12px;
  1210. color: var(--black);
  1211. .host,
  1212. .host a {
  1213. font-weight: 400;
  1214. color: var(--primary-color);
  1215. &:hover,
  1216. &:focus {
  1217. filter: brightness(90%);
  1218. }
  1219. }
  1220. }
  1221. }
  1222. }
  1223. }
  1224. .bottomBar {
  1225. position: relative;
  1226. display: flex;
  1227. align-items: center;
  1228. background: var(--primary-color);
  1229. width: 100%;
  1230. height: 30px;
  1231. line-height: 30px;
  1232. color: var(--white);
  1233. font-weight: 400;
  1234. font-size: 12px;
  1235. padding: 0 5px;
  1236. flex-basis: 100%;
  1237. i.material-icons {
  1238. vertical-align: middle;
  1239. margin-left: 5px;
  1240. font-size: 22px;
  1241. }
  1242. .songTitle {
  1243. text-align: left;
  1244. vertical-align: middle;
  1245. margin-left: 5px;
  1246. line-height: 30px;
  1247. flex: 2 1 0;
  1248. overflow: hidden;
  1249. text-overflow: ellipsis;
  1250. white-space: nowrap;
  1251. }
  1252. }
  1253. &.createStation {
  1254. .card-content {
  1255. .thumbnail {
  1256. .image {
  1257. width: 120px;
  1258. .material-icons {
  1259. position: absolute;
  1260. top: 25px;
  1261. bottom: 25px;
  1262. left: 0;
  1263. right: 0;
  1264. text-align: center;
  1265. font-size: 70px;
  1266. color: var(--primary-color);
  1267. }
  1268. }
  1269. }
  1270. .media {
  1271. margin: auto 0;
  1272. .displayName h5 {
  1273. font-weight: 600;
  1274. }
  1275. .content {
  1276. flex-grow: unset;
  1277. margin-bottom: auto;
  1278. }
  1279. }
  1280. }
  1281. }
  1282. &:hover {
  1283. box-shadow: @box-shadow-hover;
  1284. transition: all ease-in-out 0.2s;
  1285. }
  1286. }
  1287. .group {
  1288. flex: 1 0 auto;
  1289. text-align: center;
  1290. width: 100%;
  1291. margin: 10px 0;
  1292. min-height: 64px;
  1293. .group-title {
  1294. display: flex;
  1295. align-items: center;
  1296. justify-content: center;
  1297. margin: 25px 0;
  1298. h1 {
  1299. display: inline-block;
  1300. font-size: 45px;
  1301. margin: 0;
  1302. }
  1303. h2 {
  1304. font-size: 35px;
  1305. margin: 0;
  1306. }
  1307. a {
  1308. display: flex;
  1309. margin-left: 8px;
  1310. }
  1311. }
  1312. &.bottom {
  1313. margin-bottom: 40px;
  1314. }
  1315. }
  1316. </style>