Songs.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <script setup lang="ts">
  2. import { defineAsyncComponent, ref, onMounted } from "vue";
  3. import { storeToRefs } from "pinia";
  4. import { useEditSongStore } from "@/stores/editSong";
  5. import useSearchMusare from "@/composables/useSearchMusare";
  6. const SongItem = defineAsyncComponent(
  7. () => import("@/components/SongItem.vue")
  8. );
  9. const props = defineProps({
  10. modalUuid: { type: String, default: "" },
  11. modalModulePath: { type: String, default: "modals/editSong/MODAL_UUID" }
  12. });
  13. const sitename = ref("Musare");
  14. const editSongStore = useEditSongStore(props);
  15. const { song } = storeToRefs(editSongStore);
  16. const {
  17. musareSearch,
  18. resultsLeftCount,
  19. nextPageResultsCount,
  20. searchForMusareSongs
  21. } = useSearchMusare();
  22. onMounted(async () => {
  23. sitename.value = await lofig.get("siteSettings.sitename");
  24. musareSearch.value.query = song.value.title;
  25. searchForMusareSongs(1, false);
  26. });
  27. </script>
  28. <template>
  29. <div class="musare-songs-tab">
  30. <label class="label"> Search for a song on {{ sitename }} </label>
  31. <div class="control is-grouped input-with-button">
  32. <p class="control is-expanded">
  33. <input
  34. class="input"
  35. type="text"
  36. placeholder="Enter your song query here..."
  37. v-model="musareSearch.query"
  38. @keyup.enter="searchForMusareSongs(1)"
  39. />
  40. </p>
  41. <p class="control">
  42. <a class="button is-info" @click="searchForMusareSongs(1)"
  43. ><i class="material-icons icon-with-button">search</i
  44. >Search</a
  45. >
  46. </p>
  47. </div>
  48. <div v-if="musareSearch.results.length > 0">
  49. <song-item
  50. v-for="result in musareSearch.results"
  51. :key="result._id"
  52. :song="result"
  53. :disabled-actions="['addToPlaylist', 'edit']"
  54. />
  55. <button
  56. v-if="resultsLeftCount > 0"
  57. class="button is-primary load-more-button"
  58. @click="searchForMusareSongs(musareSearch.page + 1)"
  59. >
  60. Load {{ nextPageResultsCount }} more results
  61. </button>
  62. </div>
  63. </div>
  64. </template>
  65. <style lang="less" scoped>
  66. .musare-songs-tab #song-query-results {
  67. height: calc(100% - 74px);
  68. overflow: auto;
  69. .search-query-item {
  70. .icon-selected {
  71. color: var(--green) !important;
  72. }
  73. .icon-not-selected {
  74. color: var(--grey) !important;
  75. }
  76. }
  77. .search-query-item:not(:last-of-type) {
  78. margin-bottom: 10px;
  79. }
  80. .load-more-button {
  81. width: 100%;
  82. margin-top: 10px;
  83. }
  84. }
  85. </style>