SongsList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 "toasters";
  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. new Toast({
  159. content:
  160. "Successfully removed song from the queue.",
  161. timeout: 4000
  162. });
  163. } else new Toast({ content: res.message, timeout: 8000 });
  164. }
  165. );
  166. },
  167. ...mapActions("modals", ["openModal"])
  168. },
  169. mounted() {
  170. /*
  171. io.getSocket((socket) => {
  172. this.socket = socket;
  173. }); */
  174. },
  175. components: { UserIdToUsername }
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. @import "styles/global.scss";
  180. .sidebar {
  181. position: fixed;
  182. z-index: 1;
  183. top: 0;
  184. right: 0;
  185. width: 300px;
  186. height: 100vh;
  187. background-color: $white;
  188. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  189. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  190. }
  191. .inner-wrapper {
  192. top: 60px;
  193. position: relative;
  194. overflow: auto;
  195. height: 100%;
  196. }
  197. .slide-transition {
  198. transition: transform 0.6s ease-in-out;
  199. transform: translateX(0);
  200. }
  201. .slide-enter,
  202. .slide-leave {
  203. transform: translateX(100%);
  204. }
  205. .title {
  206. background-color: rgb(3, 169, 244);
  207. text-align: center;
  208. padding: 10px;
  209. color: $white;
  210. font-weight: 600;
  211. }
  212. .media {
  213. padding: 0 25px;
  214. }
  215. .media-content .content {
  216. min-height: 64px;
  217. display: flex;
  218. align-items: center;
  219. }
  220. .content p strong {
  221. word-break: break-word;
  222. }
  223. .content p small {
  224. word-break: break-word;
  225. }
  226. .add-to-queue {
  227. width: 100%;
  228. margin-top: 25px;
  229. height: 40px;
  230. border-radius: 0;
  231. background: rgb(3, 169, 244);
  232. color: $white !important;
  233. border: 0;
  234. &:active,
  235. &:focus {
  236. border: 0;
  237. }
  238. }
  239. .add-to-queue.add-to-queue-warning {
  240. background-color: red;
  241. }
  242. .add-to-queue.add-to-queue-disabled {
  243. background-color: gray;
  244. }
  245. .add-to-queue.add-to-queue-disabled:focus {
  246. background-color: gray;
  247. }
  248. .add-to-queue:focus {
  249. background: $primary-color;
  250. }
  251. .media-right {
  252. line-height: 64px;
  253. }
  254. .songTitle {
  255. word-wrap: break-word;
  256. overflow: hidden;
  257. text-overflow: ellipsis;
  258. display: -webkit-box;
  259. -webkit-box-orient: vertical;
  260. -webkit-line-clamp: 2;
  261. line-height: 20px;
  262. max-height: 40px;
  263. }
  264. </style>