PlaylistTabBase.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. <script setup lang="ts">
  2. import { defineAsyncComponent, ref, reactive, computed, onMounted } from "vue";
  3. import Toast from "toasters";
  4. import { storeToRefs } from "pinia";
  5. import { useWebsocketsStore } from "@/stores/websockets";
  6. import { useStationStore } from "@/stores/station";
  7. import { useUserPlaylistsStore } from "@/stores/userPlaylists";
  8. import { useModalsStore } from "@/stores/modals";
  9. import { useManageStationStore } from "@/stores/manageStation";
  10. import { useSortablePlaylists } from "@/composables/useSortablePlaylists";
  11. const PlaylistItem = defineAsyncComponent(
  12. () => import("@/components/PlaylistItem.vue")
  13. );
  14. const QuickConfirm = defineAsyncComponent(
  15. () => import("@/components/QuickConfirm.vue")
  16. );
  17. const props = defineProps({
  18. modalUuid: { type: String, default: null },
  19. type: {
  20. type: String,
  21. default: ""
  22. },
  23. sector: {
  24. type: String,
  25. default: "manageStation"
  26. }
  27. });
  28. const emit = defineEmits(["selected"]);
  29. const { socket } = useWebsocketsStore();
  30. const stationStore = useStationStore();
  31. const tab = ref("current");
  32. const search = reactive({
  33. query: "",
  34. searchedQuery: "",
  35. page: 0,
  36. count: 0,
  37. resultsLeft: 0,
  38. pageSize: 0,
  39. results: []
  40. });
  41. const featuredPlaylists = ref([]);
  42. const tabs = ref({});
  43. const {
  44. DraggableList,
  45. drag,
  46. playlists,
  47. savePlaylistOrder,
  48. orderOfPlaylists,
  49. myUserId,
  50. calculatePlaylistOrder
  51. } = useSortablePlaylists();
  52. const { autoRequest, history, songsList } = storeToRefs(stationStore);
  53. const manageStationStore = useManageStationStore({
  54. modalUuid: props.modalUuid
  55. });
  56. const { autofill } = storeToRefs(manageStationStore);
  57. const station = computed({
  58. get() {
  59. if (props.sector === "manageStation") return manageStationStore.station;
  60. return stationStore.station;
  61. },
  62. set(value) {
  63. if (props.sector === "manageStation")
  64. manageStationStore.updateStation(value);
  65. else stationStore.updateStation(value);
  66. }
  67. });
  68. const blacklist = computed({
  69. get() {
  70. if (props.sector === "manageStation")
  71. return manageStationStore.blacklist;
  72. return stationStore.blacklist;
  73. },
  74. set(value) {
  75. if (props.sector === "manageStation")
  76. manageStationStore.setBlacklist(value);
  77. else stationStore.setBlacklist(value);
  78. }
  79. });
  80. const resultsLeftCount = computed(() => search.count - search.results.length);
  81. const nextPageResultsCount = computed(() =>
  82. Math.min(search.pageSize, resultsLeftCount.value)
  83. );
  84. const excludedYoutubeIds = computed(() => {
  85. if (!history.value) return [];
  86. const {
  87. autorequestDisallowRecentlyPlayedEnabled,
  88. autorequestDisallowRecentlyPlayedNumber
  89. } = station.value.requests;
  90. const mediaSources = new Set();
  91. if (autorequestDisallowRecentlyPlayedEnabled) {
  92. history.value.forEach((historyItem, index) => {
  93. if (index < autorequestDisallowRecentlyPlayedNumber)
  94. mediaSources.add(historyItem.payload.song.mediaSource);
  95. });
  96. }
  97. if (songsList.value) {
  98. songsList.value.forEach(song => {
  99. mediaSources.add(song.mediaSource);
  100. });
  101. }
  102. if (station.value.currentSong) {
  103. mediaSources.add(station.value.currentSong.mediaSource);
  104. }
  105. return Array.from(mediaSources);
  106. });
  107. const totalUniqueAutorequestableYoutubeIds = computed(() => {
  108. if (!autoRequest.value) return [];
  109. const uniqueYoutubeIds = new Set();
  110. autoRequest.value.forEach(playlist => {
  111. playlist.songs.forEach(song => {
  112. uniqueYoutubeIds.add(song.mediaSource);
  113. });
  114. });
  115. return Array.from(uniqueYoutubeIds);
  116. });
  117. const actuallyAutorequestingYoutubeIds = computed(() => {
  118. const excluded = excludedYoutubeIds.value;
  119. const remaining = totalUniqueAutorequestableYoutubeIds.value.filter(
  120. mediaSource =>
  121. excluded.indexOf(mediaSource) === -1 &&
  122. !mediaSource.startsWith("spotify:")
  123. );
  124. return remaining;
  125. });
  126. const hasPermission = permission =>
  127. props.sector === "manageStation"
  128. ? manageStationStore.hasPermission(permission)
  129. : stationStore.hasPermission(permission);
  130. const { openModal } = useModalsStore();
  131. const { setPlaylists } = useUserPlaylistsStore();
  132. const {
  133. addAutorequestPlaylists,
  134. addPlaylistToAutoRequest,
  135. removePlaylistFromAutoRequest,
  136. updateAutorequestLocalStorage
  137. } = stationStore;
  138. const showTab = _tab => {
  139. if (tabs.value[`${_tab}-tab`])
  140. tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
  141. tab.value = _tab;
  142. };
  143. const label = (tense = "future", typeOverwrite = null, capitalize = false) => {
  144. let label = typeOverwrite || props.type;
  145. if (tense === "past") label = `${label}ed`;
  146. if (tense === "present") label = `${label}ing`;
  147. if (capitalize) label = `${label.charAt(0).toUpperCase()}${label.slice(1)}`;
  148. return label;
  149. };
  150. const selectedPlaylists = (typeOverwrite?: string) => {
  151. const type = typeOverwrite || props.type;
  152. if (type === "autofill") return autofill.value;
  153. if (type === "blacklist") return blacklist.value;
  154. if (type === "autorequest") return autoRequest.value;
  155. return [];
  156. };
  157. const isSelected = (playlistId, typeOverwrite?: string) => {
  158. const type = typeOverwrite || props.type;
  159. let selected = false;
  160. selectedPlaylists(type).forEach(playlist => {
  161. if (playlist._id === playlistId) selected = true;
  162. });
  163. return selected;
  164. };
  165. const deselectPlaylist = (playlistId, typeOverwrite?: string) => {
  166. const type = typeOverwrite || props.type;
  167. if (type === "autofill")
  168. return new Promise(resolve => {
  169. socket.dispatch(
  170. "stations.removeAutofillPlaylist",
  171. station.value._id,
  172. playlistId,
  173. res => {
  174. new Toast(res.message);
  175. resolve(true);
  176. }
  177. );
  178. });
  179. if (type === "blacklist")
  180. return new Promise(resolve => {
  181. socket.dispatch(
  182. "stations.removeBlacklistedPlaylist",
  183. station.value._id,
  184. playlistId,
  185. res => {
  186. new Toast(res.message);
  187. resolve(true);
  188. }
  189. );
  190. });
  191. if (type === "autorequest")
  192. return new Promise(resolve => {
  193. removePlaylistFromAutoRequest(playlistId);
  194. new Toast("Successfully deselected playlist.");
  195. resolve(true);
  196. });
  197. return false;
  198. };
  199. const selectPlaylist = async (playlist, typeOverwrite?: string) => {
  200. const type = typeOverwrite || props.type;
  201. if (isSelected(playlist._id, type))
  202. return new Toast(`Error: Playlist already ${label("past", type)}.`);
  203. if (type === "autofill")
  204. return new Promise(resolve => {
  205. socket.dispatch(
  206. "stations.autofillPlaylist",
  207. station.value._id,
  208. playlist._id,
  209. res => {
  210. new Toast(res.message);
  211. emit("selected");
  212. resolve(true);
  213. }
  214. );
  215. });
  216. if (type === "blacklist") {
  217. if (props.type !== "blacklist" && isSelected(playlist._id))
  218. await deselectPlaylist(playlist._id);
  219. return new Promise(resolve => {
  220. socket.dispatch(
  221. "stations.blacklistPlaylist",
  222. station.value._id,
  223. playlist._id,
  224. res => {
  225. new Toast(res.message);
  226. emit("selected");
  227. resolve(true);
  228. }
  229. );
  230. });
  231. }
  232. if (type === "autorequest")
  233. return new Promise(resolve => {
  234. addPlaylistToAutoRequest(playlist);
  235. new Toast("Successfully selected playlist to auto request songs.");
  236. emit("selected");
  237. resolve(true);
  238. });
  239. return false;
  240. };
  241. const searchForPlaylists = page => {
  242. if (search.page >= page || search.searchedQuery !== search.query) {
  243. search.results = [];
  244. search.page = 0;
  245. search.count = 0;
  246. search.resultsLeft = 0;
  247. search.pageSize = 0;
  248. }
  249. const { query } = search;
  250. const action =
  251. station.value.type === "official" && props.type !== "autorequest"
  252. ? "playlists.searchOfficial"
  253. : "playlists.searchCommunity";
  254. search.searchedQuery = search.query;
  255. socket.dispatch(action, query, page, res => {
  256. const { data } = res;
  257. if (res.status === "success") {
  258. const { count, pageSize, playlists } = data;
  259. search.results = [...search.results, ...playlists];
  260. search.page = page;
  261. search.count = count;
  262. search.resultsLeft = count - search.results.length;
  263. search.pageSize = pageSize;
  264. } else if (res.status === "error") {
  265. search.results = [];
  266. search.page = 0;
  267. search.count = 0;
  268. search.resultsLeft = 0;
  269. search.pageSize = 0;
  270. new Toast(res.message);
  271. }
  272. });
  273. };
  274. onMounted(() => {
  275. showTab("my-playlists");
  276. socket.onConnect(() => {
  277. socket.dispatch("playlists.indexMyPlaylists", res => {
  278. if (res.status === "success") setPlaylists(res.data.playlists);
  279. orderOfPlaylists.value = calculatePlaylistOrder(); // order in regards to the database
  280. });
  281. socket.dispatch("playlists.indexFeaturedPlaylists", res => {
  282. if (res.status === "success")
  283. featuredPlaylists.value = res.data.playlists;
  284. });
  285. if (props.type === "autofill")
  286. socket.dispatch(
  287. `stations.getStationAutofillPlaylistsById`,
  288. station.value._id,
  289. res => {
  290. if (res.status === "success") {
  291. station.value.autofill.playlists = res.data.playlists;
  292. }
  293. }
  294. );
  295. socket.dispatch(
  296. `stations.getStationBlacklistById`,
  297. station.value._id,
  298. res => {
  299. if (res.status === "success") {
  300. station.value.blacklist = res.data.playlists;
  301. }
  302. }
  303. );
  304. const autorequestLocalStorageItem = localStorage.getItem(
  305. `autorequest-${station.value._id}`
  306. );
  307. if (
  308. autorequestLocalStorageItem &&
  309. station.value.requests &&
  310. station.value.requests.allowAutorequest &&
  311. autoRequest.value.length === 0
  312. ) {
  313. const autorequestParsedItem = JSON.parse(
  314. autorequestLocalStorageItem
  315. );
  316. const autorequestUpdatedAt = new Date(
  317. autorequestParsedItem.updatedAt
  318. );
  319. const fiveMinutesAgo = new Date(
  320. new Date().getTime() - 5 * 60 * 1000
  321. );
  322. if (autorequestUpdatedAt > fiveMinutesAgo) {
  323. const playlists = [];
  324. const promises = autorequestParsedItem.playlistIds.map(
  325. playlistId =>
  326. new Promise<void>(resolve => {
  327. socket.dispatch(
  328. "playlists.getPlaylist",
  329. playlistId,
  330. res => {
  331. if (res.status === "success") {
  332. playlists.push(res.data.playlist);
  333. }
  334. resolve();
  335. }
  336. );
  337. })
  338. );
  339. Promise.all(promises).then(() => {
  340. addAutorequestPlaylists(playlists);
  341. });
  342. } else updateAutorequestLocalStorage();
  343. }
  344. });
  345. });
  346. </script>
  347. <template>
  348. <div class="playlist-tab-base">
  349. <div v-if="$slots.info" class="top-info has-text-centered">
  350. <slot name="info" />
  351. </div>
  352. <div class="tabs-container">
  353. <div class="tab-selection">
  354. <button
  355. v-if="
  356. type === 'autorequest' || station.type === 'community'
  357. "
  358. class="button is-default"
  359. :ref="el => (tabs['my-playlists-tab'] = el)"
  360. :class="{ selected: tab === 'my-playlists' }"
  361. @click="showTab('my-playlists')"
  362. >
  363. My Playlists
  364. </button>
  365. <button
  366. class="button is-default"
  367. :ref="el => (tabs['search-tab'] = el)"
  368. :class="{ selected: tab === 'search' }"
  369. @click="showTab('search')"
  370. >
  371. Search
  372. </button>
  373. <button
  374. class="button is-default"
  375. :ref="el => (tabs['current-tab'] = el)"
  376. :class="{ selected: tab === 'current' }"
  377. @click="showTab('current')"
  378. >
  379. Current
  380. <span class="tag" v-if="selectedPlaylists().length > 0">{{
  381. selectedPlaylists().length
  382. }}</span>
  383. </button>
  384. </div>
  385. <div class="tab" v-show="tab === 'search'">
  386. <div v-if="featuredPlaylists.length > 0">
  387. <label class="label"> Featured playlists </label>
  388. <playlist-item
  389. v-for="featuredPlaylist in featuredPlaylists"
  390. :key="`featuredKey-${featuredPlaylist._id}`"
  391. :playlist="featuredPlaylist"
  392. :show-owner="true"
  393. >
  394. <template #item-icon>
  395. <i
  396. class="material-icons blacklisted-icon"
  397. v-if="
  398. isSelected(
  399. featuredPlaylist._id,
  400. 'blacklist'
  401. )
  402. "
  403. :content="`This playlist is currently ${label(
  404. 'past',
  405. 'blacklist'
  406. )}`"
  407. v-tippy
  408. >
  409. block
  410. </i>
  411. <i
  412. class="material-icons"
  413. v-else-if="isSelected(featuredPlaylist._id)"
  414. :content="`This playlist is currently ${label(
  415. 'past'
  416. )}`"
  417. v-tippy
  418. >
  419. play_arrow
  420. </i>
  421. <i
  422. class="material-icons"
  423. v-else
  424. :content="`This playlist is currently not ${label(
  425. 'past'
  426. )}`"
  427. v-tippy
  428. >
  429. {{
  430. type === "blacklist"
  431. ? "block"
  432. : "play_disabled"
  433. }}
  434. </i>
  435. </template>
  436. <template #actions>
  437. <i
  438. v-if="
  439. type !== 'blacklist' &&
  440. isSelected(
  441. featuredPlaylist._id,
  442. 'blacklist'
  443. )
  444. "
  445. class="material-icons stop-icon"
  446. :content="`This playlist is ${label(
  447. 'past',
  448. 'blacklist'
  449. )} in this station`"
  450. v-tippy="{ theme: 'info' }"
  451. >play_disabled</i
  452. >
  453. <quick-confirm
  454. v-if="
  455. type !== 'blacklist' &&
  456. isSelected(featuredPlaylist._id)
  457. "
  458. @confirm="
  459. deselectPlaylist(featuredPlaylist._id)
  460. "
  461. >
  462. <i
  463. class="material-icons stop-icon"
  464. :content="`Stop ${label(
  465. 'present'
  466. )} songs from this playlist`"
  467. v-tippy
  468. >
  469. stop
  470. </i>
  471. </quick-confirm>
  472. <i
  473. v-if="
  474. type !== 'blacklist' &&
  475. !isSelected(featuredPlaylist._id) &&
  476. !isSelected(
  477. featuredPlaylist._id,
  478. 'blacklist'
  479. )
  480. "
  481. @click="selectPlaylist(featuredPlaylist)"
  482. class="material-icons play-icon"
  483. :content="`${label(
  484. 'future',
  485. null,
  486. true
  487. )} songs from this playlist`"
  488. v-tippy
  489. >play_arrow</i
  490. >
  491. <quick-confirm
  492. v-if="
  493. type === 'blacklist' &&
  494. !isSelected(
  495. featuredPlaylist._id,
  496. 'blacklist'
  497. )
  498. "
  499. @confirm="
  500. selectPlaylist(
  501. featuredPlaylist,
  502. 'blacklist'
  503. )
  504. "
  505. >
  506. <i
  507. class="material-icons stop-icon"
  508. :content="`${label(
  509. 'future',
  510. null,
  511. true
  512. )} Playlist`"
  513. v-tippy
  514. >block</i
  515. >
  516. </quick-confirm>
  517. <quick-confirm
  518. v-if="
  519. type === 'blacklist' &&
  520. isSelected(
  521. featuredPlaylist._id,
  522. 'blacklist'
  523. )
  524. "
  525. @confirm="
  526. deselectPlaylist(featuredPlaylist._id)
  527. "
  528. >
  529. <i
  530. class="material-icons stop-icon"
  531. :content="`Stop ${label(
  532. 'present'
  533. )} songs from this playlist`"
  534. v-tippy
  535. >
  536. stop
  537. </i>
  538. </quick-confirm>
  539. <i
  540. v-if="featuredPlaylist.createdBy === myUserId"
  541. @click="
  542. openModal({
  543. modal: 'editPlaylist',
  544. props: {
  545. playlistId: featuredPlaylist._id
  546. }
  547. })
  548. "
  549. class="material-icons edit-icon"
  550. content="Edit Playlist"
  551. v-tippy
  552. >edit</i
  553. >
  554. <i
  555. v-if="
  556. featuredPlaylist.createdBy !== myUserId &&
  557. (featuredPlaylist.privacy === 'public' ||
  558. hasPermission('playlists.view.others'))
  559. "
  560. @click="
  561. openModal({
  562. modal: 'editPlaylist',
  563. props: {
  564. playlistId: featuredPlaylist._id
  565. }
  566. })
  567. "
  568. class="material-icons edit-icon"
  569. content="View Playlist"
  570. v-tippy
  571. >visibility</i
  572. >
  573. </template>
  574. </playlist-item>
  575. <br />
  576. </div>
  577. <label class="label">Search for a playlist</label>
  578. <div class="control is-grouped input-with-button">
  579. <p class="control is-expanded">
  580. <input
  581. class="input"
  582. type="text"
  583. placeholder="Enter your playlist query here..."
  584. v-model="search.query"
  585. @keyup.enter="searchForPlaylists(1)"
  586. />
  587. </p>
  588. <p class="control">
  589. <a class="button is-info" @click="searchForPlaylists(1)"
  590. ><i class="material-icons icon-with-button"
  591. >search</i
  592. >Search</a
  593. >
  594. </p>
  595. </div>
  596. <div v-if="search.results.length > 0">
  597. <playlist-item
  598. v-for="playlist in search.results"
  599. :key="`searchKey-${playlist._id}`"
  600. :playlist="playlist"
  601. :show-owner="true"
  602. >
  603. <template #item-icon>
  604. <i
  605. class="material-icons blacklisted-icon"
  606. v-if="isSelected(playlist._id, 'blacklist')"
  607. :content="`This playlist is currently ${label(
  608. 'past',
  609. 'blacklist'
  610. )}`"
  611. v-tippy
  612. >
  613. block
  614. </i>
  615. <i
  616. class="material-icons"
  617. v-else-if="isSelected(playlist._id)"
  618. :content="`This playlist is currently ${label(
  619. 'past'
  620. )}`"
  621. v-tippy
  622. >
  623. play_arrow
  624. </i>
  625. <i
  626. class="material-icons"
  627. v-else
  628. :content="`This playlist is currently not ${label(
  629. 'past'
  630. )}`"
  631. v-tippy
  632. >
  633. {{
  634. type === "blacklist"
  635. ? "block"
  636. : "play_disabled"
  637. }}
  638. </i>
  639. </template>
  640. <template #actions>
  641. <i
  642. v-if="
  643. type !== 'blacklist' &&
  644. isSelected(playlist._id, 'blacklist')
  645. "
  646. class="material-icons stop-icon"
  647. :content="`This playlist is ${label(
  648. 'past',
  649. 'blacklist'
  650. )} in this station`"
  651. v-tippy="{ theme: 'info' }"
  652. >play_disabled</i
  653. >
  654. <quick-confirm
  655. v-if="
  656. type !== 'blacklist' &&
  657. isSelected(playlist._id)
  658. "
  659. @confirm="deselectPlaylist(playlist._id)"
  660. >
  661. <i
  662. class="material-icons stop-icon"
  663. :content="`Stop ${label(
  664. 'present'
  665. )} songs from this playlist`"
  666. v-tippy
  667. >
  668. stop
  669. </i>
  670. </quick-confirm>
  671. <i
  672. v-if="
  673. type !== 'blacklist' &&
  674. !isSelected(playlist._id) &&
  675. !isSelected(playlist._id, 'blacklist')
  676. "
  677. @click="selectPlaylist(playlist)"
  678. class="material-icons play-icon"
  679. :content="`${label(
  680. 'future',
  681. null,
  682. true
  683. )} songs from this playlist`"
  684. v-tippy
  685. >play_arrow</i
  686. >
  687. <quick-confirm
  688. v-if="
  689. type === 'blacklist' &&
  690. !isSelected(playlist._id, 'blacklist')
  691. "
  692. @confirm="selectPlaylist(playlist, 'blacklist')"
  693. >
  694. <i
  695. class="material-icons stop-icon"
  696. :content="`${label(
  697. 'future',
  698. null,
  699. true
  700. )} Playlist`"
  701. v-tippy
  702. >block</i
  703. >
  704. </quick-confirm>
  705. <quick-confirm
  706. v-if="
  707. type === 'blacklist' &&
  708. isSelected(playlist._id, 'blacklist')
  709. "
  710. @confirm="deselectPlaylist(playlist._id)"
  711. >
  712. <i
  713. class="material-icons stop-icon"
  714. :content="`Stop ${label(
  715. 'present'
  716. )} songs from this playlist`"
  717. v-tippy
  718. >
  719. stop
  720. </i>
  721. </quick-confirm>
  722. <i
  723. v-if="playlist.createdBy === myUserId"
  724. @click="
  725. openModal({
  726. modal: 'editPlaylist',
  727. props: { playlistId: playlist._id }
  728. })
  729. "
  730. class="material-icons edit-icon"
  731. content="Edit Playlist"
  732. v-tippy
  733. >edit</i
  734. >
  735. <i
  736. v-if="
  737. playlist.createdBy !== myUserId &&
  738. (playlist.privacy === 'public' ||
  739. hasPermission('playlists.view.others'))
  740. "
  741. @click="
  742. openModal({
  743. modal: 'editPlaylist',
  744. props: { playlistId: playlist._id }
  745. })
  746. "
  747. class="material-icons edit-icon"
  748. content="View Playlist"
  749. v-tippy
  750. >visibility</i
  751. >
  752. </template>
  753. </playlist-item>
  754. <button
  755. v-if="resultsLeftCount > 0"
  756. class="button is-primary load-more-button"
  757. @click="searchForPlaylists(search.page + 1)"
  758. >
  759. Load {{ nextPageResultsCount }} more results
  760. </button>
  761. </div>
  762. </div>
  763. <div class="tab" v-show="tab === 'current'">
  764. <p
  765. class="has-text-centered scrollable-list"
  766. v-if="
  767. selectedPlaylists().length > 0 && type === 'autorequest'
  768. "
  769. >
  770. You are currently autorequesting a mix of
  771. {{ totalUniqueAutorequestableYoutubeIds.length }} different
  772. songs. Of these, we can currently autorequest
  773. {{ actuallyAutorequestingYoutubeIds.length }} songs.
  774. <br />
  775. Songs that
  776. <span
  777. v-if="
  778. station.requests
  779. .autorequestDisallowRecentlyPlayedEnabled
  780. "
  781. >were played recently or</span
  782. >
  783. are currently in the queue or playing will not be
  784. autorequested. Spotify songs will also not be autorequested.
  785. <br />
  786. <br />
  787. </p>
  788. <div v-if="selectedPlaylists().length > 0">
  789. <playlist-item
  790. v-for="playlist in selectedPlaylists()"
  791. :key="`key-${playlist._id}`"
  792. :playlist="playlist"
  793. :show-owner="true"
  794. >
  795. <template #item-icon>
  796. <i
  797. class="material-icons"
  798. :class="{
  799. 'blacklisted-icon': type === 'blacklist'
  800. }"
  801. :content="`This playlist is currently ${label(
  802. 'past'
  803. )}`"
  804. v-tippy
  805. >
  806. {{
  807. type === "blacklist"
  808. ? "block"
  809. : "play_arrow"
  810. }}
  811. </i>
  812. </template>
  813. <template #actions>
  814. <quick-confirm
  815. @confirm="deselectPlaylist(playlist._id)"
  816. >
  817. <i
  818. class="material-icons stop-icon"
  819. :content="`Stop ${label(
  820. 'present'
  821. )} songs from this playlist`"
  822. v-tippy
  823. >
  824. stop
  825. </i>
  826. </quick-confirm>
  827. <i
  828. v-if="playlist.createdBy === myUserId"
  829. @click="
  830. openModal({
  831. modal: 'editPlaylist',
  832. props: { playlistId: playlist._id }
  833. })
  834. "
  835. class="material-icons edit-icon"
  836. content="Edit Playlist"
  837. v-tippy
  838. >edit</i
  839. >
  840. <i
  841. v-if="
  842. playlist.createdBy !== myUserId &&
  843. (playlist.privacy === 'public' ||
  844. hasPermission('playlists.view.others'))
  845. "
  846. @click="
  847. openModal({
  848. modal: 'editPlaylist',
  849. props: { playlistId: playlist._id }
  850. })
  851. "
  852. class="material-icons edit-icon"
  853. content="View Playlist"
  854. v-tippy
  855. >visibility</i
  856. >
  857. </template>
  858. </playlist-item>
  859. </div>
  860. <p v-else class="has-text-centered scrollable-list">
  861. No playlists currently {{ label("present") }}.
  862. </p>
  863. </div>
  864. <div
  865. v-if="type === 'autorequest' || station.type === 'community'"
  866. class="tab"
  867. v-show="tab === 'my-playlists'"
  868. >
  869. <div
  870. class="menu-list scrollable-list"
  871. v-if="playlists.length > 0"
  872. >
  873. <draggable-list
  874. v-model:list="playlists"
  875. item-key="_id"
  876. @start="drag = true"
  877. @end="drag = false"
  878. @update="savePlaylistOrder"
  879. >
  880. <template #item="{ element }">
  881. <playlist-item :playlist="element">
  882. <template #item-icon>
  883. <i
  884. class="material-icons blacklisted-icon"
  885. v-if="
  886. isSelected(element._id, 'blacklist')
  887. "
  888. :content="`This playlist is currently ${label(
  889. 'past',
  890. 'blacklist'
  891. )}`"
  892. v-tippy
  893. >
  894. block
  895. </i>
  896. <i
  897. class="material-icons"
  898. v-else-if="isSelected(element._id)"
  899. :content="`This playlist is currently ${label(
  900. 'past'
  901. )}`"
  902. v-tippy
  903. >
  904. play_arrow
  905. </i>
  906. <i
  907. class="material-icons"
  908. v-else
  909. :content="`This playlist is currently not ${label(
  910. 'past'
  911. )}`"
  912. v-tippy
  913. >
  914. {{
  915. type === "blacklist"
  916. ? "block"
  917. : "play_disabled"
  918. }}
  919. </i>
  920. </template>
  921. <template #actions>
  922. <i
  923. v-if="
  924. type !== 'blacklist' &&
  925. isSelected(element._id, 'blacklist')
  926. "
  927. class="material-icons stop-icon"
  928. :content="`This playlist is ${label(
  929. 'past',
  930. 'blacklist'
  931. )} in this station`"
  932. v-tippy="{ theme: 'info' }"
  933. >play_disabled</i
  934. >
  935. <quick-confirm
  936. v-if="
  937. type !== 'blacklist' &&
  938. isSelected(element._id)
  939. "
  940. @confirm="deselectPlaylist(element._id)"
  941. >
  942. <i
  943. class="material-icons stop-icon"
  944. :content="`Stop ${label(
  945. 'present'
  946. )} songs from this playlist`"
  947. v-tippy
  948. >
  949. stop
  950. </i>
  951. </quick-confirm>
  952. <i
  953. v-if="
  954. type !== 'blacklist' &&
  955. !isSelected(element._id) &&
  956. !isSelected(
  957. element._id,
  958. 'blacklist'
  959. )
  960. "
  961. @click="selectPlaylist(element)"
  962. class="material-icons play-icon"
  963. :content="`${label(
  964. 'future',
  965. null,
  966. true
  967. )} songs from this playlist`"
  968. v-tippy
  969. >play_arrow</i
  970. >
  971. <quick-confirm
  972. v-if="
  973. type === 'blacklist' &&
  974. !isSelected(
  975. element._id,
  976. 'blacklist'
  977. )
  978. "
  979. @confirm="
  980. selectPlaylist(element, 'blacklist')
  981. "
  982. >
  983. <i
  984. class="material-icons stop-icon"
  985. :content="`${label(
  986. 'future',
  987. null,
  988. true
  989. )} Playlist`"
  990. v-tippy
  991. >block</i
  992. >
  993. </quick-confirm>
  994. <quick-confirm
  995. v-if="
  996. type === 'blacklist' &&
  997. isSelected(element._id, 'blacklist')
  998. "
  999. @confirm="deselectPlaylist(element._id)"
  1000. >
  1001. <i
  1002. class="material-icons stop-icon"
  1003. :content="`Stop ${label(
  1004. 'present'
  1005. )} songs from this playlist`"
  1006. v-tippy
  1007. >
  1008. stop
  1009. </i>
  1010. </quick-confirm>
  1011. <i
  1012. @click="
  1013. openModal({
  1014. modal: 'editPlaylist',
  1015. props: {
  1016. playlistId: element._id
  1017. }
  1018. })
  1019. "
  1020. class="material-icons edit-icon"
  1021. content="Edit Playlist"
  1022. v-tippy
  1023. >edit</i
  1024. >
  1025. </template>
  1026. </playlist-item>
  1027. </template>
  1028. </draggable-list>
  1029. </div>
  1030. <p v-else class="has-text-centered scrollable-list">
  1031. You don't have any playlists
  1032. </p>
  1033. <button
  1034. class="button is-primary"
  1035. id="create-new-playlist-button"
  1036. @click="openModal('createPlaylist')"
  1037. >
  1038. Create new playlist
  1039. </button>
  1040. </div>
  1041. </div>
  1042. </div>
  1043. </template>
  1044. <style lang="less" scoped>
  1045. .night-mode {
  1046. .tabs-container .tab-selection .button {
  1047. background: var(--dark-grey) !important;
  1048. color: var(--white) !important;
  1049. }
  1050. }
  1051. .blacklisted-icon {
  1052. color: var(--dark-red);
  1053. }
  1054. .playlist-tab-base {
  1055. .top-info {
  1056. font-size: 15px;
  1057. margin-bottom: 15px;
  1058. }
  1059. .tabs-container {
  1060. .tab-selection {
  1061. display: flex;
  1062. overflow-x: auto;
  1063. .button {
  1064. border-radius: 0;
  1065. border: 0;
  1066. text-transform: uppercase;
  1067. font-size: 14px;
  1068. color: var(--dark-grey-3);
  1069. background-color: var(--light-grey-2);
  1070. flex-grow: 1;
  1071. height: 32px;
  1072. &:not(:first-of-type) {
  1073. margin-left: 5px;
  1074. }
  1075. }
  1076. .selected {
  1077. background-color: var(--primary-color) !important;
  1078. color: var(--white) !important;
  1079. font-weight: 600;
  1080. }
  1081. }
  1082. .tab {
  1083. padding: 15px 0;
  1084. border-radius: 0;
  1085. .playlist-item:not(:last-of-type) {
  1086. margin-bottom: 10px;
  1087. }
  1088. .load-more-button {
  1089. width: 100%;
  1090. margin-top: 10px;
  1091. }
  1092. }
  1093. }
  1094. }
  1095. .draggable-list-transition-move {
  1096. transition: transform 0.5s;
  1097. }
  1098. .draggable-list-ghost {
  1099. opacity: 0.5;
  1100. filter: brightness(95%);
  1101. }
  1102. </style>