SongsList.vue 5.5 KB

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