SongsList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="sidebar" transition="slide">
  3. <div class="inner-wrapper">
  4. <div v-if="$parent.type === 'community'" class="title">
  5. Queue
  6. </div>
  7. <div v-else class="title">
  8. Playlist
  9. </div>
  10. <article v-if="!$parent.noSong" class="media">
  11. <figure v-if="$parent.currentSong.thumbnail" class="media-left">
  12. <p class="image is-64x64">
  13. <img
  14. :src="$parent.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>{{ $parent.currentSong.title }}</strong>
  24. <br />
  25. <small>{{ $parent.currentSong.artists }}</small>
  26. </p>
  27. </div>
  28. </div>
  29. <div class="media-right">
  30. {{ $parent.formatTime($parent.currentSong.duration) }}
  31. </div>
  32. </article>
  33. <p v-if="$parent.noSong" class="center">
  34. There is currently no song playing.
  35. </p>
  36. <article
  37. v-for="(song, index) in $parent.songsList"
  38. :key="index"
  39. class="media"
  40. >
  41. <div class="media-content">
  42. <div
  43. class="content"
  44. style="display: block;padding-top: 10px;"
  45. >
  46. <strong class="songTitle">{{ song.title }}</strong>
  47. <small>{{ song.artists.join(", ") }}</small>
  48. <div
  49. v-if="
  50. $parent.type === 'community' &&
  51. $parent.station.partyMode === true
  52. "
  53. >
  54. <small>
  55. Requested by
  56. <b
  57. >{{
  58. $parent.$parent.getUsernameFromId(
  59. song.requestedBy
  60. )
  61. }}
  62. {{ userIdMap["Z" + song.requestedBy] }}</b
  63. >
  64. </small>
  65. <i
  66. v-if="isOwnerOnly() || isAdminOnly()"
  67. class="material-icons"
  68. style="vertical-align: middle;"
  69. @click="removeFromQueue(song.songId)"
  70. >delete_forever</i
  71. >
  72. </div>
  73. </div>
  74. </div>
  75. <div class="media-right">
  76. {{ $parent.formatTime(song.duration) }}
  77. </div>
  78. </article>
  79. <div
  80. v-if="
  81. $parent.type === 'community' &&
  82. $parent.$parent.loggedIn &&
  83. $parent.station.partyMode === true
  84. "
  85. >
  86. <button
  87. v-if="
  88. ($parent.station.locked && isOwnerOnly()) ||
  89. !$parent.station.locked ||
  90. ($parent.station.locked &&
  91. isAdminOnly() &&
  92. dismissedWarning)
  93. "
  94. class="button add-to-queue"
  95. @click="
  96. toggleModal({
  97. sector: 'station',
  98. modal: 'addSongToQueue'
  99. })
  100. "
  101. >
  102. Add Song to Queue
  103. </button>
  104. <button
  105. v-if="
  106. $parent.station.locked &&
  107. isAdminOnly() &&
  108. !isOwnerOnly() &&
  109. !dismissedWarning
  110. "
  111. class="button add-to-queue add-to-queue-warning"
  112. @click="dismissedWarning = true"
  113. >
  114. THIS STATION'S QUEUE IS LOCKED.
  115. </button>
  116. <button
  117. v-if="
  118. $parent.station.locked &&
  119. !isAdminOnly() &&
  120. !isOwnerOnly()
  121. "
  122. class="button add-to-queue add-to-queue-disabled"
  123. >
  124. THIS STATION'S QUEUE IS LOCKED.
  125. </button>
  126. </div>
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. import { mapActions } from "vuex";
  132. import { Toast } from "vue-roaster";
  133. export default {
  134. data: function() {
  135. return {
  136. dismissedWarning: false,
  137. userIdMap: this.$parent.$parent.userIdMap
  138. };
  139. },
  140. methods: {
  141. isOwnerOnly: function() {
  142. return (
  143. this.$parent.$parent.loggedIn &&
  144. this.$parent.$parent.userId === this.$parent.station.owner
  145. );
  146. },
  147. isAdminOnly: function() {
  148. return (
  149. this.$parent.$parent.loggedIn &&
  150. this.$parent.$parent.role === "admin"
  151. );
  152. },
  153. removeFromQueue: function(songId) {
  154. window.socket.emit(
  155. "stations.removeFromQueue",
  156. this.$parent.station._id,
  157. songId,
  158. res => {
  159. if (res.status === "success") {
  160. Toast.methods.addToast(
  161. "Successfully removed song from the queue.",
  162. 4000
  163. );
  164. } else Toast.methods.addToast(res.message, 8000);
  165. }
  166. );
  167. },
  168. ...mapActions("modals", ["toggleModal"])
  169. },
  170. mounted: function() {
  171. /*let _this = this;
  172. io.getSocket((socket) => {
  173. _this.socket = socket;
  174. });*/
  175. }
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .sidebar {
  180. position: fixed;
  181. z-index: 1;
  182. top: 0;
  183. right: 0;
  184. width: 300px;
  185. height: 100vh;
  186. background-color: #fff;
  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: 64px;
  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: #fff !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: #029ce3;
  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>