QueueItem.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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="openModal({ sector: 'station', modal: 'report' })"
  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. ...mapActions("modals", ["openModal"]),
  116. formatDistance,
  117. parseISO
  118. }
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. @import "../../../../../styles/global.scss";
  123. .queue-item {
  124. display: flex;
  125. flex-direction: row;
  126. align-items: center;
  127. justify-content: space-between;
  128. padding: 7.5px;
  129. border: 1px solid $light-grey-2;
  130. border-radius: 3px;
  131. #thumbnail-and-info,
  132. #duration-and-actions {
  133. display: flex;
  134. align-items: center;
  135. }
  136. #duration-and-actions {
  137. margin-left: 5px;
  138. }
  139. #queue-item-buttons {
  140. display: flex;
  141. flex-direction: column;
  142. margin-left: 10px;
  143. }
  144. #thumbnail {
  145. width: 60px;
  146. height: 60px;
  147. }
  148. #song-info {
  149. display: flex;
  150. flex-direction: column;
  151. justify-content: center;
  152. margin-left: 25px;
  153. *:not(i) {
  154. margin: 0;
  155. font-family: Karla, Arial, sans-serif;
  156. }
  157. #song-title {
  158. font-size: 20px;
  159. }
  160. #song-artists {
  161. font-size: 14px;
  162. }
  163. #song-request-time {
  164. font-size: 12px;
  165. margin-top: 7px;
  166. }
  167. }
  168. #song-duration {
  169. font-size: 20px;
  170. }
  171. #report-queue-item {
  172. cursor: pointer;
  173. color: $yellow;
  174. &:hover,
  175. &:focus {
  176. color: darken($yellow, 5%);
  177. }
  178. }
  179. #edit-queue-item {
  180. cursor: pointer;
  181. color: $musare-blue;
  182. &:hover,
  183. &:focus {
  184. color: darken($musare-blue, 5%);
  185. }
  186. }
  187. #remove-queue-item {
  188. cursor: pointer;
  189. color: $red;
  190. &:hover,
  191. &:focus {
  192. color: darken($red, 5%);
  193. }
  194. }
  195. }
  196. </style>