index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <modal title="Manage Station" class="manage-station-modal">
  3. <template #body>
  4. <div class="custom-modal-body" v-if="station && station._id">
  5. <div class="left-section">
  6. <div class="section tabs-container">
  7. <div class="tab-selection">
  8. <button
  9. class="button is-default"
  10. :class="{ selected: tab === 'settings' }"
  11. @click="showTab('settings')"
  12. >
  13. Settings
  14. </button>
  15. <button
  16. class="button is-default"
  17. :class="{ selected: tab === 'playlists' }"
  18. @click="showTab('playlists')"
  19. >
  20. Playlists
  21. </button>
  22. <button
  23. v-if="station.type === 'community'"
  24. class="button is-default"
  25. :class="{ selected: tab === 'youtube' }"
  26. @click="showTab('youtube')"
  27. >
  28. YouTube
  29. </button>
  30. </div>
  31. <settings class="tab" v-show="tab === 'settings'" />
  32. <youtube-search
  33. v-if="station.type === 'community'"
  34. class="tab"
  35. v-show="tab === 'youtube'"
  36. />
  37. <playlists class="tab" v-show="tab === 'playlists'" />
  38. </div>
  39. </div>
  40. <div class="right-section">
  41. <div class="section">
  42. <h4 class="section-title">Queue</h4>
  43. <hr class="section-horizontal-rule" />
  44. <queue />
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <template #footer>
  50. <div class="right">
  51. <confirm @confirm="clearAndRefillStationQueue()">
  52. <a class="button is-danger">
  53. Clear and refill station queue
  54. </a>
  55. </confirm>
  56. <confirm
  57. v-if="station && station.type === 'community'"
  58. @confirm="deleteStation()"
  59. >
  60. <button class="button is-danger">Delete station</button>
  61. </confirm>
  62. </div>
  63. </template>
  64. </modal>
  65. </template>
  66. <script>
  67. import { mapState, mapGetters, mapActions } from "vuex";
  68. import Toast from "toasters";
  69. import TabQueryHandler from "@/mixins/TabQueryHandler.vue";
  70. import Confirm from "@/components/Confirm.vue";
  71. import Modal from "../../Modal.vue";
  72. import Queue from "../../../pages/Station/Sidebar/Queue.vue";
  73. import Settings from "./Tabs/Settings.vue";
  74. import Playlists from "./Tabs/Playlists.vue";
  75. import YoutubeSearch from "./Tabs/YoutubeSearch.vue";
  76. export default {
  77. components: {
  78. Modal,
  79. Confirm,
  80. Queue,
  81. Settings,
  82. Playlists,
  83. YoutubeSearch
  84. },
  85. mixins: [TabQueryHandler],
  86. props: {
  87. stationId: { type: String, default: "" },
  88. sector: { type: String, default: "admin" }
  89. },
  90. data() {
  91. return {
  92. tab: "settings"
  93. };
  94. },
  95. computed: {
  96. ...mapState("modals/editStation", {
  97. station: state => state.station,
  98. originalStation: state => state.originalStation
  99. }),
  100. ...mapGetters({
  101. socket: "websockets/getSocket"
  102. })
  103. },
  104. mounted() {
  105. this.socket.dispatch(`stations.getStationById`, this.stationId, res => {
  106. if (res.status === "success") {
  107. const { station } = res.data;
  108. this.editStation(station);
  109. } else {
  110. new Toast(`Station with that ID not found${this.stationId}`);
  111. this.closeModal({
  112. sector: this.sector,
  113. modal: "manageStation"
  114. });
  115. }
  116. });
  117. },
  118. beforeDestroy() {
  119. this.clearStation();
  120. },
  121. methods: {
  122. clearAndRefillStationQueue() {
  123. this.socket.dispatch(
  124. "stations.clearAndRefillStationQueue",
  125. this.station._id,
  126. res => {
  127. if (res.status !== "success")
  128. new Toast({
  129. content: `Error: ${res.message}`,
  130. timeout: 8000
  131. });
  132. else new Toast({ content: res.message, timeout: 4000 });
  133. }
  134. );
  135. },
  136. ...mapActions("modals/editStation", ["editStation", "clearStation"]),
  137. ...mapActions("modalVisibility", ["closeModal"])
  138. }
  139. };
  140. </script>
  141. <style lang="scss">
  142. .manage-station-modal.modal {
  143. z-index: 1800;
  144. .modal-card {
  145. width: 1300px;
  146. overflow: auto;
  147. .tab > button {
  148. width: 100%;
  149. margin-bottom: 10px;
  150. }
  151. }
  152. }
  153. </style>
  154. <style lang="scss" scoped>
  155. .manage-station-modal.modal .modal-card-body .custom-modal-body {
  156. display: flex;
  157. flex-wrap: wrap;
  158. height: 100%;
  159. .section {
  160. display: flex;
  161. flex-direction: column;
  162. flex-grow: 1;
  163. width: auto;
  164. padding: 15px !important;
  165. margin: 0 10px;
  166. }
  167. .left-section {
  168. flex-basis: 50%;
  169. height: 100%;
  170. overflow-y: auto;
  171. flex-grow: 1;
  172. .tabs-container {
  173. .tab-selection {
  174. display: flex;
  175. .button {
  176. border-radius: 5px 5px 0 0;
  177. border: 0;
  178. text-transform: uppercase;
  179. font-size: 14px;
  180. color: var(--dark-grey-3);
  181. background-color: var(--light-grey-2);
  182. flex-grow: 1;
  183. height: 32px;
  184. &:not(:first-of-type) {
  185. margin-left: 5px;
  186. }
  187. }
  188. .selected {
  189. background-color: var(--dark-grey-3) !important;
  190. color: var(--white) !important;
  191. }
  192. }
  193. .tab {
  194. border: 1px solid var(--light-grey-3);
  195. padding: 15px;
  196. border-radius: 0 0 5px 5px;
  197. }
  198. }
  199. }
  200. .right-section {
  201. flex-basis: 50%;
  202. height: 100%;
  203. overflow-y: auto;
  204. flex-grow: 1;
  205. }
  206. }
  207. @media screen and (max-width: 1100px) {
  208. .manage-station-modal.modal .modal-card-body .custom-modal-body {
  209. .left-section,
  210. .right-section {
  211. flex-basis: unset;
  212. height: auto;
  213. }
  214. }
  215. }
  216. </style>