|
@@ -1,66 +1,112 @@
|
|
<template>
|
|
<template>
|
|
<div class="youtube-tab section">
|
|
<div class="youtube-tab section">
|
|
- <label class="label"> Search for a song from YouTube </label>
|
|
|
|
- <div class="control is-grouped input-with-button">
|
|
|
|
- <p class="control is-expanded">
|
|
|
|
- <input
|
|
|
|
- class="input"
|
|
|
|
- type="text"
|
|
|
|
- placeholder="Enter your YouTube query here..."
|
|
|
|
- v-model="search.songs.query"
|
|
|
|
- autofocus
|
|
|
|
- @keyup.enter="searchForSongs()"
|
|
|
|
|
|
+ <div class="musare-songs">
|
|
|
|
+ <label class="label"> Search for a song on Musare </label>
|
|
|
|
+ <div class="control is-grouped input-with-button">
|
|
|
|
+ <p class="control is-expanded">
|
|
|
|
+ <input
|
|
|
|
+ class="input"
|
|
|
|
+ type="text"
|
|
|
|
+ placeholder="Enter your song query here..."
|
|
|
|
+ v-model="musareSearch.query"
|
|
|
|
+ @keyup.enter="searchForMusareSongs(1)"
|
|
|
|
+ />
|
|
|
|
+ </p>
|
|
|
|
+ <p class="control">
|
|
|
|
+ <a class="button is-info" @click="searchForMusareSongs(1)"
|
|
|
|
+ ><i class="material-icons icon-with-button">search</i
|
|
|
|
+ >Search</a
|
|
|
|
+ >
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <div v-if="musareSearch.results.length > 0">
|
|
|
|
+ <song-item
|
|
|
|
+ v-for="song in musareSearch.results"
|
|
|
|
+ :key="song._id"
|
|
|
|
+ :song="song"
|
|
/>
|
|
/>
|
|
- </p>
|
|
|
|
- <p class="control">
|
|
|
|
- <a
|
|
|
|
- class="button is-info"
|
|
|
|
- @click.prevent="searchForSongs()"
|
|
|
|
- href="#"
|
|
|
|
- ><i class="material-icons icon-with-button">search</i
|
|
|
|
- >Search</a
|
|
|
|
|
|
+ <button
|
|
|
|
+ v-if="resultsLeftCount > 0"
|
|
|
|
+ class="button is-primary load-more-button"
|
|
|
|
+ @click="searchForMusareSongs(musareSearch.page + 1)"
|
|
>
|
|
>
|
|
- </p>
|
|
|
|
|
|
+ Load {{ nextPageResultsCount }} more results
|
|
|
|
+ </button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div v-if="search.songs.results.length > 0" id="song-query-results">
|
|
|
|
- <search-query-item
|
|
|
|
- v-for="(result, index) in search.songs.results"
|
|
|
|
- :key="result.id"
|
|
|
|
- :result="result"
|
|
|
|
- >
|
|
|
|
- <template #actions>
|
|
|
|
- <transition name="search-query-actions" mode="out-in">
|
|
|
|
- <a
|
|
|
|
- class="button is-success"
|
|
|
|
- v-if="result.isAddedToQueue"
|
|
|
|
- href="#"
|
|
|
|
- key="added-to-playlist"
|
|
|
|
- >
|
|
|
|
- <i class="material-icons icon-with-button">done</i>
|
|
|
|
- Added to playlist
|
|
|
|
- </a>
|
|
|
|
- <a
|
|
|
|
- class="button is-dark"
|
|
|
|
- v-else
|
|
|
|
- @click.prevent="addSongToPlaylist(result.id, index)"
|
|
|
|
- href="#"
|
|
|
|
- key="add-to-playlist"
|
|
|
|
- >
|
|
|
|
- <i class="material-icons icon-with-button">add</i>
|
|
|
|
- Add to playlist
|
|
|
|
- </a>
|
|
|
|
- </transition>
|
|
|
|
- </template>
|
|
|
|
- </search-query-item>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <label class="label"> Search for a song from YouTube </label>
|
|
|
|
+ <div class="control is-grouped input-with-button">
|
|
|
|
+ <p class="control is-expanded">
|
|
|
|
+ <input
|
|
|
|
+ class="input"
|
|
|
|
+ type="text"
|
|
|
|
+ placeholder="Enter your YouTube query here..."
|
|
|
|
+ v-model="youtubeSearch.songs.query"
|
|
|
|
+ autofocus
|
|
|
|
+ @keyup.enter="searchForSongs()"
|
|
|
|
+ />
|
|
|
|
+ </p>
|
|
|
|
+ <p class="control">
|
|
|
|
+ <a
|
|
|
|
+ class="button is-info"
|
|
|
|
+ @click.prevent="searchForSongs()"
|
|
|
|
+ href="#"
|
|
|
|
+ ><i class="material-icons icon-with-button">search</i
|
|
|
|
+ >Search</a
|
|
|
|
+ >
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
|
|
- <a
|
|
|
|
- class="button is-primary load-more-button"
|
|
|
|
- @click.prevent="loadMoreSongs()"
|
|
|
|
- href="#"
|
|
|
|
|
|
+ <div
|
|
|
|
+ v-if="youtubeSearch.songs.results.length > 0"
|
|
|
|
+ id="song-query-results"
|
|
>
|
|
>
|
|
- Load more...
|
|
|
|
- </a>
|
|
|
|
|
|
+ <search-query-item
|
|
|
|
+ v-for="(result, index) in youtubeSearch.songs.results"
|
|
|
|
+ :key="result.id"
|
|
|
|
+ :result="result"
|
|
|
|
+ >
|
|
|
|
+ <template #actions>
|
|
|
|
+ <transition name="search-query-actions" mode="out-in">
|
|
|
|
+ <a
|
|
|
|
+ class="button is-success"
|
|
|
|
+ v-if="result.isAddedToQueue"
|
|
|
|
+ href="#"
|
|
|
|
+ key="added-to-playlist"
|
|
|
|
+ >
|
|
|
|
+ <i class="material-icons icon-with-button"
|
|
|
|
+ >done</i
|
|
|
|
+ >
|
|
|
|
+ Added to playlist
|
|
|
|
+ </a>
|
|
|
|
+ <a
|
|
|
|
+ class="button is-dark"
|
|
|
|
+ v-else
|
|
|
|
+ @click.prevent="
|
|
|
|
+ addSongToPlaylist(result.id, index)
|
|
|
|
+ "
|
|
|
|
+ href="#"
|
|
|
|
+ key="add-to-playlist"
|
|
|
|
+ >
|
|
|
|
+ <i class="material-icons icon-with-button"
|
|
|
|
+ >add</i
|
|
|
|
+ >
|
|
|
|
+ Add to playlist
|
|
|
|
+ </a>
|
|
|
|
+ </transition>
|
|
|
|
+ </template>
|
|
|
|
+ </search-query-item>
|
|
|
|
+
|
|
|
|
+ <a
|
|
|
|
+ class="button is-primary load-more-button"
|
|
|
|
+ @click.prevent="loadMoreSongs()"
|
|
|
|
+ href="#"
|
|
|
|
+ >
|
|
|
|
+ Load more...
|
|
|
|
+ </a>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -69,15 +115,14 @@
|
|
import { mapState, mapGetters } from "vuex";
|
|
import { mapState, mapGetters } from "vuex";
|
|
|
|
|
|
import SearchYoutube from "@/mixins/SearchYoutube.vue";
|
|
import SearchYoutube from "@/mixins/SearchYoutube.vue";
|
|
|
|
+import SearchMusare from "@/mixins/SearchMusare.vue";
|
|
|
|
|
|
|
|
+import SongItem from "@/components/SongItem.vue";
|
|
import SearchQueryItem from "../../../SearchQueryItem.vue";
|
|
import SearchQueryItem from "../../../SearchQueryItem.vue";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
- components: { SearchQueryItem },
|
|
|
|
- mixins: [SearchYoutube],
|
|
|
|
- data() {
|
|
|
|
- return {};
|
|
|
|
- },
|
|
|
|
|
|
+ components: { SearchQueryItem, SongItem },
|
|
|
|
+ mixins: [SearchYoutube, SearchMusare],
|
|
computed: {
|
|
computed: {
|
|
...mapState("modals/editPlaylist", {
|
|
...mapState("modals/editPlaylist", {
|
|
playlist: state => state.playlist
|
|
playlist: state => state.playlist
|
|
@@ -87,22 +132,28 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
- "search.songs.results": function checkIfSongInPlaylist(songs) {
|
|
|
|
|
|
+ "youtubeSearch.songs.results": function checkIfSongInPlaylist(songs) {
|
|
songs.forEach((searchItem, index) =>
|
|
songs.forEach((searchItem, index) =>
|
|
this.playlist.songs.find(song => {
|
|
this.playlist.songs.find(song => {
|
|
if (song.youtubeId === searchItem.id)
|
|
if (song.youtubeId === searchItem.id)
|
|
- this.search.songs.results[index].isAddedToQueue = true;
|
|
|
|
|
|
+ this.youtubeSearch.songs.results[
|
|
|
|
+ index
|
|
|
|
+ ].isAddedToQueue = true;
|
|
|
|
|
|
return song.youtubeId === searchItem.id;
|
|
return song.youtubeId === searchItem.id;
|
|
})
|
|
})
|
|
);
|
|
);
|
|
},
|
|
},
|
|
"playlist.songs": function checkIfSongInPlaylist() {
|
|
"playlist.songs": function checkIfSongInPlaylist() {
|
|
- this.search.songs.results.forEach((searchItem, index) =>
|
|
|
|
|
|
+ this.youtubeSearch.songs.results.forEach((searchItem, index) =>
|
|
this.playlist.songs.find(song => {
|
|
this.playlist.songs.find(song => {
|
|
- this.search.songs.results[index].isAddedToQueue = false;
|
|
|
|
|
|
+ this.youtubeSearch.songs.results[
|
|
|
|
+ index
|
|
|
|
+ ].isAddedToQueue = false;
|
|
if (song.youtubeId === searchItem.id)
|
|
if (song.youtubeId === searchItem.id)
|
|
- this.search.songs.results[index].isAddedToQueue = true;
|
|
|
|
|
|
+ this.youtubeSearch.songs.results[
|
|
|
|
+ index
|
|
|
|
+ ].isAddedToQueue = true;
|
|
|
|
|
|
return song.youtubeId === searchItem.id;
|
|
return song.youtubeId === searchItem.id;
|
|
})
|
|
})
|