1
0

Youtube.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div class="youtube-tab">
  3. <label class="label"> Search for a song from YouTube </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 YouTube query here..."
  10. v-model="youtubeSearch.songs.query"
  11. autofocus
  12. @keyup.enter="searchForSongs()"
  13. />
  14. </p>
  15. <p class="control">
  16. <button
  17. class="button is-info"
  18. @click.prevent="searchForSongs()"
  19. >
  20. <i class="material-icons icon-with-button">search</i>Search
  21. </button>
  22. </p>
  23. </div>
  24. <div
  25. v-if="youtubeSearch.songs.results.length > 0"
  26. id="song-query-results"
  27. >
  28. <search-query-item
  29. v-for="result in youtubeSearch.songs.results"
  30. :key="result.id"
  31. :result="result"
  32. >
  33. <template #actions>
  34. <i
  35. class="material-icons icon-selected"
  36. v-if="result.id === song.youtubeId"
  37. key="selected"
  38. >radio_button_checked
  39. </i>
  40. <i
  41. class="material-icons icon-not-selected"
  42. v-else
  43. @click.prevent="selectSong(result)"
  44. key="not-selected"
  45. >radio_button_unchecked
  46. </i>
  47. </template>
  48. </search-query-item>
  49. <button
  50. class="button is-primary load-more-button"
  51. @click.prevent="loadMoreSongs()"
  52. >
  53. Load more...
  54. </button>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import { mapGetters } from "vuex";
  60. import { mapModalState, mapModalActions } from "@/vuex_helpers";
  61. import SearchYoutube from "@/mixins/SearchYoutube.vue";
  62. import SearchQueryItem from "../../../SearchQueryItem.vue";
  63. export default {
  64. components: { SearchQueryItem },
  65. mixins: [SearchYoutube],
  66. props: {
  67. modalUuid: { type: String, default: "" },
  68. modalModulePath: { type: String, default: "modals/editSong/MODAL_UUID" }
  69. },
  70. data() {
  71. return {};
  72. },
  73. computed: {
  74. ...mapModalState("MODAL_MODULE_PATH", {
  75. song: state => state.song,
  76. newSong: state => state.newSong
  77. }),
  78. ...mapGetters({
  79. socket: "websockets/getSocket"
  80. })
  81. },
  82. methods: {
  83. selectSong(result) {
  84. this.updateYoutubeId(result.id);
  85. if (this.newSong) {
  86. this.updateTitle(result.title);
  87. this.updateThumbnail(result.thumbnail);
  88. }
  89. },
  90. ...mapModalActions("MODAL_MODULE_PATH", [
  91. "updateYoutubeId",
  92. "updateTitle",
  93. "updateThumbnail"
  94. ])
  95. }
  96. };
  97. </script>
  98. <style lang="less" scoped>
  99. .youtube-tab #song-query-results {
  100. height: calc(100% - 74px);
  101. overflow: auto;
  102. .search-query-item {
  103. .icon-selected {
  104. color: var(--green) !important;
  105. }
  106. .icon-not-selected {
  107. color: var(--grey) !important;
  108. }
  109. }
  110. .search-query-item:not(:last-of-type) {
  111. margin-bottom: 10px;
  112. }
  113. .load-more-button {
  114. width: 100%;
  115. margin-top: 10px;
  116. }
  117. }
  118. </style>