SongsList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. <user-id-to-username
  58. :userId="song.requestedBy"
  59. :link="true"
  60. />
  61. </b>
  62. </small>
  63. <i
  64. v-if="isOwnerOnly() || isAdminOnly()"
  65. class="material-icons"
  66. style="vertical-align: middle;"
  67. @click="removeFromQueue(song.songId)"
  68. >delete_forever</i
  69. >
  70. </div>
  71. </div>
  72. </div>
  73. <div class="media-right">
  74. {{ $parent.formatTime(song.duration) }}
  75. </div>
  76. </article>
  77. <div
  78. v-if="
  79. $parent.type === 'community' &&
  80. loggedIn &&
  81. $parent.station.partyMode === true
  82. "
  83. >
  84. <button
  85. v-if="
  86. ($parent.station.locked && isOwnerOnly()) ||
  87. !$parent.station.locked ||
  88. ($parent.station.locked &&
  89. isAdminOnly() &&
  90. dismissedWarning)
  91. "
  92. class="button add-to-queue"
  93. @click="
  94. openModal({
  95. sector: 'station',
  96. modal: 'addSongToQueue'
  97. })
  98. "
  99. >
  100. Add Song to Queue
  101. </button>
  102. <button
  103. v-if="
  104. $parent.station.locked &&
  105. isAdminOnly() &&
  106. !isOwnerOnly() &&
  107. !dismissedWarning
  108. "
  109. class="button add-to-queue add-to-queue-warning"
  110. @click="dismissedWarning = true"
  111. >
  112. THIS STATION'S QUEUE IS LOCKED.
  113. </button>
  114. <button
  115. v-if="
  116. $parent.station.locked &&
  117. !isAdminOnly() &&
  118. !isOwnerOnly()
  119. "
  120. class="button add-to-queue add-to-queue-disabled"
  121. >
  122. THIS STATION'S QUEUE IS LOCKED.
  123. </button>
  124. </div>
  125. </div>
  126. </div>
  127. </template>
  128. <script>
  129. import { mapState, mapActions } from "vuex";
  130. import { Toast } from "vue-roaster";
  131. import UserIdToUsername from "../UserIdToUsername.vue";
  132. export default {
  133. data() {
  134. return {
  135. dismissedWarning: false
  136. };
  137. },
  138. computed: mapState({
  139. loggedIn: state => state.user.auth.loggedIn,
  140. userId: state => state.user.auth.userId,
  141. role: state => state.user.auth.role
  142. }),
  143. methods: {
  144. isOwnerOnly() {
  145. return this.loggedIn && this.userId === this.$parent.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.$parent.station._id,
  154. songId,
  155. res => {
  156. if (res.status === "success") {
  157. Toast.methods.addToast(
  158. "Successfully removed song from the queue.",
  159. 4000
  160. );
  161. } else Toast.methods.addToast(res.message, 8000);
  162. }
  163. );
  164. },
  165. ...mapActions("modals", ["openModal"])
  166. },
  167. mounted() {
  168. /*
  169. io.getSocket((socket) => {
  170. this.socket = socket;
  171. }); */
  172. },
  173. components: { UserIdToUsername }
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. .sidebar {
  178. position: fixed;
  179. z-index: 1;
  180. top: 0;
  181. right: 0;
  182. width: 300px;
  183. height: 100vh;
  184. background-color: #fff;
  185. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  186. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  187. }
  188. .inner-wrapper {
  189. top: 60px;
  190. position: relative;
  191. overflow: auto;
  192. height: 100%;
  193. }
  194. .slide-transition {
  195. transition: transform 0.6s ease-in-out;
  196. transform: translateX(0);
  197. }
  198. .slide-enter,
  199. .slide-leave {
  200. transform: translateX(100%);
  201. }
  202. .title {
  203. background-color: rgb(3, 169, 244);
  204. text-align: center;
  205. padding: 10px;
  206. color: white;
  207. font-weight: 600;
  208. }
  209. .media {
  210. padding: 0 25px;
  211. }
  212. .media-content .content {
  213. min-height: 64px;
  214. display: flex;
  215. align-items: center;
  216. }
  217. .content p strong {
  218. word-break: break-word;
  219. }
  220. .content p small {
  221. word-break: break-word;
  222. }
  223. .add-to-queue {
  224. width: 100%;
  225. margin-top: 25px;
  226. height: 40px;
  227. border-radius: 0;
  228. background: rgb(3, 169, 244);
  229. color: #fff !important;
  230. border: 0;
  231. &:active,
  232. &:focus {
  233. border: 0;
  234. }
  235. }
  236. .add-to-queue.add-to-queue-warning {
  237. background-color: red;
  238. }
  239. .add-to-queue.add-to-queue-disabled {
  240. background-color: gray;
  241. }
  242. .add-to-queue.add-to-queue-disabled:focus {
  243. background-color: gray;
  244. }
  245. .add-to-queue:focus {
  246. background: #029ce3;
  247. }
  248. .media-right {
  249. line-height: 64px;
  250. }
  251. .songTitle {
  252. word-wrap: break-word;
  253. overflow: hidden;
  254. text-overflow: ellipsis;
  255. display: -webkit-box;
  256. -webkit-box-orient: vertical;
  257. -webkit-line-clamp: 2;
  258. line-height: 20px;
  259. max-height: 40px;
  260. }
  261. </style>