SongsList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <sidebar :title="station.type === 'community' ? 'Queue' : 'Playlist'">
  3. <template v-slot:content>
  4. <article v-if="!noSong" class="media">
  5. <figure v-if="currentSong.thumbnail" class="media-left">
  6. <p class="image is-64x64">
  7. <img
  8. :src="currentSong.thumbnail"
  9. onerror="this.src='/assets/notes-transparent.png'"
  10. />
  11. </p>
  12. </figure>
  13. <div class="media-content">
  14. <div class="content">
  15. <p>
  16. Current Song:
  17. <strong>{{ currentSong.title }}</strong>
  18. <br />
  19. <small>{{ currentSong.artists }}</small>
  20. </p>
  21. </div>
  22. </div>
  23. <div class="media-right">
  24. {{ utils.formatTime(currentSong.duration) }}
  25. </div>
  26. </article>
  27. <p v-if="noSong" class="has-text-centered">
  28. There is currently no song playing.
  29. </p>
  30. <hr v-if="noSong" />
  31. <article
  32. v-for="song in songsList"
  33. :key="song.songId"
  34. class="media"
  35. :class="{ 'is-playing': currentSong.songId === song.songId }"
  36. >
  37. <div class="media-content">
  38. <div
  39. class="content"
  40. style="display: block; padding-top: 10px"
  41. >
  42. <strong class="songTitle">{{ song.title }}</strong>
  43. <small>{{ song.artists.join(", ") }}</small>
  44. <div
  45. v-if="
  46. station.type === 'community' &&
  47. station.partyMode === true
  48. "
  49. >
  50. <small>
  51. Requested by
  52. <b>
  53. <user-id-to-username
  54. :userId="song.requestedBy"
  55. :link="true"
  56. />
  57. </b>
  58. </small>
  59. <i
  60. v-if="isOwnerOnly() || isAdminOnly()"
  61. class="material-icons"
  62. style="vertical-align: middle"
  63. @click="removeFromQueue(song.songId)"
  64. >delete_forever</i
  65. >
  66. </div>
  67. </div>
  68. </div>
  69. <div class="media-right">
  70. {{ utils.formatTime(song.duration) }}
  71. </div>
  72. </article>
  73. <div
  74. v-if="
  75. station.type === 'community' &&
  76. loggedIn &&
  77. station.partyMode === true
  78. "
  79. >
  80. <button
  81. v-if="
  82. (station.locked && isOwnerOnly()) ||
  83. !station.locked ||
  84. (station.locked &&
  85. isAdminOnly() &&
  86. dismissedWarning)
  87. "
  88. class="button add-to-queue"
  89. @click="
  90. openModal({
  91. sector: 'station',
  92. modal: 'addSongToQueue'
  93. })
  94. "
  95. >
  96. Add Song to Queue
  97. </button>
  98. <button
  99. v-if="
  100. station.locked &&
  101. isAdminOnly() &&
  102. !isOwnerOnly() &&
  103. !dismissedWarning
  104. "
  105. class="button add-to-queue add-to-queue-warning"
  106. @click="dismissedWarning = true"
  107. >
  108. THIS STATION'S QUEUE IS LOCKED.
  109. </button>
  110. <button
  111. v-if="station.locked && !isAdminOnly() && !isOwnerOnly()"
  112. class="button add-to-queue add-to-queue-disabled"
  113. >
  114. THIS STATION'S QUEUE IS LOCKED.
  115. </button>
  116. </div>
  117. </template>
  118. </sidebar>
  119. </template>
  120. <script>
  121. import { mapState, mapActions } from "vuex";
  122. import Toast from "toasters";
  123. import utils from "../../js/utils";
  124. import Sidebar from "./Sidebar.vue";
  125. import UserIdToUsername from "../UserIdToUsername.vue";
  126. export default {
  127. data() {
  128. return {
  129. utils,
  130. dismissedWarning: false
  131. };
  132. },
  133. computed: mapState({
  134. loggedIn: state => state.user.auth.loggedIn,
  135. userId: state => state.user.auth.userId,
  136. role: state => state.user.auth.role,
  137. station: state => state.station.station,
  138. currentSong: state => state.station.currentSong,
  139. songsList: state => state.station.songsList,
  140. noSong: state => state.station.noSong
  141. }),
  142. methods: {
  143. isOwnerOnly() {
  144. return this.loggedIn && this.userId === this.station.owner;
  145. },
  146. isAdminOnly() {
  147. return this.loggedIn && this.role === "admin";
  148. },
  149. removeFromQueue(songId) {
  150. window.socket.emit(
  151. "stations.removeFromQueue",
  152. this.station._id,
  153. songId,
  154. res => {
  155. if (res.status === "success") {
  156. new Toast({
  157. content:
  158. "Successfully removed song from the queue.",
  159. timeout: 4000
  160. });
  161. } else new Toast({ content: res.message, timeout: 8000 });
  162. }
  163. );
  164. },
  165. ...mapActions("modals", ["openModal"])
  166. },
  167. components: { UserIdToUsername, Sidebar }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. @import "styles/global.scss";
  172. .inner-wrapper {
  173. overflow: auto;
  174. height: 100%;
  175. }
  176. .media {
  177. padding: 0 25px;
  178. }
  179. .media.is-playing {
  180. background-color: $musareBlue;
  181. color: white;
  182. }
  183. .media-content .content {
  184. min-height: 64px;
  185. display: flex;
  186. align-items: center;
  187. color: inherit;
  188. }
  189. .content p strong {
  190. word-break: break-word;
  191. }
  192. .content p small {
  193. word-break: break-word;
  194. }
  195. .add-to-queue {
  196. width: 100%;
  197. margin-top: 25px;
  198. height: 40px;
  199. border-radius: 0;
  200. background: rgb(3, 169, 244);
  201. color: $white !important;
  202. border: 0;
  203. &:active,
  204. &:focus {
  205. border: 0;
  206. }
  207. }
  208. .add-to-queue.add-to-queue-warning {
  209. background-color: red;
  210. }
  211. .add-to-queue.add-to-queue-disabled {
  212. background-color: gray;
  213. }
  214. .add-to-queue.add-to-queue-disabled:focus {
  215. background-color: gray;
  216. }
  217. .add-to-queue:focus {
  218. background: $primary-color;
  219. }
  220. .media-right {
  221. line-height: 64px;
  222. }
  223. .songTitle {
  224. word-wrap: break-word;
  225. overflow: hidden;
  226. text-overflow: ellipsis;
  227. display: -webkit-box;
  228. -webkit-box-orient: vertical;
  229. -webkit-line-clamp: 2;
  230. line-height: 20px;
  231. max-height: 40px;
  232. }
  233. </style>