Songs.vue 2.2 KB

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