AdminQueue.vue 3.8 KB

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