StationInfoBox.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="about-station-container">
  3. <div class="station-info">
  4. <div class="row station-name">
  5. <h1>{{ station.displayName }}</h1>
  6. <i
  7. v-if="station.type === 'official'"
  8. class="material-icons verified-station"
  9. content="Verified Station"
  10. v-tippy
  11. >
  12. check_circle
  13. </i>
  14. <a>
  15. <!-- Favorite Station Button -->
  16. <i
  17. v-if="loggedIn && station.isFavorited"
  18. @click.prevent="unfavoriteStation()"
  19. content="Unfavorite Station"
  20. v-tippy
  21. class="material-icons"
  22. >star</i
  23. >
  24. <i
  25. v-if="loggedIn && !station.isFavorited"
  26. @click.prevent="favoriteStation()"
  27. class="material-icons"
  28. content="Favorite Station"
  29. v-tippy
  30. >star_border</i
  31. >
  32. </a>
  33. </div>
  34. <p>{{ station.description }}</p>
  35. </div>
  36. <div class="admin-buttons">
  37. <!-- (Admin) Pause/Resume Button -->
  38. <button
  39. class="button is-danger"
  40. v-if="isOwnerOrAdmin() && stationPaused"
  41. @click="resumeStation()"
  42. >
  43. <i class="material-icons icon-with-button">play_arrow</i>
  44. <span> Resume Station </span>
  45. </button>
  46. <button
  47. class="button is-danger"
  48. @click="pauseStation()"
  49. v-if="isOwnerOrAdmin() && !stationPaused"
  50. >
  51. <i class="material-icons icon-with-button">pause</i>
  52. <span> Pause Station </span>
  53. </button>
  54. <!-- (Admin) Skip Button -->
  55. <button
  56. class="button is-danger"
  57. @click="skipStation()"
  58. v-if="isOwnerOrAdmin()"
  59. >
  60. <i class="material-icons icon-with-button">skip_next</i>
  61. <span> Force Skip </span>
  62. </button>
  63. <!-- (Admin) Station Settings Button -->
  64. <button
  65. class="button is-primary"
  66. @click="
  67. openModal({
  68. modal: 'manageStation',
  69. data: {
  70. stationId: station._id,
  71. sector: 'station'
  72. }
  73. })
  74. "
  75. v-if="isOwnerOrAdmin() && showManageStation"
  76. >
  77. <i class="material-icons icon-with-button">settings</i>
  78. <span> Manage Station </span>
  79. </button>
  80. <router-link
  81. v-if="showGoToStation"
  82. :to="{
  83. name: 'station',
  84. params: { id: station.name }
  85. }"
  86. class="button is-primary"
  87. >
  88. Go To Station
  89. </router-link>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import { mapGetters, mapState, mapActions } from "vuex";
  95. import Toast from "toasters";
  96. export default {
  97. props: {
  98. station: { type: Object, default: null },
  99. stationPaused: { type: Boolean, default: null },
  100. showManageStation: { type: Boolean, default: false },
  101. showGoToStation: { type: Boolean, default: false }
  102. },
  103. data() {
  104. return {};
  105. },
  106. computed: {
  107. ...mapState({
  108. loggedIn: state => state.user.auth.loggedIn,
  109. userId: state => state.user.auth.userId,
  110. role: state => state.user.auth.role
  111. }),
  112. ...mapGetters({
  113. socket: "websockets/getSocket"
  114. })
  115. },
  116. mounted() {},
  117. methods: {
  118. isOwnerOnly() {
  119. return this.loggedIn && this.userId === this.station.owner;
  120. },
  121. isAdminOnly() {
  122. return this.loggedIn && this.role === "admin";
  123. },
  124. isOwnerOrAdmin() {
  125. return this.isOwnerOnly() || this.isAdminOnly();
  126. },
  127. resumeStation() {
  128. this.socket.dispatch("stations.resume", this.station._id, data => {
  129. if (data.status !== "success")
  130. new Toast(`Error: ${data.message}`);
  131. else new Toast("Successfully resumed the station.");
  132. });
  133. },
  134. pauseStation() {
  135. this.socket.dispatch("stations.pause", this.station._id, data => {
  136. if (data.status !== "success")
  137. new Toast(`Error: ${data.message}`);
  138. else new Toast("Successfully paused the station.");
  139. });
  140. },
  141. skipStation() {
  142. this.socket.dispatch(
  143. "stations.forceSkip",
  144. this.station._id,
  145. data => {
  146. if (data.status !== "success")
  147. new Toast(`Error: ${data.message}`);
  148. else
  149. new Toast(
  150. "Successfully skipped the station's current song."
  151. );
  152. }
  153. );
  154. },
  155. favoriteStation() {
  156. this.socket.dispatch(
  157. "stations.favoriteStation",
  158. this.station._id,
  159. res => {
  160. if (res.status === "success") {
  161. new Toast("Successfully favorited station.");
  162. } else new Toast(res.message);
  163. }
  164. );
  165. },
  166. unfavoriteStation() {
  167. this.socket.dispatch(
  168. "stations.unfavoriteStation",
  169. this.station._id,
  170. res => {
  171. if (res.status === "success") {
  172. new Toast("Successfully unfavorited station.");
  173. } else new Toast(res.message);
  174. }
  175. );
  176. },
  177. ...mapActions("modalVisibility", ["openModal"])
  178. }
  179. };
  180. </script>
  181. <style lang="less">
  182. .night-mode {
  183. .about-station-container {
  184. background-color: var(--dark-grey-3) !important;
  185. }
  186. }
  187. .about-station-container {
  188. padding: 20px;
  189. display: flex;
  190. flex-direction: column;
  191. flex-grow: unset;
  192. .row {
  193. display: flex;
  194. flex-direction: row;
  195. max-width: 100%;
  196. }
  197. .station-info {
  198. .station-name {
  199. flex-direction: row !important;
  200. h1 {
  201. margin: 0;
  202. font-size: 36px;
  203. line-height: 0.8;
  204. text-overflow: ellipsis;
  205. overflow: hidden;
  206. }
  207. i {
  208. margin-left: 10px;
  209. font-size: 30px;
  210. color: var(--yellow);
  211. &.stationMode {
  212. padding-left: 10px;
  213. margin-left: auto;
  214. color: var(--primary-color);
  215. }
  216. }
  217. .verified-station {
  218. color: var(--primary-color);
  219. }
  220. }
  221. p {
  222. display: -webkit-box;
  223. max-width: 700px;
  224. margin-bottom: 10px;
  225. overflow: hidden;
  226. text-overflow: ellipsis;
  227. -webkit-box-orient: vertical;
  228. -webkit-line-clamp: 3;
  229. }
  230. }
  231. .admin-buttons {
  232. display: flex;
  233. .button {
  234. margin: 3px;
  235. }
  236. }
  237. }
  238. </style>