EditStation.vue 25 KB

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