SongsList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 v-for="song in songsList" :key="song.songId" class="media">
  38. <div class="media-content">
  39. <div
  40. class="content"
  41. style="display: block;padding-top: 10px;"
  42. >
  43. <strong class="songTitle">{{ song.title }}</strong>
  44. <small>{{ song.artists.join(", ") }}</small>
  45. <div
  46. v-if="
  47. station.type === 'community' &&
  48. station.partyMode === true
  49. "
  50. >
  51. <small>
  52. Requested by
  53. <b>
  54. <user-id-to-username
  55. :userId="song.requestedBy"
  56. :link="true"
  57. />
  58. </b>
  59. </small>
  60. <i
  61. v-if="isOwnerOnly() || isAdminOnly()"
  62. class="material-icons"
  63. style="vertical-align: middle;"
  64. @click="removeFromQueue(song.songId)"
  65. >delete_forever</i
  66. >
  67. </div>
  68. </div>
  69. </div>
  70. <div class="media-right">
  71. {{ utils.formatTime(song.duration) }}
  72. </div>
  73. </article>
  74. <div
  75. v-if="
  76. station.type === 'community' &&
  77. loggedIn &&
  78. station.partyMode === true
  79. "
  80. >
  81. <button
  82. v-if="
  83. (station.locked && isOwnerOnly()) ||
  84. !station.locked ||
  85. (station.locked &&
  86. isAdminOnly() &&
  87. dismissedWarning)
  88. "
  89. class="button add-to-queue"
  90. @click="
  91. openModal({
  92. sector: 'station',
  93. modal: 'addSongToQueue'
  94. })
  95. "
  96. >
  97. Add Song to Queue
  98. </button>
  99. <button
  100. v-if="
  101. station.locked &&
  102. isAdminOnly() &&
  103. !isOwnerOnly() &&
  104. !dismissedWarning
  105. "
  106. class="button add-to-queue add-to-queue-warning"
  107. @click="dismissedWarning = true"
  108. >
  109. THIS STATION'S QUEUE IS LOCKED.
  110. </button>
  111. <button
  112. v-if="station.locked && !isAdminOnly() && !isOwnerOnly()"
  113. class="button add-to-queue add-to-queue-disabled"
  114. >
  115. THIS STATION'S QUEUE IS LOCKED.
  116. </button>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { mapState, mapActions } from "vuex";
  123. import Toast from "toasters";
  124. import utils from "../../js/utils";
  125. import UserIdToUsername from "../UserIdToUsername.vue";
  126. export default {
  127. data() {
  128. return {
  129. utils,
  130. dismissedWarning: false
  131. };
  132. },
  133. computed: mapState({
  134. loggedIn: state => state.user.auth.loggedIn,
  135. userId: state => state.user.auth.userId,
  136. role: state => state.user.auth.role,
  137. station: state => state.station.station,
  138. currentSong: state => state.station.currentSong,
  139. songsList: state => state.station.songsList,
  140. noSong: state => state.station.noSong
  141. }),
  142. methods: {
  143. isOwnerOnly() {
  144. return this.loggedIn && this.userId === this.station.owner;
  145. },
  146. isAdminOnly() {
  147. return this.loggedIn && this.role === "admin";
  148. },
  149. removeFromQueue(songId) {
  150. window.socket.emit(
  151. "stations.removeFromQueue",
  152. this.station._id,
  153. songId,
  154. res => {
  155. if (res.status === "success") {
  156. new Toast({
  157. content:
  158. "Successfully removed song from the queue.",
  159. timeout: 4000
  160. });
  161. } else new Toast({ content: res.message, timeout: 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. @import "styles/global.scss";
  178. .night-mode {
  179. .sidebar {
  180. background-color: $night-mode-secondary;
  181. .title {
  182. color: #fff;
  183. }
  184. * {
  185. color: #ddd;
  186. }
  187. }
  188. }
  189. .sidebar {
  190. position: fixed;
  191. z-index: 1;
  192. top: 0;
  193. right: 0;
  194. width: 300px;
  195. height: 100vh;
  196. background-color: $white;
  197. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  198. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  199. }
  200. .inner-wrapper {
  201. top: 60px;
  202. position: relative;
  203. overflow: auto;
  204. height: 100%;
  205. }
  206. .slide-transition {
  207. transition: transform 0.6s ease-in-out;
  208. transform: translateX(0);
  209. }
  210. .slide-enter,
  211. .slide-leave {
  212. transform: translateX(100%);
  213. }
  214. .title {
  215. background-color: rgb(3, 169, 244);
  216. text-align: center;
  217. padding: 10px;
  218. color: $white;
  219. font-weight: 600;
  220. }
  221. .media {
  222. padding: 0 25px;
  223. }
  224. .media-content .content {
  225. min-height: 64px;
  226. display: flex;
  227. align-items: center;
  228. }
  229. .content p strong {
  230. word-break: break-word;
  231. }
  232. .content p small {
  233. word-break: break-word;
  234. }
  235. .add-to-queue {
  236. width: 100%;
  237. margin-top: 25px;
  238. height: 40px;
  239. border-radius: 0;
  240. background: rgb(3, 169, 244);
  241. color: $white !important;
  242. border: 0;
  243. &:active,
  244. &:focus {
  245. border: 0;
  246. }
  247. }
  248. .add-to-queue.add-to-queue-warning {
  249. background-color: red;
  250. }
  251. .add-to-queue.add-to-queue-disabled {
  252. background-color: gray;
  253. }
  254. .add-to-queue.add-to-queue-disabled:focus {
  255. background-color: gray;
  256. }
  257. .add-to-queue:focus {
  258. background: $primary-color;
  259. }
  260. .media-right {
  261. line-height: 64px;
  262. }
  263. .songTitle {
  264. word-wrap: break-word;
  265. overflow: hidden;
  266. text-overflow: ellipsis;
  267. display: -webkit-box;
  268. -webkit-box-orient: vertical;
  269. -webkit-line-clamp: 2;
  270. line-height: 20px;
  271. max-height: 40px;
  272. }
  273. </style>