SongsList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <div class="sidebar" transition="slide">
  3. <div class="inner-wrapper">
  4. <div v-if="station.type === 'community'" class="sidebar-title">
  5. Queue
  6. </div>
  7. <div v-else class="sidebar-title">Playlist</div>
  8. <article v-if="!noSong" class="media">
  9. <figure v-if="currentSong.thumbnail" class="media-left">
  10. <p class="image is-64x64">
  11. <img
  12. :src="currentSong.thumbnail"
  13. onerror="this.src='/assets/notes-transparent.png'"
  14. />
  15. </p>
  16. </figure>
  17. <div class="media-content">
  18. <div class="content">
  19. <p>
  20. Current Song:
  21. <strong>{{ currentSong.title }}</strong>
  22. <br />
  23. <small>{{ currentSong.artists }}</small>
  24. </p>
  25. </div>
  26. </div>
  27. <div class="media-right">
  28. {{ utils.formatTime(currentSong.duration) }}
  29. </div>
  30. </article>
  31. <p v-if="noSong" class="has-text-centered">
  32. There is currently no song playing.
  33. </p>
  34. <hr v-if="noSong" />
  35. <article
  36. v-for="song in songsList"
  37. :key="song.songId"
  38. class="media"
  39. :class="{ 'is-playing': currentSong.songId === song.songId }"
  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. station.type === 'community' &&
  51. 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. {{ utils.formatTime(song.duration) }}
  75. </div>
  76. </article>
  77. <div
  78. v-if="
  79. station.type === 'community' &&
  80. loggedIn &&
  81. station.partyMode === true
  82. "
  83. >
  84. <button
  85. v-if="
  86. (station.locked && isOwnerOnly()) ||
  87. !station.locked ||
  88. (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. 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="station.locked && !isAdminOnly() && !isOwnerOnly()"
  116. class="button add-to-queue add-to-queue-disabled"
  117. >
  118. THIS STATION'S QUEUE IS LOCKED.
  119. </button>
  120. </div>
  121. </div>
  122. </div>
  123. </template>
  124. <script>
  125. import { mapState, mapActions } from "vuex";
  126. import Toast from "toasters";
  127. import utils from "../../js/utils";
  128. import UserIdToUsername from "../UserIdToUsername.vue";
  129. export default {
  130. data() {
  131. return {
  132. utils,
  133. dismissedWarning: false
  134. };
  135. },
  136. computed: mapState({
  137. loggedIn: state => state.user.auth.loggedIn,
  138. userId: state => state.user.auth.userId,
  139. role: state => state.user.auth.role,
  140. station: state => state.station.station,
  141. currentSong: state => state.station.currentSong,
  142. songsList: state => state.station.songsList,
  143. noSong: state => state.station.noSong
  144. }),
  145. methods: {
  146. isOwnerOnly() {
  147. return this.loggedIn && this.userId === this.station.owner;
  148. },
  149. isAdminOnly() {
  150. return this.loggedIn && this.role === "admin";
  151. },
  152. removeFromQueue(songId) {
  153. window.socket.emit(
  154. "stations.removeFromQueue",
  155. this.station._id,
  156. songId,
  157. res => {
  158. if (res.status === "success") {
  159. new Toast({
  160. content:
  161. "Successfully removed song from the queue.",
  162. timeout: 4000
  163. });
  164. } else new Toast({ content: res.message, timeout: 8000 });
  165. }
  166. );
  167. },
  168. ...mapActions("modals", ["openModal"])
  169. },
  170. mounted() {
  171. /*
  172. io.getSocket((socket) => {
  173. this.socket = socket;
  174. }); */
  175. },
  176. components: { UserIdToUsername }
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. @import "styles/global.scss";
  181. .night-mode {
  182. .sidebar {
  183. background-color: $night-mode-secondary;
  184. .sidebar-title {
  185. color: #fff;
  186. }
  187. * {
  188. color: #ddd;
  189. }
  190. }
  191. }
  192. .inner-wrapper {
  193. overflow: auto;
  194. height: 100%;
  195. }
  196. .sidebar-title {
  197. background-color: rgb(3, 169, 244);
  198. text-align: center;
  199. padding: 10px;
  200. color: $white;
  201. font-weight: 600;
  202. font-size: 20px;
  203. }
  204. .media {
  205. padding: 0 25px;
  206. }
  207. .media.is-playing {
  208. background-color: $musareBlue;
  209. color: white;
  210. }
  211. .media-content .content {
  212. min-height: 64px;
  213. display: flex;
  214. align-items: center;
  215. color: inherit;
  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: $white !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: $primary-color;
  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>