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. {{ utils.formatTime(currentSong.duration) }}
  31. </div>
  32. </article>
  33. <p v-if="noSong" class="center">
  34. There is currently no song playing.
  35. </p>
  36. <hr v-if="noSong" />
  37. <article
  38. v-for="song in songsList"
  39. :key="song.songId"
  40. class="media"
  41. :class="{ 'is-playing': currentSong.songId === song.songId }"
  42. >
  43. <div class="media-content">
  44. <div
  45. class="content"
  46. style="display: block;padding-top: 10px;"
  47. >
  48. <strong class="songTitle">{{ song.title }}</strong>
  49. <small>{{ song.artists.join(", ") }}</small>
  50. <div
  51. v-if="
  52. station.type === 'community' &&
  53. station.partyMode === true
  54. "
  55. >
  56. <small>
  57. Requested by
  58. <b>
  59. <user-id-to-username
  60. :userId="song.requestedBy"
  61. :link="true"
  62. />
  63. </b>
  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. {{ utils.formatTime(song.duration) }}
  77. </div>
  78. </article>
  79. <div
  80. v-if="
  81. station.type === 'community' &&
  82. loggedIn &&
  83. station.partyMode === true
  84. "
  85. >
  86. <button
  87. v-if="
  88. (station.locked && isOwnerOnly()) ||
  89. !station.locked ||
  90. (station.locked &&
  91. isAdminOnly() &&
  92. dismissedWarning)
  93. "
  94. class="button add-to-queue"
  95. @click="
  96. openModal({
  97. sector: 'station',
  98. modal: 'addSongToQueue'
  99. })
  100. "
  101. >
  102. Add Song to Queue
  103. </button>
  104. <button
  105. v-if="
  106. 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="station.locked && !isAdminOnly() && !isOwnerOnly()"
  118. class="button add-to-queue add-to-queue-disabled"
  119. >
  120. THIS STATION'S QUEUE IS LOCKED.
  121. </button>
  122. </div>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import { mapState, mapActions } from "vuex";
  128. import Toast from "toasters";
  129. import utils from "../../js/utils";
  130. import UserIdToUsername from "../UserIdToUsername.vue";
  131. export default {
  132. data() {
  133. return {
  134. utils,
  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. station: state => state.station.station,
  143. currentSong: state => state.station.currentSong,
  144. songsList: state => state.station.songsList,
  145. noSong: state => state.station.noSong
  146. }),
  147. methods: {
  148. isOwnerOnly() {
  149. return this.loggedIn && this.userId === this.station.owner;
  150. },
  151. isAdminOnly() {
  152. return this.loggedIn && this.role === "admin";
  153. },
  154. removeFromQueue(songId) {
  155. window.socket.emit(
  156. "stations.removeFromQueue",
  157. this.station._id,
  158. songId,
  159. res => {
  160. if (res.status === "success") {
  161. new Toast({
  162. content:
  163. "Successfully removed song from the queue.",
  164. timeout: 4000
  165. });
  166. } else new Toast({ content: res.message, timeout: 8000 });
  167. }
  168. );
  169. },
  170. ...mapActions("modals", ["openModal"])
  171. },
  172. mounted() {
  173. /*
  174. io.getSocket((socket) => {
  175. this.socket = socket;
  176. }); */
  177. },
  178. components: { UserIdToUsername }
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. @import "styles/global.scss";
  183. .night-mode {
  184. .sidebar {
  185. background-color: $night-mode-secondary;
  186. .title {
  187. color: #fff;
  188. }
  189. * {
  190. color: #ddd;
  191. }
  192. }
  193. }
  194. .inner-wrapper {
  195. overflow: auto;
  196. height: 100%;
  197. }
  198. .title {
  199. background-color: rgb(3, 169, 244);
  200. text-align: center;
  201. padding: 10px;
  202. color: $white;
  203. font-weight: 600;
  204. }
  205. .media {
  206. padding: 0 25px;
  207. }
  208. .media.is-playing {
  209. background-color: $musareBlue;
  210. color: white;
  211. }
  212. .media-content .content {
  213. min-height: 64px;
  214. display: flex;
  215. align-items: center;
  216. color: inherit;
  217. }
  218. .content p strong {
  219. word-break: break-word;
  220. }
  221. .content p small {
  222. word-break: break-word;
  223. }
  224. .add-to-queue {
  225. width: 100%;
  226. margin-top: 25px;
  227. height: 40px;
  228. border-radius: 0;
  229. background: rgb(3, 169, 244);
  230. color: $white !important;
  231. border: 0;
  232. &:active,
  233. &:focus {
  234. border: 0;
  235. }
  236. }
  237. .add-to-queue.add-to-queue-warning {
  238. background-color: red;
  239. }
  240. .add-to-queue.add-to-queue-disabled {
  241. background-color: gray;
  242. }
  243. .add-to-queue.add-to-queue-disabled:focus {
  244. background-color: gray;
  245. }
  246. .add-to-queue:focus {
  247. background: $primary-color;
  248. }
  249. .media-right {
  250. line-height: 64px;
  251. }
  252. .songTitle {
  253. word-wrap: break-word;
  254. overflow: hidden;
  255. text-overflow: ellipsis;
  256. display: -webkit-box;
  257. -webkit-box-orient: vertical;
  258. -webkit-line-clamp: 2;
  259. line-height: 20px;
  260. max-height: 40px;
  261. }
  262. </style>