EditStation.vue 25 KB

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