123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173 |
- <script setup lang="ts">
- import { defineAsyncComponent, ref, reactive, computed, onMounted } from "vue";
- import Toast from "toasters";
- import { storeToRefs } from "pinia";
- import { useWebsocketsStore } from "@/stores/websockets";
- import { useStationStore } from "@/stores/station";
- import { useUserPlaylistsStore } from "@/stores/userPlaylists";
- import { useModalsStore } from "@/stores/modals";
- import { useManageStationStore } from "@/stores/manageStation";
- import { useSortablePlaylists } from "@/composables/useSortablePlaylists";
- const PlaylistItem = defineAsyncComponent(
- () => import("@/components/PlaylistItem.vue")
- );
- const QuickConfirm = defineAsyncComponent(
- () => import("@/components/QuickConfirm.vue")
- );
- const props = defineProps({
- modalUuid: { type: String, default: null },
- type: {
- type: String,
- default: ""
- },
- sector: {
- type: String,
- default: "manageStation"
- }
- });
- const emit = defineEmits(["selected"]);
- const { socket } = useWebsocketsStore();
- const stationStore = useStationStore();
- const tab = ref("current");
- const search = reactive({
- query: "",
- searchedQuery: "",
- page: 0,
- count: 0,
- resultsLeft: 0,
- pageSize: 0,
- results: []
- });
- const featuredPlaylists = ref([]);
- const tabs = ref({});
- const {
- DraggableList,
- drag,
- playlists,
- savePlaylistOrder,
- orderOfPlaylists,
- myUserId,
- calculatePlaylistOrder
- } = useSortablePlaylists();
- const { autoRequest, history, songsList } = storeToRefs(stationStore);
- const manageStationStore = useManageStationStore({
- modalUuid: props.modalUuid
- });
- const { autofill } = storeToRefs(manageStationStore);
- const station = computed({
- get() {
- if (props.sector === "manageStation") return manageStationStore.station;
- return stationStore.station;
- },
- set(value) {
- if (props.sector === "manageStation")
- manageStationStore.updateStation(value);
- else stationStore.updateStation(value);
- }
- });
- const blacklist = computed({
- get() {
- if (props.sector === "manageStation")
- return manageStationStore.blacklist;
- return stationStore.blacklist;
- },
- set(value) {
- if (props.sector === "manageStation")
- manageStationStore.setBlacklist(value);
- else stationStore.setBlacklist(value);
- }
- });
- const resultsLeftCount = computed(() => search.count - search.results.length);
- const nextPageResultsCount = computed(() =>
- Math.min(search.pageSize, resultsLeftCount.value)
- );
- const excludedYoutubeIds = computed(() => {
- if (!history.value) return [];
- const {
- autorequestDisallowRecentlyPlayedEnabled,
- autorequestDisallowRecentlyPlayedNumber
- } = station.value.requests;
- const mediaSources = new Set();
- if (autorequestDisallowRecentlyPlayedEnabled) {
- history.value.forEach((historyItem, index) => {
- if (index < autorequestDisallowRecentlyPlayedNumber)
- mediaSources.add(historyItem.payload.song.mediaSource);
- });
- }
- if (songsList.value) {
- songsList.value.forEach(song => {
- mediaSources.add(song.mediaSource);
- });
- }
- if (station.value.currentSong) {
- mediaSources.add(station.value.currentSong.mediaSource);
- }
- return Array.from(mediaSources);
- });
- const totalUniqueAutorequestableYoutubeIds = computed(() => {
- if (!autoRequest.value) return [];
- const uniqueYoutubeIds = new Set();
- autoRequest.value.forEach(playlist => {
- playlist.songs.forEach(song => {
- uniqueYoutubeIds.add(song.mediaSource);
- });
- });
- return Array.from(uniqueYoutubeIds);
- });
- const actuallyAutorequestingYoutubeIds = computed(() => {
- const excluded = excludedYoutubeIds.value;
- const remaining = totalUniqueAutorequestableYoutubeIds.value.filter(
- mediaSource => excluded.indexOf(mediaSource) === -1
- );
- return remaining;
- });
- const hasPermission = permission =>
- props.sector === "manageStation"
- ? manageStationStore.hasPermission(permission)
- : stationStore.hasPermission(permission);
- const { openModal } = useModalsStore();
- const { setPlaylists } = useUserPlaylistsStore();
- const {
- addAutorequestPlaylists,
- addPlaylistToAutoRequest,
- removePlaylistFromAutoRequest,
- updateAutorequestLocalStorage
- } = stationStore;
- const showTab = _tab => {
- if (tabs.value[`${_tab}-tab`])
- tabs.value[`${_tab}-tab`].scrollIntoView({ block: "nearest" });
- tab.value = _tab;
- };
- const label = (tense = "future", typeOverwrite = null, capitalize = false) => {
- let label = typeOverwrite || props.type;
- if (tense === "past") label = `${label}ed`;
- if (tense === "present") label = `${label}ing`;
- if (capitalize) label = `${label.charAt(0).toUpperCase()}${label.slice(1)}`;
- return label;
- };
- const selectedPlaylists = (typeOverwrite?: string) => {
- const type = typeOverwrite || props.type;
- if (type === "autofill") return autofill.value;
- if (type === "blacklist") return blacklist.value;
- if (type === "autorequest") return autoRequest.value;
- return [];
- };
- const isSelected = (playlistId, typeOverwrite?: string) => {
- const type = typeOverwrite || props.type;
- let selected = false;
- selectedPlaylists(type).forEach(playlist => {
- if (playlist._id === playlistId) selected = true;
- });
- return selected;
- };
- const deselectPlaylist = (playlistId, typeOverwrite?: string) => {
- const type = typeOverwrite || props.type;
- if (type === "autofill")
- return new Promise(resolve => {
- socket.dispatch(
- "stations.removeAutofillPlaylist",
- station.value._id,
- playlistId,
- res => {
- new Toast(res.message);
- resolve(true);
- }
- );
- });
- if (type === "blacklist")
- return new Promise(resolve => {
- socket.dispatch(
- "stations.removeBlacklistedPlaylist",
- station.value._id,
- playlistId,
- res => {
- new Toast(res.message);
- resolve(true);
- }
- );
- });
- if (type === "autorequest")
- return new Promise(resolve => {
- removePlaylistFromAutoRequest(playlistId);
- new Toast("Successfully deselected playlist.");
- resolve(true);
- });
- return false;
- };
- const selectPlaylist = async (playlist, typeOverwrite?: string) => {
- const type = typeOverwrite || props.type;
- if (isSelected(playlist._id, type))
- return new Toast(`Error: Playlist already ${label("past", type)}.`);
- if (type === "autofill")
- return new Promise(resolve => {
- socket.dispatch(
- "stations.autofillPlaylist",
- station.value._id,
- playlist._id,
- res => {
- new Toast(res.message);
- emit("selected");
- resolve(true);
- }
- );
- });
- if (type === "blacklist") {
- if (props.type !== "blacklist" && isSelected(playlist._id))
- await deselectPlaylist(playlist._id);
- return new Promise(resolve => {
- socket.dispatch(
- "stations.blacklistPlaylist",
- station.value._id,
- playlist._id,
- res => {
- new Toast(res.message);
- emit("selected");
- resolve(true);
- }
- );
- });
- }
- if (type === "autorequest")
- return new Promise(resolve => {
- addPlaylistToAutoRequest(playlist);
- new Toast("Successfully selected playlist to auto request songs.");
- emit("selected");
- resolve(true);
- });
- return false;
- };
- const searchForPlaylists = page => {
- if (search.page >= page || search.searchedQuery !== search.query) {
- search.results = [];
- search.page = 0;
- search.count = 0;
- search.resultsLeft = 0;
- search.pageSize = 0;
- }
- const { query } = search;
- const action =
- station.value.type === "official" && props.type !== "autorequest"
- ? "playlists.searchOfficial"
- : "playlists.searchCommunity";
- search.searchedQuery = search.query;
- socket.dispatch(action, query, page, res => {
- const { data } = res;
- if (res.status === "success") {
- const { count, pageSize, playlists } = data;
- search.results = [...search.results, ...playlists];
- search.page = page;
- search.count = count;
- search.resultsLeft = count - search.results.length;
- search.pageSize = pageSize;
- } else if (res.status === "error") {
- search.results = [];
- search.page = 0;
- search.count = 0;
- search.resultsLeft = 0;
- search.pageSize = 0;
- new Toast(res.message);
- }
- });
- };
- onMounted(() => {
- showTab("my-playlists");
- socket.onConnect(() => {
- socket.dispatch("playlists.indexMyPlaylists", res => {
- if (res.status === "success") setPlaylists(res.data.playlists);
- orderOfPlaylists.value = calculatePlaylistOrder(); // order in regards to the database
- });
- socket.dispatch("playlists.indexFeaturedPlaylists", res => {
- if (res.status === "success")
- featuredPlaylists.value = res.data.playlists;
- });
- if (props.type === "autofill")
- socket.dispatch(
- `stations.getStationAutofillPlaylistsById`,
- station.value._id,
- res => {
- if (res.status === "success") {
- station.value.autofill.playlists = res.data.playlists;
- }
- }
- );
- socket.dispatch(
- `stations.getStationBlacklistById`,
- station.value._id,
- res => {
- if (res.status === "success") {
- station.value.blacklist = res.data.playlists;
- }
- }
- );
- const autorequestLocalStorageItem = localStorage.getItem(
- `autorequest-${station.value._id}`
- );
- if (
- autorequestLocalStorageItem &&
- station.value.requests &&
- station.value.requests.allowAutorequest &&
- autoRequest.value.length === 0
- ) {
- const autorequestParsedItem = JSON.parse(
- autorequestLocalStorageItem
- );
- const autorequestUpdatedAt = new Date(
- autorequestParsedItem.updatedAt
- );
- const fiveMinutesAgo = new Date(
- new Date().getTime() - 5 * 60 * 1000
- );
- if (autorequestUpdatedAt > fiveMinutesAgo) {
- const playlists = [];
- const promises = autorequestParsedItem.playlistIds.map(
- playlistId =>
- new Promise<void>(resolve => {
- socket.dispatch(
- "playlists.getPlaylist",
- playlistId,
- res => {
- if (res.status === "success") {
- playlists.push(res.data.playlist);
- }
- resolve();
- }
- );
- })
- );
- Promise.all(promises).then(() => {
- addAutorequestPlaylists(playlists);
- });
- } else updateAutorequestLocalStorage();
- }
- });
- });
- </script>
- <template>
- <div class="playlist-tab-base">
- <div v-if="$slots.info" class="top-info has-text-centered">
- <slot name="info" />
- </div>
- <div class="tabs-container">
- <div class="tab-selection">
- <button
- v-if="
- type === 'autorequest' || station.type === 'community'
- "
- class="button is-default"
- :ref="el => (tabs['my-playlists-tab'] = el)"
- :class="{ selected: tab === 'my-playlists' }"
- @click="showTab('my-playlists')"
- >
- My Playlists
- </button>
- <button
- class="button is-default"
- :ref="el => (tabs['search-tab'] = el)"
- :class="{ selected: tab === 'search' }"
- @click="showTab('search')"
- >
- Search
- </button>
- <button
- class="button is-default"
- :ref="el => (tabs['current-tab'] = el)"
- :class="{ selected: tab === 'current' }"
- @click="showTab('current')"
- >
- Current
- <span class="tag" v-if="selectedPlaylists().length > 0">{{
- selectedPlaylists().length
- }}</span>
- </button>
- </div>
- <div class="tab" v-show="tab === 'search'">
- <div v-if="featuredPlaylists.length > 0">
- <label class="label"> Featured playlists </label>
- <playlist-item
- v-for="featuredPlaylist in featuredPlaylists"
- :key="`featuredKey-${featuredPlaylist._id}`"
- :playlist="featuredPlaylist"
- :show-owner="true"
- >
- <template #item-icon>
- <i
- class="material-icons blacklisted-icon"
- v-if="
- isSelected(
- featuredPlaylist._id,
- 'blacklist'
- )
- "
- :content="`This playlist is currently ${label(
- 'past',
- 'blacklist'
- )}`"
- v-tippy
- >
- block
- </i>
- <i
- class="material-icons"
- v-else-if="isSelected(featuredPlaylist._id)"
- :content="`This playlist is currently ${label(
- 'past'
- )}`"
- v-tippy
- >
- play_arrow
- </i>
- <i
- class="material-icons"
- v-else
- :content="`This playlist is currently not ${label(
- 'past'
- )}`"
- v-tippy
- >
- {{
- type === "blacklist"
- ? "block"
- : "play_disabled"
- }}
- </i>
- </template>
- <template #actions>
- <i
- v-if="
- type !== 'blacklist' &&
- isSelected(
- featuredPlaylist._id,
- 'blacklist'
- )
- "
- class="material-icons stop-icon"
- :content="`This playlist is ${label(
- 'past',
- 'blacklist'
- )} in this station`"
- v-tippy="{ theme: 'info' }"
- >play_disabled</i
- >
- <quick-confirm
- v-if="
- type !== 'blacklist' &&
- isSelected(featuredPlaylist._id)
- "
- @confirm="
- deselectPlaylist(featuredPlaylist._id)
- "
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- v-if="
- type !== 'blacklist' &&
- !isSelected(featuredPlaylist._id) &&
- !isSelected(
- featuredPlaylist._id,
- 'blacklist'
- )
- "
- @click="selectPlaylist(featuredPlaylist)"
- class="material-icons play-icon"
- :content="`${label(
- 'future',
- null,
- true
- )} songs from this playlist`"
- v-tippy
- >play_arrow</i
- >
- <quick-confirm
- v-if="
- type === 'blacklist' &&
- !isSelected(
- featuredPlaylist._id,
- 'blacklist'
- )
- "
- @confirm="
- selectPlaylist(
- featuredPlaylist,
- 'blacklist'
- )
- "
- >
- <i
- class="material-icons stop-icon"
- :content="`${label(
- 'future',
- null,
- true
- )} Playlist`"
- v-tippy
- >block</i
- >
- </quick-confirm>
- <quick-confirm
- v-if="
- type === 'blacklist' &&
- isSelected(
- featuredPlaylist._id,
- 'blacklist'
- )
- "
- @confirm="
- deselectPlaylist(featuredPlaylist._id)
- "
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- v-if="featuredPlaylist.createdBy === myUserId"
- @click="
- openModal({
- modal: 'editPlaylist',
- props: {
- playlistId: featuredPlaylist._id
- }
- })
- "
- class="material-icons edit-icon"
- content="Edit Playlist"
- v-tippy
- >edit</i
- >
- <i
- v-if="
- featuredPlaylist.createdBy !== myUserId &&
- (featuredPlaylist.privacy === 'public' ||
- hasPermission('playlists.view.others'))
- "
- @click="
- openModal({
- modal: 'editPlaylist',
- props: {
- playlistId: featuredPlaylist._id
- }
- })
- "
- class="material-icons edit-icon"
- content="View Playlist"
- v-tippy
- >visibility</i
- >
- </template>
- </playlist-item>
- <br />
- </div>
- <label class="label">Search for a playlist</label>
- <div class="control is-grouped input-with-button">
- <p class="control is-expanded">
- <input
- class="input"
- type="text"
- placeholder="Enter your playlist query here..."
- v-model="search.query"
- @keyup.enter="searchForPlaylists(1)"
- />
- </p>
- <p class="control">
- <a class="button is-info" @click="searchForPlaylists(1)"
- ><i class="material-icons icon-with-button"
- >search</i
- >Search</a
- >
- </p>
- </div>
- <div v-if="search.results.length > 0">
- <playlist-item
- v-for="playlist in search.results"
- :key="`searchKey-${playlist._id}`"
- :playlist="playlist"
- :show-owner="true"
- >
- <template #item-icon>
- <i
- class="material-icons blacklisted-icon"
- v-if="isSelected(playlist._id, 'blacklist')"
- :content="`This playlist is currently ${label(
- 'past',
- 'blacklist'
- )}`"
- v-tippy
- >
- block
- </i>
- <i
- class="material-icons"
- v-else-if="isSelected(playlist._id)"
- :content="`This playlist is currently ${label(
- 'past'
- )}`"
- v-tippy
- >
- play_arrow
- </i>
- <i
- class="material-icons"
- v-else
- :content="`This playlist is currently not ${label(
- 'past'
- )}`"
- v-tippy
- >
- {{
- type === "blacklist"
- ? "block"
- : "play_disabled"
- }}
- </i>
- </template>
- <template #actions>
- <i
- v-if="
- type !== 'blacklist' &&
- isSelected(playlist._id, 'blacklist')
- "
- class="material-icons stop-icon"
- :content="`This playlist is ${label(
- 'past',
- 'blacklist'
- )} in this station`"
- v-tippy="{ theme: 'info' }"
- >play_disabled</i
- >
- <quick-confirm
- v-if="
- type !== 'blacklist' &&
- isSelected(playlist._id)
- "
- @confirm="deselectPlaylist(playlist._id)"
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- v-if="
- type !== 'blacklist' &&
- !isSelected(playlist._id) &&
- !isSelected(playlist._id, 'blacklist')
- "
- @click="selectPlaylist(playlist)"
- class="material-icons play-icon"
- :content="`${label(
- 'future',
- null,
- true
- )} songs from this playlist`"
- v-tippy
- >play_arrow</i
- >
- <quick-confirm
- v-if="
- type === 'blacklist' &&
- !isSelected(playlist._id, 'blacklist')
- "
- @confirm="selectPlaylist(playlist, 'blacklist')"
- >
- <i
- class="material-icons stop-icon"
- :content="`${label(
- 'future',
- null,
- true
- )} Playlist`"
- v-tippy
- >block</i
- >
- </quick-confirm>
- <quick-confirm
- v-if="
- type === 'blacklist' &&
- isSelected(playlist._id, 'blacklist')
- "
- @confirm="deselectPlaylist(playlist._id)"
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- v-if="playlist.createdBy === myUserId"
- @click="
- openModal({
- modal: 'editPlaylist',
- props: { playlistId: playlist._id }
- })
- "
- class="material-icons edit-icon"
- content="Edit Playlist"
- v-tippy
- >edit</i
- >
- <i
- v-if="
- playlist.createdBy !== myUserId &&
- (playlist.privacy === 'public' ||
- hasPermission('playlists.view.others'))
- "
- @click="
- openModal({
- modal: 'editPlaylist',
- props: { playlistId: playlist._id }
- })
- "
- class="material-icons edit-icon"
- content="View Playlist"
- v-tippy
- >visibility</i
- >
- </template>
- </playlist-item>
- <button
- v-if="resultsLeftCount > 0"
- class="button is-primary load-more-button"
- @click="searchForPlaylists(search.page + 1)"
- >
- Load {{ nextPageResultsCount }} more results
- </button>
- </div>
- </div>
- <div class="tab" v-show="tab === 'current'">
- <p
- class="has-text-centered scrollable-list"
- v-if="
- selectedPlaylists().length > 0 && type === 'autorequest'
- "
- >
- You are currently autorequesting a mix of
- {{ totalUniqueAutorequestableYoutubeIds.length }} different
- songs. Of these, we can currently autorequest
- {{ actuallyAutorequestingYoutubeIds.length }} songs.
- <br />
- Songs that
- <span
- v-if="
- station.requests
- .autorequestDisallowRecentlyPlayedEnabled
- "
- >were played recently or</span
- >
- are currently in the queue or playing will not be
- autorequested.
- <br />
- <br />
- </p>
- <div v-if="selectedPlaylists().length > 0">
- <playlist-item
- v-for="playlist in selectedPlaylists()"
- :key="`key-${playlist._id}`"
- :playlist="playlist"
- :show-owner="true"
- >
- <template #item-icon>
- <i
- class="material-icons"
- :class="{
- 'blacklisted-icon': type === 'blacklist'
- }"
- :content="`This playlist is currently ${label(
- 'past'
- )}`"
- v-tippy
- >
- {{
- type === "blacklist"
- ? "block"
- : "play_arrow"
- }}
- </i>
- </template>
- <template #actions>
- <quick-confirm
- @confirm="deselectPlaylist(playlist._id)"
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- v-if="playlist.createdBy === myUserId"
- @click="
- openModal({
- modal: 'editPlaylist',
- props: { playlistId: playlist._id }
- })
- "
- class="material-icons edit-icon"
- content="Edit Playlist"
- v-tippy
- >edit</i
- >
- <i
- v-if="
- playlist.createdBy !== myUserId &&
- (playlist.privacy === 'public' ||
- hasPermission('playlists.view.others'))
- "
- @click="
- openModal({
- modal: 'editPlaylist',
- props: { playlistId: playlist._id }
- })
- "
- class="material-icons edit-icon"
- content="View Playlist"
- v-tippy
- >visibility</i
- >
- </template>
- </playlist-item>
- </div>
- <p v-else class="has-text-centered scrollable-list">
- No playlists currently {{ label("present") }}.
- </p>
- </div>
- <div
- v-if="type === 'autorequest' || station.type === 'community'"
- class="tab"
- v-show="tab === 'my-playlists'"
- >
- <div
- class="menu-list scrollable-list"
- v-if="playlists.length > 0"
- >
- <draggable-list
- v-model:list="playlists"
- item-key="_id"
- @start="drag = true"
- @end="drag = false"
- @update="savePlaylistOrder"
- >
- <template #item="{ element }">
- <playlist-item :playlist="element">
- <template #item-icon>
- <i
- class="material-icons blacklisted-icon"
- v-if="
- isSelected(element._id, 'blacklist')
- "
- :content="`This playlist is currently ${label(
- 'past',
- 'blacklist'
- )}`"
- v-tippy
- >
- block
- </i>
- <i
- class="material-icons"
- v-else-if="isSelected(element._id)"
- :content="`This playlist is currently ${label(
- 'past'
- )}`"
- v-tippy
- >
- play_arrow
- </i>
- <i
- class="material-icons"
- v-else
- :content="`This playlist is currently not ${label(
- 'past'
- )}`"
- v-tippy
- >
- {{
- type === "blacklist"
- ? "block"
- : "play_disabled"
- }}
- </i>
- </template>
- <template #actions>
- <i
- v-if="
- type !== 'blacklist' &&
- isSelected(element._id, 'blacklist')
- "
- class="material-icons stop-icon"
- :content="`This playlist is ${label(
- 'past',
- 'blacklist'
- )} in this station`"
- v-tippy="{ theme: 'info' }"
- >play_disabled</i
- >
- <quick-confirm
- v-if="
- type !== 'blacklist' &&
- isSelected(element._id)
- "
- @confirm="deselectPlaylist(element._id)"
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- v-if="
- type !== 'blacklist' &&
- !isSelected(element._id) &&
- !isSelected(
- element._id,
- 'blacklist'
- )
- "
- @click="selectPlaylist(element)"
- class="material-icons play-icon"
- :content="`${label(
- 'future',
- null,
- true
- )} songs from this playlist`"
- v-tippy
- >play_arrow</i
- >
- <quick-confirm
- v-if="
- type === 'blacklist' &&
- !isSelected(
- element._id,
- 'blacklist'
- )
- "
- @confirm="
- selectPlaylist(element, 'blacklist')
- "
- >
- <i
- class="material-icons stop-icon"
- :content="`${label(
- 'future',
- null,
- true
- )} Playlist`"
- v-tippy
- >block</i
- >
- </quick-confirm>
- <quick-confirm
- v-if="
- type === 'blacklist' &&
- isSelected(element._id, 'blacklist')
- "
- @confirm="deselectPlaylist(element._id)"
- >
- <i
- class="material-icons stop-icon"
- :content="`Stop ${label(
- 'present'
- )} songs from this playlist`"
- v-tippy
- >
- stop
- </i>
- </quick-confirm>
- <i
- @click="
- openModal({
- modal: 'editPlaylist',
- props: {
- playlistId: element._id
- }
- })
- "
- class="material-icons edit-icon"
- content="Edit Playlist"
- v-tippy
- >edit</i
- >
- </template>
- </playlist-item>
- </template>
- </draggable-list>
- </div>
- <p v-else class="has-text-centered scrollable-list">
- You don't have any playlists
- </p>
- <button
- class="button is-primary"
- id="create-new-playlist-button"
- @click="openModal('createPlaylist')"
- >
- Create new playlist
- </button>
- </div>
- </div>
- </div>
- </template>
- <style lang="less" scoped>
- .night-mode {
- .tabs-container .tab-selection .button {
- background: var(--dark-grey) !important;
- color: var(--white) !important;
- }
- }
- .blacklisted-icon {
- color: var(--dark-red);
- }
- .playlist-tab-base {
- .top-info {
- font-size: 15px;
- margin-bottom: 15px;
- }
- .tabs-container {
- .tab-selection {
- display: flex;
- overflow-x: auto;
- .button {
- border-radius: 0;
- border: 0;
- text-transform: uppercase;
- font-size: 14px;
- color: var(--dark-grey-3);
- background-color: var(--light-grey-2);
- flex-grow: 1;
- height: 32px;
- &:not(:first-of-type) {
- margin-left: 5px;
- }
- }
- .selected {
- background-color: var(--primary-color) !important;
- color: var(--white) !important;
- font-weight: 600;
- }
- }
- .tab {
- padding: 15px 0;
- border-radius: 0;
- .playlist-item:not(:last-of-type) {
- margin-bottom: 10px;
- }
- .load-more-button {
- width: 100%;
- margin-top: 10px;
- }
- }
- }
- }
- .draggable-list-transition-move {
- transition: transform 0.5s;
- }
- .draggable-list-ghost {
- opacity: 0.5;
- filter: brightness(95%);
- }
- </style>
|