AdminSongs.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 is-horizontal">
  33. <input v-for="artist in song.artists" track-by="$index" class="input" type="text" :value="artist" v-model="artist">
  34. </p>
  35. </td>
  36. <td>
  37. <a class="button is-danger" @click="songs.splice(index, 1)">Remove</a>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. <a class="button is-success" @click="update()">Save Changes</a>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. songs: []
  51. }
  52. },
  53. methods: {
  54. update() {
  55. this.socket.emit('/songs/update', this.songs, (result) => {
  56. console.log(result);
  57. });
  58. }
  59. },
  60. ready: function() {
  61. let local = this;
  62. local.socket = local.$parent.$parent.socket;
  63. local.socket.emit("/songs", function(data) {
  64. local.songs = data;
  65. });
  66. }
  67. }
  68. </script>
  69. <style lang="sass" scoped>
  70. .is-success {
  71. width: 100%;
  72. }
  73. </style>