EditStation.vue 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. <template>
  2. <modal title="Edit Station" class="edit-station-modal">
  3. <template #body>
  4. <div class="custom-modal-body" v-if="station && station._id">
  5. <!-- Station Preferences -->
  6. <div class="section left-section">
  7. <div class="col col-2">
  8. <div>
  9. <label class="label">Name</label>
  10. <p class="control">
  11. <input
  12. class="input"
  13. type="text"
  14. v-model="station.name"
  15. />
  16. </p>
  17. </div>
  18. <div>
  19. <label class="label">Display name</label>
  20. <p class="control">
  21. <input
  22. class="input"
  23. type="text"
  24. v-model="station.displayName"
  25. />
  26. </p>
  27. </div>
  28. </div>
  29. <div class="col col-1">
  30. <div>
  31. <label class="label">Description</label>
  32. <p class="control">
  33. <input
  34. class="input"
  35. type="text"
  36. v-model="station.description"
  37. />
  38. </p>
  39. </div>
  40. </div>
  41. <div
  42. class="col col-2"
  43. v-if="station.type === 'official' && station.genres"
  44. >
  45. <div>
  46. <label class="label">Genre(s)</label>
  47. <p class="control has-addons">
  48. <input
  49. class="input"
  50. type="text"
  51. id="new-genre"
  52. v-model="genreInputValue"
  53. @blur="blurGenreInput()"
  54. @focus="focusGenreInput()"
  55. @keydown="keydownGenreInput()"
  56. @keyup.enter="addTag('genres')"
  57. />
  58. <button
  59. class="button is-info add-button blue"
  60. @click="addTag('genres')"
  61. >
  62. <i class="material-icons">add</i>
  63. </button>
  64. </p>
  65. <div
  66. class="autosuggest-container"
  67. v-if="
  68. (genreInputFocussed ||
  69. genreAutosuggestContainerFocussed) &&
  70. genreAutosuggestItems.length > 0
  71. "
  72. @mouseover="focusGenreContainer()"
  73. @mouseleave="blurGenreContainer()"
  74. >
  75. <span
  76. class="autosuggest-item"
  77. tabindex="0"
  78. @click="selectGenreAutosuggest(item)"
  79. v-for="(item,
  80. index) in genreAutosuggestItems"
  81. :key="index"
  82. >{{ item }}</span
  83. >
  84. </div>
  85. <div class="list-container">
  86. <div
  87. class="list-item"
  88. v-for="(genre, index) in station.genres"
  89. :key="index"
  90. >
  91. <div
  92. class="list-item-circle blue"
  93. @click="removeTag('genres', index)"
  94. >
  95. <i class="material-icons">close</i>
  96. </div>
  97. <p>{{ genre }}</p>
  98. </div>
  99. </div>
  100. </div>
  101. <div>
  102. <label class="label">Blacklist genre(s)</label>
  103. <p class="control has-addons">
  104. <input
  105. class="input"
  106. type="text"
  107. v-model="blacklistGenreInputValue"
  108. @blur="blurBlacklistGenreInput()"
  109. @focus="focusBlacklistGenreInput()"
  110. @keydown="keydownBlacklistGenreInput()"
  111. @keyup.enter="addTag('blacklist-genres')"
  112. />
  113. <button
  114. class="button is-info add-button red"
  115. @click="addTag('blacklist-genres')"
  116. >
  117. <i class="material-icons">add</i>
  118. </button>
  119. </p>
  120. <div
  121. class="autosuggest-container"
  122. v-if="
  123. (blacklistGenreInputFocussed ||
  124. blacklistGenreAutosuggestContainerFocussed) &&
  125. blacklistGenreAutosuggestItems.length >
  126. 0
  127. "
  128. @mouseover="focusBlacklistGenreContainer()"
  129. @mouseleave="blurBlacklistGenreContainer()"
  130. >
  131. <span
  132. class="autosuggest-item"
  133. tabindex="0"
  134. @click="
  135. selectBlacklistGenreAutosuggest(item)
  136. "
  137. v-for="(item,
  138. index) in blacklistGenreAutosuggestItems"
  139. :key="index"
  140. >{{ item }}</span
  141. >
  142. </div>
  143. <div class="list-container">
  144. <div
  145. class="list-item"
  146. v-for="(genre,
  147. index) in station.blacklistedGenres"
  148. :key="index"
  149. >
  150. <div
  151. class="list-item-circle red"
  152. @click="
  153. removeTag('blacklist-genres', index)
  154. "
  155. >
  156. <i class="material-icons">close</i>
  157. </div>
  158. <p>{{ genre }}</p>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <!-- Buttons changing the privacy settings -->
  165. <div class="section right-section">
  166. <div>
  167. <label class="label">Privacy</label>
  168. <div
  169. @mouseenter="privacyDropdownActive = true"
  170. @mouseleave="privacyDropdownActive = false"
  171. class="button-wrapper"
  172. >
  173. <button
  174. :class="privacyButtons[station.privacy].style"
  175. @click="updatePrivacyLocal(station.privacy)"
  176. >
  177. <i class="material-icons">{{
  178. privacyButtons[station.privacy].iconName
  179. }}</i>
  180. {{ station.privacy }}
  181. </button>
  182. <transition name="slide-down">
  183. <button
  184. class="green"
  185. v-if="
  186. privacyDropdownActive &&
  187. station.privacy !== 'public'
  188. "
  189. @click="updatePrivacyLocal('public')"
  190. >
  191. <i class="material-icons">{{
  192. privacyButtons["public"].iconName
  193. }}</i>
  194. Public
  195. </button>
  196. </transition>
  197. <transition name="slide-down">
  198. <button
  199. class="orange"
  200. v-if="
  201. privacyDropdownActive &&
  202. station.privacy !== 'unlisted'
  203. "
  204. @click="updatePrivacyLocal('unlisted')"
  205. >
  206. <i class="material-icons">{{
  207. privacyButtons["unlisted"].iconName
  208. }}</i>
  209. Unlisted
  210. </button>
  211. </transition>
  212. <transition name="slide-down">
  213. <button
  214. class="red"
  215. v-if="
  216. privacyDropdownActive &&
  217. station.privacy !== 'private'
  218. "
  219. @click="updatePrivacyLocal('private')"
  220. >
  221. <i class="material-icons">{{
  222. privacyButtons["private"].iconName
  223. }}</i>
  224. Private
  225. </button>
  226. </transition>
  227. </div>
  228. </div>
  229. <!-- Buttons changing the mode of the station -->
  230. <div v-if="station.type === 'community'">
  231. <label class="label">Mode</label>
  232. <div
  233. @mouseenter="modeDropdownActive = true"
  234. @mouseleave="modeDropdownActive = false"
  235. class="button-wrapper"
  236. >
  237. <button
  238. :class="{
  239. blue: !station.partyMode,
  240. yellow: station.partyMode
  241. }"
  242. @click="
  243. station.partyMode
  244. ? updatePartyModeLocal(true)
  245. : updatePartyModeLocal(false)
  246. "
  247. >
  248. <i class="material-icons">{{
  249. station.partyMode
  250. ? "emoji_people"
  251. : "playlist_play"
  252. }}</i>
  253. {{ station.partyMode ? "Party" : "Playlist" }}
  254. </button>
  255. <transition name="slide-down">
  256. <button
  257. class="blue"
  258. v-if="
  259. modeDropdownActive && station.partyMode
  260. "
  261. @click="updatePartyModeLocal(false)"
  262. >
  263. <i class="material-icons">playlist_play</i>
  264. Playlist
  265. </button>
  266. </transition>
  267. <transition name="slide-down">
  268. <button
  269. class="yellow"
  270. v-if="
  271. modeDropdownActive && !station.partyMode
  272. "
  273. @click="updatePartyModeLocal(true)"
  274. >
  275. <i class="material-icons">emoji_people</i>
  276. Party
  277. </button>
  278. </transition>
  279. </div>
  280. </div>
  281. <div
  282. v-if="
  283. station.type === 'community' &&
  284. station.partyMode === true
  285. "
  286. >
  287. <label class="label">Queue lock</label>
  288. <div
  289. @mouseenter="queueLockDropdownActive = true"
  290. @mouseleave="queueLockDropdownActive = false"
  291. class="button-wrapper"
  292. >
  293. <button
  294. :class="{
  295. green: station.locked,
  296. red: !station.locked
  297. }"
  298. @click="
  299. station.locked
  300. ? updateQueueLockLocal(true)
  301. : updateQueueLockLocal(false)
  302. "
  303. >
  304. <i class="material-icons">{{
  305. station.locked ? "lock" : "lock_open"
  306. }}</i>
  307. {{ station.locked ? "Locked" : "Unlocked" }}
  308. </button>
  309. <transition name="slide-down">
  310. <button
  311. class="green"
  312. v-if="
  313. queueLockDropdownActive &&
  314. !station.locked
  315. "
  316. @click="updateQueueLockLocal(true)"
  317. >
  318. <i class="material-icons">lock</i>
  319. Locked
  320. </button>
  321. </transition>
  322. <transition name="slide-down">
  323. <button
  324. class="red"
  325. v-if="
  326. queueLockDropdownActive &&
  327. station.locked
  328. "
  329. @click="updateQueueLockLocal(false)"
  330. >
  331. <i class="material-icons">lock_open</i>
  332. Unlocked
  333. </button>
  334. </transition>
  335. </div>
  336. </div>
  337. <div>
  338. <label class="label">Theme</label>
  339. <div
  340. @mouseenter="themeDropdownActive = true"
  341. @mouseleave="themeDropdownActive = false"
  342. class="button-wrapper"
  343. >
  344. <button
  345. :class="station.theme"
  346. @click="updateThemeLocal(station.theme)"
  347. >
  348. <i class="material-icons">palette</i>
  349. {{ station.theme }}
  350. </button>
  351. <transition name="slide-down">
  352. <button
  353. class="blue"
  354. v-if="
  355. themeDropdownActive &&
  356. station.theme !== 'blue'
  357. "
  358. @click="updateThemeLocal('blue')"
  359. >
  360. <i class="material-icons">palette</i>
  361. Blue
  362. </button>
  363. </transition>
  364. <transition name="slide-down">
  365. <button
  366. class="purple"
  367. v-if="
  368. themeDropdownActive &&
  369. station.theme !== 'purple'
  370. "
  371. @click="updateThemeLocal('purple')"
  372. >
  373. <i class="material-icons">palette</i>
  374. Purple
  375. </button>
  376. </transition>
  377. <transition name="slide-down">
  378. <button
  379. class="teal"
  380. v-if="
  381. themeDropdownActive &&
  382. station.theme !== 'teal'
  383. "
  384. @click="updateThemeLocal('teal')"
  385. >
  386. <i class="material-icons">palette</i>
  387. Teal
  388. </button>
  389. </transition>
  390. <transition name="slide-down">
  391. <button
  392. class="orange"
  393. v-if="
  394. themeDropdownActive &&
  395. station.theme !== 'orange'
  396. "
  397. @click="updateThemeLocal('orange')"
  398. >
  399. <i class="material-icons">palette</i>
  400. Orange
  401. </button>
  402. </transition>
  403. </div>
  404. </div>
  405. </div>
  406. </div>
  407. </template>
  408. <template #footer>
  409. <button class="button is-success" @click="update()">
  410. Update Settings
  411. </button>
  412. <button
  413. v-if="station.type === 'community'"
  414. class="button is-danger"
  415. @click="deleteStation()"
  416. >
  417. Delete station
  418. </button>
  419. </template>
  420. </modal>
  421. </template>
  422. <script>
  423. import { mapState, mapActions } from "vuex";
  424. import Toast from "toasters";
  425. import Modal from "../Modal.vue";
  426. import io from "../../io";
  427. import validation from "../../validation";
  428. export default {
  429. components: { Modal },
  430. props: {
  431. stationId: { type: String, default: "" },
  432. sector: { type: String, default: "admin" }
  433. },
  434. data() {
  435. return {
  436. genreInputValue: "",
  437. genreInputFocussed: false,
  438. genreAutosuggestContainerFocussed: false,
  439. keydownGenreInputTimeout: 0,
  440. genreAutosuggestItems: [],
  441. blacklistGenreInputValue: "",
  442. blacklistGenreInputFocussed: false,
  443. blacklistGenreAutosuggestContainerFocussed: false,
  444. blacklistKeydownGenreInputTimeout: 0,
  445. blacklistGenreAutosuggestItems: [],
  446. privacyDropdownActive: false,
  447. modeDropdownActive: false,
  448. queueLockDropdownActive: false,
  449. themeDropdownActive: false,
  450. genres: [
  451. "Blues",
  452. "Country",
  453. "Disco",
  454. "Funk",
  455. "Hip-Hop",
  456. "Jazz",
  457. "Metal",
  458. "Oldies",
  459. "Other",
  460. "Pop",
  461. "Rap",
  462. "Reggae",
  463. "Rock",
  464. "Techno",
  465. "Trance",
  466. "Classical",
  467. "Instrumental",
  468. "House",
  469. "Electronic",
  470. "Christian Rap",
  471. "Lo-Fi",
  472. "Musical",
  473. "Rock 'n' Roll",
  474. "Opera",
  475. "Drum & Bass",
  476. "Club-House",
  477. "Indie",
  478. "Heavy Metal",
  479. "Christian rock",
  480. "Dubstep"
  481. ],
  482. privacyButtons: {
  483. public: {
  484. style: "green",
  485. iconName: "public"
  486. },
  487. private: {
  488. style: "red",
  489. iconName: "lock"
  490. },
  491. unlisted: {
  492. style: "orange",
  493. iconName: "link"
  494. }
  495. }
  496. };
  497. },
  498. computed: {
  499. // ...mapState("admin/stations", {
  500. // stations: state => state.stations
  501. // }),
  502. ...mapState("modals/editStation", {
  503. station: state => state.station,
  504. originalStation: state => state.originalStation
  505. })
  506. },
  507. mounted() {
  508. io.getSocket(socket => {
  509. this.socket = socket;
  510. this.socket.emit(`stations.getStationById`, this.stationId, res => {
  511. if (res.status === "success") {
  512. const { station } = res;
  513. // this.song = { ...song };
  514. // if (this.song.discogs === undefined)
  515. // this.song.discogs = null;
  516. this.editStation(station);
  517. // this.songDataLoaded = true;
  518. this.station.genres = JSON.parse(
  519. JSON.stringify(this.station.genres)
  520. );
  521. this.station.blacklistedGenres = JSON.parse(
  522. JSON.stringify(this.station.blacklistedGenres)
  523. );
  524. } else {
  525. new Toast({
  526. content: "Station with that ID not found",
  527. timeout: 3000
  528. });
  529. this.closeModal({
  530. sector: this.sector,
  531. modal: "editStation"
  532. });
  533. }
  534. });
  535. return socket;
  536. });
  537. },
  538. methods: {
  539. update() {
  540. if (this.originalStation.name !== this.station.name)
  541. this.updateName();
  542. if (this.originalStation.displayName !== this.station.displayName)
  543. this.updateDisplayName();
  544. if (this.originalStation.description !== this.station.description)
  545. this.updateDescription();
  546. if (this.originalStation.privacy !== this.station.privacy)
  547. this.updatePrivacy();
  548. if (
  549. this.originalStation.type === "community" &&
  550. this.originalStation.partyMode !== this.station.partyMode
  551. )
  552. this.updatePartyMode();
  553. if (
  554. this.originalStation.type === "community" &&
  555. this.station.partyMode &&
  556. this.originalStation.locked !== this.station.locked
  557. )
  558. this.updateQueueLock();
  559. if (
  560. this.originalStation.genres.toString() !==
  561. this.station.genres.toString()
  562. )
  563. this.updateGenres();
  564. if (
  565. this.originalStation.blacklistedGenres.toString() !==
  566. this.station.blacklistedGenres.toString()
  567. )
  568. this.updateBlacklistedGenres();
  569. if (this.originalStation.theme !== this.station.theme)
  570. this.updateTheme();
  571. },
  572. updateName() {
  573. const { name } = this.station;
  574. if (!validation.isLength(name, 2, 16))
  575. return new Toast({
  576. content: "Name must have between 2 and 16 characters.",
  577. timeout: 8000
  578. });
  579. if (!validation.regex.az09_.test(name))
  580. return new Toast({
  581. content:
  582. "Invalid name format. Allowed characters: a-z, 0-9 and _.",
  583. timeout: 8000
  584. });
  585. return this.socket.emit(
  586. "stations.updateName",
  587. this.station._id,
  588. name,
  589. res => {
  590. if (res.status === "success")
  591. this.originalStation.name = name;
  592. new Toast({ content: res.message, timeout: 8000 });
  593. }
  594. );
  595. },
  596. updateDisplayName() {
  597. const { displayName } = this.station;
  598. if (!validation.isLength(displayName, 2, 32))
  599. return new Toast({
  600. content:
  601. "Display name must have between 2 and 32 characters.",
  602. timeout: 8000
  603. });
  604. if (!validation.regex.ascii.test(displayName))
  605. return new Toast({
  606. content:
  607. "Invalid display name format. Only ASCII characters are allowed.",
  608. timeout: 8000
  609. });
  610. return this.socket.emit(
  611. "stations.updateDisplayName",
  612. this.station._id,
  613. displayName,
  614. res => {
  615. if (res.status === "success")
  616. this.originalStation.displayName = displayName;
  617. new Toast({ content: res.message, timeout: 8000 });
  618. }
  619. );
  620. },
  621. updateDescription() {
  622. const { description } = this.station;
  623. if (!validation.isLength(description, 2, 200))
  624. return new Toast({
  625. content:
  626. "Description must have between 2 and 200 characters.",
  627. timeout: 8000
  628. });
  629. let characters = description.split("");
  630. characters = characters.filter(character => {
  631. return character.charCodeAt(0) === 21328;
  632. });
  633. if (characters.length !== 0)
  634. return new Toast({
  635. content: "Invalid description format.",
  636. timeout: 8000
  637. });
  638. return this.socket.emit(
  639. "stations.updateDescription",
  640. this.station._id,
  641. description,
  642. res => {
  643. if (res.status === "success")
  644. this.originalStation.description = description;
  645. return new Toast({ content: res.message, timeout: 8000 });
  646. }
  647. );
  648. },
  649. updatePrivacyLocal(privacy) {
  650. if (this.station.privacy === privacy) return;
  651. this.station.privacy = privacy;
  652. this.privacyDropdownActive = false;
  653. },
  654. updatePrivacy() {
  655. this.socket.emit(
  656. "stations.updatePrivacy",
  657. this.station._id,
  658. this.station.privacy,
  659. res => {
  660. if (res.status === "success")
  661. this.originalStation.privacy = this.station.privacy;
  662. return new Toast({ content: res.message, timeout: 8000 });
  663. }
  664. );
  665. },
  666. updateGenres() {
  667. this.socket.emit(
  668. "stations.updateGenres",
  669. this.station._id,
  670. this.station.genres,
  671. res => {
  672. console.log(res);
  673. if (res.status === "success") {
  674. const genres = JSON.parse(
  675. JSON.stringify(this.station.genres)
  676. );
  677. if (this.originalStation)
  678. this.originalStation.genres = genres;
  679. return new Toast({
  680. content: res.message,
  681. timeout: 4000
  682. });
  683. }
  684. return new Toast({ content: res.message, timeout: 8000 });
  685. }
  686. );
  687. },
  688. updateBlacklistedGenres() {
  689. this.socket.emit(
  690. "stations.updateBlacklistedGenres",
  691. this.station._id,
  692. this.station.blacklistedGenres,
  693. res => {
  694. if (res.status === "success") {
  695. const blacklistedGenres = JSON.parse(
  696. JSON.stringify(this.station.blacklistedGenres)
  697. );
  698. this.originalStation.blacklistedGenres = blacklistedGenres;
  699. }
  700. return new Toast({ content: res.message, timeout: 8000 });
  701. }
  702. );
  703. },
  704. updatePartyModeLocal(partyMode) {
  705. if (this.station.partyMode === partyMode) return;
  706. this.station.partyMode = partyMode;
  707. this.modeDropdownActive = false;
  708. },
  709. updatePartyMode() {
  710. this.socket.emit(
  711. "stations.updatePartyMode",
  712. this.station._id,
  713. this.station.partyMode,
  714. res => {
  715. if (res.status === "success")
  716. this.originalStation.partyMode = this.station.partyMode;
  717. return new Toast({ content: res.message, timeout: 8000 });
  718. }
  719. );
  720. },
  721. updateQueueLockLocal(locked) {
  722. if (this.station.locked === locked) return;
  723. this.station.locked = locked;
  724. this.queueLockDropdownActive = false;
  725. },
  726. updateQueueLock() {
  727. this.socket.emit("stations.toggleLock", this.station._id, res => {
  728. console.log(res);
  729. if (res.status === "success") {
  730. if (this.originalStation)
  731. this.originalStation.locked = res.data;
  732. return new Toast({
  733. content: `Toggled queue lock successfully to ${res.data}`,
  734. timeout: 4000
  735. });
  736. }
  737. return new Toast({
  738. content: "Failed to toggle queue lock.",
  739. timeout: 8000
  740. });
  741. });
  742. },
  743. updateThemeLocal(theme) {
  744. if (this.station.theme === theme) return;
  745. this.station.theme = theme;
  746. this.themeDropdownActive = false;
  747. },
  748. updateTheme() {
  749. this.socket.emit(
  750. "stations.updateTheme",
  751. this.station._id,
  752. this.station.theme,
  753. res => {
  754. if (res.status === "success")
  755. this.originalStation.theme = this.station.theme;
  756. return new Toast({ content: res.message, timeout: 8000 });
  757. }
  758. );
  759. },
  760. deleteStation() {
  761. this.socket.emit("stations.remove", this.station._id, res => {
  762. if (res.status === "success")
  763. this.closeModal({
  764. sector: "station",
  765. modal: "editStation"
  766. });
  767. return new Toast({ content: res.message, timeout: 8000 });
  768. });
  769. },
  770. blurGenreInput() {
  771. this.genreInputFocussed = false;
  772. },
  773. focusGenreInput() {
  774. this.genreInputFocussed = true;
  775. },
  776. keydownGenreInput() {
  777. clearTimeout(this.keydownGenreInputTimeout);
  778. this.keydownGenreInputTimeout = setTimeout(() => {
  779. if (this.genreInputValue.length > 1) {
  780. this.genreAutosuggestItems = this.genres.filter(genre => {
  781. return genre
  782. .toLowerCase()
  783. .startsWith(this.genreInputValue.toLowerCase());
  784. });
  785. } else this.genreAutosuggestItems = [];
  786. }, 1000);
  787. },
  788. focusGenreContainer() {
  789. this.genreAutosuggestContainerFocussed = true;
  790. },
  791. blurGenreContainer() {
  792. this.genreAutosuggestContainerFocussed = false;
  793. },
  794. selectGenreAutosuggest(value) {
  795. this.genreInputValue = value;
  796. },
  797. blurBlacklistGenreInput() {
  798. this.blacklistGenreInputFocussed = false;
  799. },
  800. focusBlacklistGenreInput() {
  801. this.blacklistGenreInputFocussed = true;
  802. },
  803. keydownBlacklistGenreInput() {
  804. clearTimeout(this.keydownBlacklistGenreInputTimeout);
  805. this.keydownBlacklistGenreInputTimeout = setTimeout(() => {
  806. if (this.blacklistGenreInputValue.length > 1) {
  807. this.blacklistGenreAutosuggestItems = this.genres.filter(
  808. genre => {
  809. return genre
  810. .toLowerCase()
  811. .startsWith(
  812. this.blacklistGenreInputValue.toLowerCase()
  813. );
  814. }
  815. );
  816. } else this.blacklistGenreAutosuggestItems = [];
  817. }, 1000);
  818. },
  819. focusBlacklistGenreContainer() {
  820. this.blacklistGenreAutosuggestContainerFocussed = true;
  821. },
  822. blurBlacklistGenreContainer() {
  823. this.blacklistGenreAutosuggestContainerFocussed = false;
  824. },
  825. selectBlacklistGenreAutosuggest(value) {
  826. this.blacklistGenreInputValue = value;
  827. },
  828. addTag(type) {
  829. if (type === "genres") {
  830. const genre = this.genreInputValue.toLowerCase().trim();
  831. if (this.station.genres.indexOf(genre) !== -1)
  832. return new Toast({
  833. content: "Genre already exists",
  834. timeout: 3000
  835. });
  836. if (genre) {
  837. this.station.genres.push(genre);
  838. this.genreInputValue = "";
  839. return false;
  840. }
  841. return new Toast({
  842. content: "Genre cannot be empty",
  843. timeout: 3000
  844. });
  845. }
  846. if (type === "blacklist-genres") {
  847. const genre = this.blacklistGenreInputValue
  848. .toLowerCase()
  849. .trim();
  850. if (this.station.blacklistedGenres.indexOf(genre) !== -1)
  851. return new Toast({
  852. content: "Blacklist genre already exists",
  853. timeout: 3000
  854. });
  855. if (genre) {
  856. this.station.blacklistedGenres.push(genre);
  857. this.blacklistGenreInputValue = "";
  858. return false;
  859. }
  860. return new Toast({
  861. content: "Blacklist genre cannot be empty",
  862. timeout: 3000
  863. });
  864. }
  865. return false;
  866. },
  867. removeTag(type, index) {
  868. if (type === "genres") this.station.genres.splice(index, 1);
  869. else if (type === "blacklist-genres")
  870. this.station.blacklistedGenres.splice(index, 1);
  871. },
  872. ...mapActions("modals/editStation", ["editStation"]),
  873. ...mapActions("modalVisibility", ["closeModal"])
  874. }
  875. };
  876. </script>
  877. <style lang="scss" scoped>
  878. @import "../../styles/global.scss";
  879. .night-mode {
  880. .modal-card,
  881. .modal-card-head,
  882. .modal-card-body,
  883. .modal-card-foot {
  884. background-color: $night-mode-bg-secondary;
  885. }
  886. .section {
  887. background-color: $night-mode-bg-secondary !important;
  888. border: 0 !important;
  889. }
  890. .label,
  891. p,
  892. strong {
  893. color: $night-mode-text;
  894. }
  895. }
  896. .modal-card-title {
  897. text-align: center;
  898. margin-left: 24px;
  899. }
  900. .custom-modal-body {
  901. padding: 16px;
  902. display: flex;
  903. }
  904. .section {
  905. border: 1px solid #a3e0ff;
  906. background-color: #f4f4f4;
  907. border-radius: 5px;
  908. padding: 16px;
  909. }
  910. .left-section {
  911. width: 595px;
  912. display: grid;
  913. gap: 16px;
  914. grid-template-rows: min-content min-content auto;
  915. .control {
  916. input {
  917. width: 100%;
  918. height: 36px;
  919. }
  920. .add-button {
  921. width: 32px;
  922. &.blue {
  923. background-color: $musare-blue !important;
  924. }
  925. &.red {
  926. background-color: $red !important;
  927. }
  928. i {
  929. font-size: 32px;
  930. }
  931. }
  932. }
  933. .col {
  934. > div {
  935. position: relative;
  936. }
  937. }
  938. .list-item-circle {
  939. width: 16px;
  940. height: 16px;
  941. border-radius: 8px;
  942. cursor: pointer;
  943. margin-right: 8px;
  944. float: left;
  945. -webkit-touch-callout: none;
  946. -webkit-user-select: none;
  947. -khtml-user-select: none;
  948. -moz-user-select: none;
  949. -ms-user-select: none;
  950. user-select: none;
  951. &.blue {
  952. background-color: $musare-blue;
  953. i {
  954. color: $musare-blue;
  955. }
  956. }
  957. &.red {
  958. background-color: $red;
  959. i {
  960. color: $red;
  961. }
  962. }
  963. i {
  964. font-size: 14px;
  965. margin-left: 1px;
  966. }
  967. }
  968. .list-item-circle:hover,
  969. .list-item-circle:focus {
  970. i {
  971. color: white;
  972. }
  973. }
  974. .list-item > p {
  975. line-height: 16px;
  976. word-wrap: break-word;
  977. width: calc(100% - 24px);
  978. left: 24px;
  979. float: left;
  980. margin-bottom: 8px;
  981. }
  982. .list-item:last-child > p {
  983. margin-bottom: 0;
  984. }
  985. .autosuggest-container {
  986. position: absolute;
  987. background: white;
  988. width: calc(100% + 1px);
  989. top: 57px;
  990. z-index: 200;
  991. overflow: auto;
  992. max-height: 100%;
  993. clear: both;
  994. .autosuggest-item {
  995. padding: 8px;
  996. display: block;
  997. border: 1px solid #dbdbdb;
  998. margin-top: -1px;
  999. line-height: 16px;
  1000. cursor: pointer;
  1001. -webkit-user-select: none;
  1002. -ms-user-select: none;
  1003. -moz-user-select: none;
  1004. user-select: none;
  1005. }
  1006. .autosuggest-item:hover,
  1007. .autosuggest-item:focus {
  1008. background-color: #eee;
  1009. }
  1010. .autosuggest-item:first-child {
  1011. border-top: none;
  1012. }
  1013. .autosuggest-item:last-child {
  1014. border-radius: 0 0 3px 3px;
  1015. }
  1016. }
  1017. }
  1018. .right-section {
  1019. width: 157px;
  1020. min-height: 515px;
  1021. margin-left: 16px;
  1022. display: grid;
  1023. gap: 16px;
  1024. grid-template-rows: min-content min-content min-content;
  1025. .button-wrapper {
  1026. display: flex;
  1027. flex-direction: column;
  1028. button {
  1029. width: 100%;
  1030. height: 36px;
  1031. border: 0;
  1032. border-radius: 3px;
  1033. font-size: 18px;
  1034. color: white;
  1035. box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25);
  1036. display: block;
  1037. text-align: center;
  1038. justify-content: center;
  1039. display: inline-flex;
  1040. -ms-flex-align: center;
  1041. align-items: center;
  1042. -moz-user-select: none;
  1043. user-select: none;
  1044. cursor: pointer;
  1045. margin-bottom: 10px;
  1046. padding: 0;
  1047. text-transform: capitalize;
  1048. &.red {
  1049. background-color: $red;
  1050. }
  1051. &.green {
  1052. background-color: $green;
  1053. }
  1054. &.blue {
  1055. background-color: $musare-blue;
  1056. }
  1057. &.orange {
  1058. background-color: $light-orange;
  1059. }
  1060. &.yellow {
  1061. background-color: $yellow;
  1062. }
  1063. &.purple {
  1064. background-color: $purple;
  1065. }
  1066. &.teal {
  1067. background-color: $teal;
  1068. }
  1069. i {
  1070. font-size: 20px;
  1071. margin-right: 4px;
  1072. }
  1073. }
  1074. }
  1075. }
  1076. .col {
  1077. display: grid;
  1078. grid-column-gap: 16px;
  1079. }
  1080. .col-1 {
  1081. grid-template-columns: auto;
  1082. }
  1083. .col-2 {
  1084. grid-template-columns: auto auto;
  1085. }
  1086. .slide-down-enter-active {
  1087. transition: transform 0.25s;
  1088. }
  1089. .slide-down-enter {
  1090. transform: translateY(-10px);
  1091. }
  1092. .modal-card {
  1093. overflow: auto;
  1094. }
  1095. .modal-card-body {
  1096. overflow: unset;
  1097. }
  1098. </style>