AdminQueue.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="app">
  3. <main-header></main-header>
  4. <table>
  5. <thead>
  6. <tr>
  7. <td>Title</td>
  8. <td>Artists</td>
  9. <td>Genre's</td>
  10. <td>Controls</td>
  11. </tr>
  12. </thead>
  13. <tbody>
  14. <tr v-for="song in songs">
  15. <td>{{song.title}}</td>
  16. <td>{{song.artists}}</td>
  17. <td>{{song.genres}}</td>
  18. <td><button @click="reviewSong(song._id)">Review</button></td>
  19. </tr>
  20. </tbody>
  21. </table>
  22. <main-footer></main-footer>
  23. <div class="modal fade" id="reviewModal" tabindex="-1" role="dialog" aria-labelledby="review-modal">
  24. <div class="modal-dialog modal-large" role="document">
  25. <div class="modal-content">
  26. <div class="modal-header">
  27. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  28. <h5 class="modal-title">Review</h5>
  29. </div>
  30. <div class="modal-body">
  31. <label for="reviewId">ID</label>
  32. <input type="text" v-bind:value="reviewSongObject._id" id="reviewId"/><br>
  33. <label for="reviewTitle">Title</label>
  34. <input type="text" v-bind:value="reviewSongObject.title" id="reviewTitle"/><br>
  35. <label for="reviewArtists">Artists</label>
  36. <input type="text" v-bind:value="reviewSongObject.artists" id="reviewArtists"/><br>
  37. <label for="reviewGenres">Genres</label>
  38. <input type="text" v-bind:value="reviewSongObject.genres" id="reviewGenres"/><br>
  39. <label for="reviewDuration">Duration</label>
  40. <input type="number" v-bind:value="reviewSongObject.duration" id="reviewDuration"/><br>
  41. <label for="reviewSkipDuration">Skip Duration</label>
  42. <input type="number" v-bind:value="reviewSongObject.skipDuration" id="reviewSkipDuration"/><br>
  43. <label for="reviewImage">Image</label>
  44. <input type="text" v-bind:value="reviewSongObject.image" id="reviewImage"/>
  45. </div>
  46. <div class="modal-footer">
  47. <button type="button" class="btn btn-primary left" @click="saveQueueSongChanges()">Save</button>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import MainHeader from '../MainHeader.vue'
  56. import MainFooter from '../MainFooter.vue'
  57. export default {
  58. components: { MainHeader, MainFooter },
  59. data() {
  60. return {
  61. songs: [],
  62. reviewSongObject: {},
  63. reviewSongId: ""
  64. }
  65. },
  66. methods: {
  67. reviewSong: function(id) {
  68. let local = this;
  69. local.reviewSongObject = {};
  70. local.reviewSongId = "";
  71. local.songs.forEach(function(song) {
  72. if (song._id === id) {
  73. for (var prop in song) {
  74. local.reviewSongObject[prop] = song[prop];
  75. }
  76. local.reviewSongId = id;
  77. $('#reviewModal').modal('show');
  78. }
  79. });
  80. },
  81. saveQueueSongChanges: function() {
  82. let local = this;
  83. let songId = local.reviewSongId;
  84. let songObject = {};
  85. songObject._id = $("#reviewId").val();
  86. songObject.title = $("#reviewTitle").val();
  87. songObject.artists = $("#reviewArtists").val();
  88. songObject.genres = $("#reviewGenres").val();
  89. songObject.duration = $("#reviewDuration").val();
  90. songObject.skipDuration = $("#reviewSkipDuration").val();
  91. songObject.image = $("#reviewImage").val();
  92. if (typeof songObject.artists === "string") {
  93. songObject.artists = songObject.artists.split(", ");
  94. }
  95. if (typeof songObject.genres === "string") {
  96. songObject.genres = songObject.genres.split(", ");
  97. }
  98. local.socket.emit("/songs/queue/updateSong/:id", songId, songObject, function(data) {
  99. console.log(data);
  100. });
  101. }
  102. },
  103. ready: function() {
  104. let local = this;
  105. local.socket = this.$parent.socket;
  106. local.socket.emit("/songs/queue/getSongs", function(data) {
  107. local.songs = data.songs;
  108. });
  109. }
  110. }
  111. </script>
  112. <style lang="sass">
  113. </style>