Songs.vue 2.1 KB

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