SongsList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class='sidebar' transition='slide' v-if='$parent.sidebars.songslist'>
  3. <div class='inner-wrapper'>
  4. <div class='title' v-if='$parent.type === "community"'>Queue</div>
  5. <div class='title' v-else>Playlist</div>
  6. <article class="media" v-if="!$parent.noSong">
  7. <figure class="media-left">
  8. <p class="image is-64x64">
  9. <img :src="$parent.currentSong.thumbnail" onerror="this.src='/assets/notes-transparent.png'">
  10. </p>
  11. </figure>
  12. <div class="media-content">
  13. <div class="content">
  14. <p>
  15. Current Song: <strong>{{ $parent.currentSong.title }}</strong>
  16. <br>
  17. <small>{{ $parent.currentSong.artists }}</small>
  18. </p>
  19. </div>
  20. </div>
  21. <div class="media-right">
  22. {{ $parent.formatTime($parent.currentSong.duration) }}
  23. </div>
  24. </article>
  25. <p v-if="$parent.noSong" class="center">There is currently no song playing.</p>
  26. <article class="media" v-for='song in $parent.songsList'>
  27. <div class="media-content">
  28. <div class="content">
  29. <p>
  30. <strong>{{ song.title }}</strong>
  31. <br>
  32. <small>{{ song.artists.join(', ') }}</small>
  33. <div v-if="this.$parent.$parent.type === 'community'">
  34. <br>
  35. <small>Requested by <b>{{this.$parent.$parent.$parent.getUsernameFromId(song.requestedBy)}} {{this.userIdMap[song.requestedBy]}}</b></small>
  36. <button class="button" @click="removeFromQueue(song.songId)" v-if="isOwnerOnly() || isAdminOnly()">REMOVE</button>
  37. </div>
  38. </p>
  39. </div>
  40. </div>
  41. <div class="media-right">
  42. {{ $parent.$parent.formatTime(song.duration) }}
  43. </div>
  44. </article>
  45. <div v-if="$parent.type === 'community' && $parent.$parent.loggedIn">
  46. <button class='button add-to-queue' @click='$parent.modals.addSongToQueue = !$parent.modals.addSongToQueue' v-if="($parent.station.locked && isOwnerOnly()) || !$parent.station.locked || ($parent.station.locked && isAdminOnly() && dismissedWarning)">Add Song to Queue</button>
  47. <button class='button add-to-queue add-to-queue-warning' @click='dismissedWarning = true' v-if="$parent.station.locked && isAdminOnly() && !isOwnerOnly() && !dismissedWarning">THIS STATION'S QUEUE IS LOCKED.</button>
  48. <button class='button add-to-queue add-to-queue-disabled' v-if="$parent.station.locked && !isAdminOnly() && !isOwnerOnly()">THIS STATION'S QUEUE IS LOCKED.</button>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import io from '../../io';
  55. import { Toast } from 'vue-roaster';
  56. export default {
  57. data: function () {
  58. return {
  59. dismissedWarning: false,
  60. userIdMap: this.$parent.$parent.userIdMap
  61. }
  62. },
  63. methods: {
  64. isOwnerOnly: function () {
  65. return this.$parent.$parent.loggedIn && this.$parent.$parent.userId === this.$parent.station.owner;
  66. },
  67. isAdminOnly: function() {
  68. return this.$parent.$parent.loggedIn && this.$parent.$parent.role === 'admin';
  69. },
  70. removeFromQueue: function(songId) {
  71. socket.emit('stations.removeFromQueue', this.$parent.station._id, songId, res => {
  72. if (res.status === 'success') {
  73. Toast.methods.addToast('Successfully removed song from the queue.', 4000);
  74. } else Toast.methods.addToast(res.message, 8000);
  75. });
  76. }
  77. },
  78. ready: function () {
  79. /*let _this = this;
  80. io.getSocket((socket) => {
  81. _this.socket = socket;
  82. });*/
  83. }
  84. }
  85. </script>
  86. <style type='scss' scoped>
  87. .sidebar {
  88. position: fixed;
  89. z-index: 1;
  90. top: 0;
  91. right: 0;
  92. width: 300px;
  93. height: 100vh;
  94. background-color: #fff;
  95. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  96. }
  97. .inner-wrapper {
  98. top: 64px;
  99. position: relative;
  100. overflow: auto;
  101. height: 100%;
  102. }
  103. .slide-transition {
  104. transition: transform 0.6s ease-in-out;
  105. transform: translateX(0);
  106. }
  107. .slide-enter, .slide-leave { transform: translateX(100%); }
  108. .title {
  109. background-color: rgb(3, 169, 244);
  110. text-align: center;
  111. padding: 10px;
  112. color: white;
  113. font-weight: 600;
  114. }
  115. .media { padding: 0 25px; }
  116. .media-content .content {
  117. min-height: 64px;
  118. display: flex;
  119. align-items: center;
  120. }
  121. .content p strong { word-break: break-word; }
  122. .content p small { word-break: break-word; }
  123. .add-to-queue {
  124. width: 100%;
  125. margin-top: 25px;
  126. height: 40px;
  127. border-radius: 0;
  128. background: rgb(3, 169, 244);
  129. color: #fff !important;
  130. border: 0;
  131. &:active, &:focus { border: 0; }
  132. }
  133. .add-to-queue.add-to-queue-warning {
  134. background-color: red;
  135. }
  136. .add-to-queue.add-to-queue-disabled {
  137. background-color: gray;
  138. }
  139. .add-to-queue.add-to-queue-disabled:focus {
  140. background-color: gray;
  141. }
  142. .add-to-queue:focus { background: #029ce3; }
  143. .media-right { line-height: 64px; }
  144. </style>