QueueItem.vue 4.0 KB

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