QueueItem.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div class="queue-item">
  3. <div id="thumbnail-and-info">
  4. <img
  5. id="thumbnail"
  6. :src="song.ytThumbnail ? song.ytThumbnail : song.thumbnail"
  7. onerror="this.src='/assets/notes-transparent.png'"
  8. />
  9. <div id="song-info">
  10. <h4
  11. id="song-title"
  12. :style="
  13. song.artists.length < 1 ? { fontSize: '16px' } : null
  14. "
  15. :title="song.title"
  16. >
  17. {{ song.title }}
  18. </h4>
  19. <h5
  20. id="song-artists"
  21. v-if="song.artists"
  22. :title="song.artists.join(', ')"
  23. >
  24. {{ song.artists.join(", ") }}
  25. </h5>
  26. <p
  27. id="song-request-time"
  28. v-if="
  29. station.type === 'community' &&
  30. station.partyMode === true
  31. "
  32. >
  33. Requested by
  34. <strong>
  35. <user-id-to-username
  36. :user-id="song.requestedBy"
  37. :link="true"
  38. />
  39. {{
  40. formatDistance(
  41. parseISO(song.requestedAt),
  42. new Date(),
  43. {
  44. addSuffix: true
  45. }
  46. )
  47. }}
  48. </strong>
  49. </p>
  50. </div>
  51. </div>
  52. <div id="duration-and-actions">
  53. <p id="song-duration">
  54. {{ utils.formatTime(song.duration) }}
  55. </p>
  56. <div id="queue-item-buttons">
  57. <i
  58. v-if="
  59. $parent.loggedIn &&
  60. !song.simpleSong &&
  61. song.likes !== -1 &&
  62. song.dislikes !== -1
  63. "
  64. class="material-icons"
  65. id="report-queue-item"
  66. @click="reportQueueSong(song)"
  67. >flag</i
  68. >
  69. <i
  70. v-if="
  71. $parent.isAdminOnly() &&
  72. !song.simpleSong &&
  73. song.likes !== -1 &&
  74. song.dislikes !== -1
  75. "
  76. class="material-icons"
  77. id="edit-queue-item"
  78. @click="$parent.$parent.$parent.editSong(song)"
  79. >edit</i
  80. >
  81. <i
  82. v-if="
  83. station.type === 'community' &&
  84. ($parent.isOwnerOnly() || $parent.isAdminOnly())
  85. "
  86. class="material-icons"
  87. id="remove-queue-item"
  88. @click="$parent.removeFromQueue(song.songId)"
  89. >delete_forever</i
  90. >
  91. </div>
  92. </div>
  93. </div>
  94. </template>
  95. <script>
  96. import { mapActions } from "vuex";
  97. import { formatDistance, parseISO } from "date-fns";
  98. import UserIdToUsername from "../../../../../components/common/UserIdToUsername.vue";
  99. import utils from "../../../../../../js/utils";
  100. export default {
  101. components: { UserIdToUsername },
  102. props: {
  103. song: {
  104. type: Object,
  105. default: () => {}
  106. },
  107. station: {
  108. type: Object,
  109. default: () => {
  110. return { type: "community", partyMode: false };
  111. }
  112. }
  113. },
  114. data() {
  115. return {
  116. utils
  117. };
  118. },
  119. methods: {
  120. reportQueueSong(song) {
  121. this.updateReportQueueSong(song);
  122. this.openModal({ sector: "station", modal: "report" });
  123. },
  124. ...mapActions("station", ["updateReportQueueSong"]),
  125. ...mapActions("modalVisibility", ["openModal"]),
  126. formatDistance,
  127. parseISO
  128. }
  129. };
  130. </script>
  131. <style lang="scss" scoped>
  132. @import "../../../../../styles/global.scss";
  133. .night-mode {
  134. .queue-item {
  135. background-color: $dark-grey-2 !important;
  136. border: 0 !important;
  137. }
  138. }
  139. .queue-item {
  140. display: flex;
  141. flex-direction: row;
  142. align-items: center;
  143. justify-content: space-between;
  144. padding: 7.5px;
  145. border: 1px solid $light-grey-2;
  146. border-radius: 3px;
  147. #thumbnail-and-info,
  148. #duration-and-actions {
  149. display: flex;
  150. align-items: center;
  151. }
  152. #duration-and-actions {
  153. margin-left: 5px;
  154. }
  155. #queue-item-buttons {
  156. display: flex;
  157. flex-direction: row;
  158. flex-wrap: wrap;
  159. margin-left: 10px;
  160. justify-content: center;
  161. }
  162. #thumbnail {
  163. width: 65px;
  164. height: 65px;
  165. margin: -7.5px;
  166. border-radius: 3px 0 0 3px;
  167. }
  168. #thumbnail-and-info {
  169. width: calc(100% - 120px);
  170. }
  171. #song-info {
  172. display: flex;
  173. flex-direction: column;
  174. justify-content: center;
  175. margin-left: 20px;
  176. width: calc(100% - 65px);
  177. *:not(i) {
  178. margin: 0;
  179. font-family: Karla, Arial, sans-serif;
  180. }
  181. #song-title {
  182. font-size: 20px;
  183. overflow: hidden;
  184. text-overflow: ellipsis;
  185. white-space: nowrap;
  186. }
  187. #song-artists {
  188. font-size: 14px;
  189. overflow: hidden;
  190. text-overflow: ellipsis;
  191. white-space: nowrap;
  192. }
  193. #song-request-time {
  194. font-size: 12px;
  195. margin-top: 7px;
  196. }
  197. }
  198. #song-duration {
  199. font-size: 20px;
  200. }
  201. #report-queue-item {
  202. cursor: pointer;
  203. color: $yellow;
  204. &:hover,
  205. &:focus {
  206. color: darken($yellow, 5%);
  207. }
  208. }
  209. #edit-queue-item {
  210. cursor: pointer;
  211. color: var(--station-theme);
  212. &:hover,
  213. &:focus {
  214. filter: brightness(90%);
  215. }
  216. }
  217. #remove-queue-item {
  218. cursor: pointer;
  219. color: $red;
  220. &:hover,
  221. &:focus {
  222. color: darken($red, 5%);
  223. }
  224. }
  225. }
  226. </style>