QueueSongs.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="columns is-mobile">
  3. <div class="column is-8-desktop is-offset-2-desktop is-12-mobile">
  4. <table class="table is-striped">
  5. <thead>
  6. <tr>
  7. <td>YouTube ID</td>
  8. <td>Title</td>
  9. <td>Thumbnail</td>
  10. <td>Artists</td>
  11. <td>Options</td>
  12. </tr>
  13. </thead>
  14. <tbody>
  15. <tr v-for="(index, song) in songs" track-by="$index">
  16. <td>
  17. <p class="control">
  18. <input class="input" type="text" :value="song._id" v-model="song._id">
  19. </p>
  20. </td>
  21. <td>
  22. <p class="control">
  23. <input class="input" type="text" :value="song.title" v-model="song.title">
  24. </p>
  25. </td>
  26. <td>
  27. <p class="control">
  28. <input class="input" type="text" :value="song.thumbnail" v-model="song.thumbnail">
  29. </p>
  30. </td>
  31. <td>
  32. <div class="control">
  33. <input v-for="artist in song.artists" track-by="$index" class="input" type="text" :value="artist" v-model="artist">
  34. </div>
  35. </td>
  36. <td>
  37. <a class="button is-danger" @click="remove(song, index)">Remove</a>
  38. <a class="button is-success" @click="update(song)">Save Changes</a>
  39. </td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. songs: []
  51. }
  52. },
  53. methods: {
  54. update (song) {
  55. this.socket.emit('queueSongs.update', song, res => {
  56. console.log(res);
  57. });
  58. },
  59. remove (songId) {
  60. this.socket.emit('queueSongs.remove', songId, res => {
  61. console.log(res);
  62. });
  63. }
  64. },
  65. ready: function() {
  66. let _this = this;
  67. let socketInterval = setInterval(() => {
  68. if (!!_this.$parent.$parent.socket) {
  69. _this.socket = _this.$parent.$parent.socket;
  70. _this.socket.emit('queueSongs.index', data => {
  71. _this.songs = data;
  72. });
  73. clearInterval(socketInterval);
  74. }
  75. }, 100);
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. </style>