SongsList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <sidebar :title="station.type === 'community' ? 'Queue' : 'Playlist'">
  3. <template #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. :user-id="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 "../../components/Sidebar.vue";
  125. import UserIdToUsername from "../../components/common/UserIdToUsername.vue";
  126. export default {
  127. components: { UserIdToUsername, Sidebar },
  128. data() {
  129. return {
  130. utils,
  131. dismissedWarning: false
  132. };
  133. },
  134. computed: mapState({
  135. loggedIn: state => state.user.auth.loggedIn,
  136. userId: state => state.user.auth.userId,
  137. role: state => state.user.auth.role,
  138. station: state => state.station.station,
  139. currentSong: state => state.station.currentSong,
  140. songsList: state => state.station.songsList,
  141. noSong: state => state.station.noSong
  142. }),
  143. methods: {
  144. isOwnerOnly() {
  145. return this.loggedIn && this.userId === this.station.owner;
  146. },
  147. isAdminOnly() {
  148. return this.loggedIn && this.role === "admin";
  149. },
  150. removeFromQueue(songId) {
  151. window.socket.emit(
  152. "stations.removeFromQueue",
  153. this.station._id,
  154. songId,
  155. res => {
  156. if (res.status === "success") {
  157. new Toast({
  158. content:
  159. "Successfully removed song from the queue.",
  160. timeout: 4000
  161. });
  162. } else new Toast({ content: res.message, timeout: 8000 });
  163. }
  164. );
  165. },
  166. ...mapActions("modals", ["openModal"])
  167. }
  168. };
  169. </script>
  170. <style lang="scss" scoped>
  171. @import "../../styles/global.scss";
  172. .media {
  173. padding: 0 25px;
  174. }
  175. .media.is-playing {
  176. background-color: $musare-blue;
  177. color: white;
  178. }
  179. .media-content .content {
  180. min-height: 64px;
  181. display: flex;
  182. align-items: center;
  183. color: inherit;
  184. }
  185. .content p strong {
  186. word-break: break-word;
  187. }
  188. .content p small {
  189. word-break: break-word;
  190. }
  191. .add-to-queue {
  192. width: 100%;
  193. margin-top: 25px;
  194. height: 40px;
  195. border-radius: 0;
  196. background: rgb(3, 169, 244);
  197. color: $white !important;
  198. border: 0;
  199. &:active,
  200. &:focus {
  201. border: 0;
  202. }
  203. }
  204. .add-to-queue.add-to-queue-warning {
  205. background-color: red;
  206. }
  207. .add-to-queue.add-to-queue-disabled {
  208. background-color: gray;
  209. }
  210. .add-to-queue.add-to-queue-disabled:focus {
  211. background-color: gray;
  212. }
  213. .add-to-queue:focus {
  214. background: $primary-color;
  215. }
  216. .media-right {
  217. line-height: 64px;
  218. }
  219. .songTitle {
  220. word-wrap: break-word;
  221. overflow: hidden;
  222. text-overflow: ellipsis;
  223. display: -webkit-box;
  224. -webkit-box-orient: vertical;
  225. -webkit-line-clamp: 2;
  226. line-height: 20px;
  227. max-height: 40px;
  228. }
  229. </style>