12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292 |
- <template>
- <modal title="Edit Station" class="edit-station-modal">
- <template #body>
- <div class="custom-modal-body" v-if="station && station._id">
- <!-- Station Preferences -->
- <div class="section left-section">
- <div class="col col-2">
- <div>
- <label class="label">Name</label>
- <p class="control">
- <input
- class="input"
- type="text"
- v-model="station.name"
- />
- </p>
- </div>
- <div>
- <label class="label">Display name</label>
- <p class="control">
- <input
- class="input"
- type="text"
- v-model="station.displayName"
- />
- </p>
- </div>
- </div>
- <div class="col col-1">
- <div>
- <label class="label">Description</label>
- <p class="control">
- <input
- class="input"
- type="text"
- v-model="station.description"
- />
- </p>
- </div>
- </div>
- <div
- class="col col-2"
- v-if="station.type === 'official' && station.genres"
- >
- <div>
- <label class="label">Genre(s)</label>
- <p class="control has-addons">
- <input
- class="input"
- type="text"
- id="new-genre"
- v-model="genreInputValue"
- @blur="blurGenreInput()"
- @focus="focusGenreInput()"
- @keydown="keydownGenreInput()"
- @keyup.enter="addTag('genres')"
- />
- <button
- class="button is-info add-button blue"
- @click="addTag('genres')"
- >
- <i class="material-icons">add</i>
- </button>
- </p>
- <div
- class="autosuggest-container"
- v-if="
- (genreInputFocussed ||
- genreAutosuggestContainerFocussed) &&
- genreAutosuggestItems.length > 0
- "
- @mouseover="focusGenreContainer()"
- @mouseleave="blurGenreContainer()"
- >
- <span
- class="autosuggest-item"
- tabindex="0"
- @click="selectGenreAutosuggest(item)"
- v-for="(item,
- index) in genreAutosuggestItems"
- :key="index"
- >{{ item }}</span
- >
- </div>
- <div class="list-container">
- <div
- class="list-item"
- v-for="(genre, index) in station.genres"
- :key="index"
- >
- <div
- class="list-item-circle blue"
- @click="removeTag('genres', index)"
- >
- <i class="material-icons">close</i>
- </div>
- <p>{{ genre }}</p>
- </div>
- </div>
- </div>
- <div>
- <label class="label">Blacklist genre(s)</label>
- <p class="control has-addons">
- <input
- class="input"
- type="text"
- v-model="blacklistGenreInputValue"
- @blur="blurBlacklistGenreInput()"
- @focus="focusBlacklistGenreInput()"
- @keydown="keydownBlacklistGenreInput()"
- @keyup.enter="addTag('blacklist-genres')"
- />
- <button
- class="button is-info add-button red"
- @click="addTag('blacklist-genres')"
- >
- <i class="material-icons">add</i>
- </button>
- </p>
- <div
- class="autosuggest-container"
- v-if="
- (blacklistGenreInputFocussed ||
- blacklistGenreAutosuggestContainerFocussed) &&
- blacklistGenreAutosuggestItems.length >
- 0
- "
- @mouseover="focusBlacklistGenreContainer()"
- @mouseleave="blurBlacklistGenreContainer()"
- >
- <span
- class="autosuggest-item"
- tabindex="0"
- @click="
- selectBlacklistGenreAutosuggest(item)
- "
- v-for="(item,
- index) in blacklistGenreAutosuggestItems"
- :key="index"
- >{{ item }}</span
- >
- </div>
- <div class="list-container">
- <div
- class="list-item"
- v-for="(genre,
- index) in station.blacklistedGenres"
- :key="index"
- >
- <div
- class="list-item-circle red"
- @click="
- removeTag('blacklist-genres', index)
- "
- >
- <i class="material-icons">close</i>
- </div>
- <p>{{ genre }}</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- Buttons changing the privacy settings -->
- <div class="section right-section">
- <div>
- <label class="label">Privacy</label>
- <div
- @mouseenter="privacyDropdownActive = true"
- @mouseleave="privacyDropdownActive = false"
- class="button-wrapper"
- >
- <button
- :class="privacyButtons[station.privacy].style"
- @click="updatePrivacyLocal(station.privacy)"
- >
- <i class="material-icons">{{
- privacyButtons[station.privacy].iconName
- }}</i>
- {{ station.privacy }}
- </button>
- <transition name="slide-down">
- <button
- class="green"
- v-if="
- privacyDropdownActive &&
- station.privacy !== 'public'
- "
- @click="updatePrivacyLocal('public')"
- >
- <i class="material-icons">{{
- privacyButtons["public"].iconName
- }}</i>
- Public
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="orange"
- v-if="
- privacyDropdownActive &&
- station.privacy !== 'unlisted'
- "
- @click="updatePrivacyLocal('unlisted')"
- >
- <i class="material-icons">{{
- privacyButtons["unlisted"].iconName
- }}</i>
- Unlisted
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="red"
- v-if="
- privacyDropdownActive &&
- station.privacy !== 'private'
- "
- @click="updatePrivacyLocal('private')"
- >
- <i class="material-icons">{{
- privacyButtons["private"].iconName
- }}</i>
- Private
- </button>
- </transition>
- </div>
- </div>
- <!-- Buttons changing the mode of the station -->
- <div v-if="station.type === 'community'">
- <label class="label">Mode</label>
- <div
- @mouseenter="modeDropdownActive = true"
- @mouseleave="modeDropdownActive = false"
- class="button-wrapper"
- >
- <button
- :class="{
- blue: !station.partyMode,
- yellow: station.partyMode
- }"
- @click="
- station.partyMode
- ? updatePartyModeLocal(true)
- : updatePartyModeLocal(false)
- "
- >
- <i class="material-icons">{{
- station.partyMode
- ? "emoji_people"
- : "playlist_play"
- }}</i>
- {{ station.partyMode ? "Party" : "Playlist" }}
- </button>
- <transition name="slide-down">
- <button
- class="blue"
- v-if="
- modeDropdownActive && station.partyMode
- "
- @click="updatePartyModeLocal(false)"
- >
- <i class="material-icons">playlist_play</i>
- Playlist
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="yellow"
- v-if="
- modeDropdownActive && !station.partyMode
- "
- @click="updatePartyModeLocal(true)"
- >
- <i class="material-icons">emoji_people</i>
- Party
- </button>
- </transition>
- </div>
- </div>
- <div
- v-if="
- station.type === 'community' &&
- station.partyMode === true
- "
- >
- <label class="label">Queue lock</label>
- <div
- @mouseenter="queueLockDropdownActive = true"
- @mouseleave="queueLockDropdownActive = false"
- class="button-wrapper"
- >
- <button
- :class="{
- green: station.locked,
- red: !station.locked
- }"
- @click="
- station.locked
- ? updateQueueLockLocal(true)
- : updateQueueLockLocal(false)
- "
- >
- <i class="material-icons">{{
- station.locked ? "lock" : "lock_open"
- }}</i>
- {{ station.locked ? "Locked" : "Unlocked" }}
- </button>
- <transition name="slide-down">
- <button
- class="green"
- v-if="
- queueLockDropdownActive &&
- !station.locked
- "
- @click="updateQueueLockLocal(true)"
- >
- <i class="material-icons">lock</i>
- Locked
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="red"
- v-if="
- queueLockDropdownActive &&
- station.locked
- "
- @click="updateQueueLockLocal(false)"
- >
- <i class="material-icons">lock_open</i>
- Unlocked
- </button>
- </transition>
- </div>
- </div>
- <div>
- <label class="label">Theme</label>
- <div
- @mouseenter="themeDropdownActive = true"
- @mouseleave="themeDropdownActive = false"
- class="button-wrapper"
- >
- <button
- :class="station.theme"
- @click="updateThemeLocal(station.theme)"
- >
- <i class="material-icons">palette</i>
- {{ station.theme }}
- </button>
- <transition name="slide-down">
- <button
- class="blue"
- v-if="
- themeDropdownActive &&
- station.theme !== 'blue'
- "
- @click="updateThemeLocal('blue')"
- >
- <i class="material-icons">palette</i>
- Blue
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="purple"
- v-if="
- themeDropdownActive &&
- station.theme !== 'purple'
- "
- @click="updateThemeLocal('purple')"
- >
- <i class="material-icons">palette</i>
- Purple
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="teal"
- v-if="
- themeDropdownActive &&
- station.theme !== 'teal'
- "
- @click="updateThemeLocal('teal')"
- >
- <i class="material-icons">palette</i>
- Teal
- </button>
- </transition>
- <transition name="slide-down">
- <button
- class="orange"
- v-if="
- themeDropdownActive &&
- station.theme !== 'orange'
- "
- @click="updateThemeLocal('orange')"
- >
- <i class="material-icons">palette</i>
- Orange
- </button>
- </transition>
- </div>
- </div>
- </div>
- </div>
- </template>
- <template #footer>
- <save-button ref="saveButton" @clicked="saveChanges()" />
- <button
- v-if="station.type === 'community'"
- class="button is-danger"
- @click="deleteStation()"
- >
- Delete station
- </button>
- </template>
- </modal>
- </template>
- <script>
- import { mapState, mapActions } from "vuex";
- import Toast from "toasters";
- import Modal from "../Modal.vue";
- import io from "../../io";
- import validation from "../../validation";
- import SaveButton from "../ui/SaveButton.vue";
- export default {
- components: { Modal, SaveButton },
- props: {
- stationId: { type: String, default: "" },
- sector: { type: String, default: "admin" }
- },
- data() {
- return {
- genreInputValue: "",
- genreInputFocussed: false,
- genreAutosuggestContainerFocussed: false,
- keydownGenreInputTimeout: 0,
- genreAutosuggestItems: [],
- blacklistGenreInputValue: "",
- blacklistGenreInputFocussed: false,
- blacklistGenreAutosuggestContainerFocussed: false,
- blacklistKeydownGenreInputTimeout: 0,
- blacklistGenreAutosuggestItems: [],
- privacyDropdownActive: false,
- modeDropdownActive: false,
- queueLockDropdownActive: false,
- themeDropdownActive: false,
- genres: [
- "Blues",
- "Country",
- "Disco",
- "Funk",
- "Hip-Hop",
- "Jazz",
- "Metal",
- "Oldies",
- "Other",
- "Pop",
- "Rap",
- "Reggae",
- "Rock",
- "Techno",
- "Trance",
- "Classical",
- "Instrumental",
- "House",
- "Electronic",
- "Christian Rap",
- "Lo-Fi",
- "Musical",
- "Rock 'n' Roll",
- "Opera",
- "Drum & Bass",
- "Club-House",
- "Indie",
- "Heavy Metal",
- "Christian rock",
- "Dubstep"
- ],
- privacyButtons: {
- public: {
- style: "green",
- iconName: "public"
- },
- private: {
- style: "red",
- iconName: "lock"
- },
- unlisted: {
- style: "orange",
- iconName: "link"
- }
- }
- };
- },
- computed: {
- // ...mapState("admin/stations", {
- // stations: state => state.stations
- // }),
- ...mapState("modals/editStation", {
- station: state => state.station,
- originalStation: state => state.originalStation
- })
- },
- mounted() {
- io.getSocket(socket => {
- this.socket = socket;
- this.socket.emit(`stations.getStationById`, this.stationId, res => {
- if (res.status === "success") {
- const { station } = res;
- // this.song = { ...song };
- // if (this.song.discogs === undefined)
- // this.song.discogs = null;
- this.editStation(station);
- // this.songDataLoaded = true;
- this.socket.emit(
- `stations.getStationIncludedPlaylistsById`,
- this.stationId,
- res => {
- if (res.status === "success") {
- this.station.genres = res.playlists.map(
- playlist => {
- if (playlist) {
- if (playlist.type === "genre")
- return playlist.createdFor;
- return `Playlist: ${playlist.name}`;
- }
- return "Unknown/Error";
- }
- );
- this.originalStation.genres = JSON.parse(
- JSON.stringify(this.station.genres)
- );
- }
- }
- );
- this.socket.emit(
- `stations.getStationExcludedPlaylistsById`,
- this.stationId,
- res => {
- if (res.status === "success") {
- this.station.blacklistedGenres = res.playlists.map(
- playlist => {
- if (playlist) {
- if (playlist.type === "genre")
- return playlist.createdFor;
- return `Playlist: ${playlist.name}`;
- }
- return "Unknown/Error";
- }
- );
- this.originalStation.blacklistedGenres = JSON.parse(
- JSON.stringify(
- this.station.blacklistedGenres
- )
- );
- }
- }
- );
- // this.station.genres = JSON.parse(
- // JSON.stringify(this.station.genres)
- // );
- // this.station.blacklistedGenres = JSON.parse(
- // JSON.stringify(this.station.blacklistedGenres)
- // );
- } else {
- new Toast({
- content: "Station with that ID not found",
- timeout: 3000
- });
- this.closeModal({
- sector: this.sector,
- modal: "editStation"
- });
- }
- });
- return socket;
- });
- },
- methods: {
- saveChanges() {
- const nameChanged = this.originalStation.name !== this.station.name;
- const displayNameChanged =
- this.originalStation.displayName !== this.station.displayName;
- const descriptionChanged =
- this.originalStation.description !== this.station.description;
- const privacyChanged =
- this.originalStation.privacy !== this.station.privacy;
- const partyModeChanged =
- this.originalStation.type === "community" &&
- this.originalStation.partyMode !== this.station.partyMode;
- const queueLockChanged =
- this.originalStation.type === "community" &&
- this.station.partyMode &&
- this.originalStation.locked !== this.station.locked;
- const genresChanged =
- this.originalStation.genres.toString() !==
- this.station.genres.toString();
- const blacklistedGenresChanged =
- this.originalStation.blacklistedGenres.toString() !==
- this.station.blacklistedGenres.toString();
- const themeChanged =
- this.originalStation.theme !== this.station.theme;
- if (nameChanged) this.updateName();
- if (displayNameChanged) this.updateDisplayName();
- if (descriptionChanged) this.updateDescription();
- if (privacyChanged) this.updatePrivacy();
- if (partyModeChanged) this.updatePartyMode();
- if (queueLockChanged) this.updateQueueLock();
- if (genresChanged) this.updateGenres();
- if (blacklistedGenresChanged) this.updateBlacklistedGenres();
- if (themeChanged) this.updateTheme();
- if (
- !nameChanged &&
- !displayNameChanged &&
- !descriptionChanged &&
- !privacyChanged &&
- !partyModeChanged &&
- !queueLockChanged &&
- !genresChanged &&
- !blacklistedGenresChanged &&
- !themeChanged
- ) {
- this.$refs.saveButton.handleFailedSave();
- new Toast({
- content: "Please make a change before saving.",
- timeout: 8000
- });
- }
- },
- updateName() {
- const { name } = this.station;
- if (!validation.isLength(name, 2, 16))
- return new Toast({
- content: "Name must have between 2 and 16 characters.",
- timeout: 8000
- });
- if (!validation.regex.az09_.test(name))
- return new Toast({
- content:
- "Invalid name format. Allowed characters: a-z, 0-9 and _.",
- timeout: 8000
- });
- this.$refs.saveButton.status = "disabled";
- return this.socket.emit(
- "stations.updateName",
- this.station._id,
- name,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- this.originalStation.name = name;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updateDisplayName() {
- const { displayName } = this.station;
- if (!validation.isLength(displayName, 2, 32))
- return new Toast({
- content:
- "Display name must have between 2 and 32 characters.",
- timeout: 8000
- });
- if (!validation.regex.ascii.test(displayName))
- return new Toast({
- content:
- "Invalid display name format. Only ASCII characters are allowed.",
- timeout: 8000
- });
- this.$refs.saveButton.status = "disabled";
- return this.socket.emit(
- "stations.updateDisplayName",
- this.station._id,
- displayName,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- this.originalStation.displayName = displayName;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updateDescription() {
- const { description } = this.station;
- if (!validation.isLength(description, 2, 200))
- return new Toast({
- content:
- "Description must have between 2 and 200 characters.",
- timeout: 8000
- });
- let characters = description.split("");
- characters = characters.filter(character => {
- return character.charCodeAt(0) === 21328;
- });
- if (characters.length !== 0)
- return new Toast({
- content: "Invalid description format.",
- timeout: 8000
- });
- this.$refs.saveButton.status = "disabled";
- return this.socket.emit(
- "stations.updateDescription",
- this.station._id,
- description,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- this.originalStation.description = description;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updatePrivacyLocal(privacy) {
- if (this.station.privacy === privacy) return;
- this.station.privacy = privacy;
- this.privacyDropdownActive = false;
- },
- updatePrivacy() {
- this.$refs.saveButton.status = "disabled";
- this.socket.emit(
- "stations.updatePrivacy",
- this.station._id,
- this.station.privacy,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- this.originalStation.privacy = this.station.privacy;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updateGenres() {
- this.$refs.saveButton.status = "disabled";
- this.socket.emit(
- "stations.updateGenres",
- this.station._id,
- this.station.genres,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- const genres = JSON.parse(
- JSON.stringify(this.station.genres)
- );
- if (this.originalStation)
- this.originalStation.genres = genres;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updateBlacklistedGenres() {
- this.$refs.saveButton.status = "disabled";
- this.socket.emit(
- "stations.updateBlacklistedGenres",
- this.station._id,
- this.station.blacklistedGenres,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- const blacklistedGenres = JSON.parse(
- JSON.stringify(this.station.blacklistedGenres)
- );
- this.originalStation.blacklistedGenres = blacklistedGenres;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updatePartyModeLocal(partyMode) {
- if (this.station.partyMode === partyMode) return;
- this.station.partyMode = partyMode;
- this.modeDropdownActive = false;
- },
- updatePartyMode() {
- this.$refs.saveButton.status = "disabled";
- this.socket.emit(
- "stations.updatePartyMode",
- this.station._id,
- this.station.partyMode,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- this.originalStation.partyMode = this.station.partyMode;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- updateQueueLockLocal(locked) {
- if (this.station.locked === locked) return;
- this.station.locked = locked;
- this.queueLockDropdownActive = false;
- },
- updateQueueLock() {
- this.$refs.saveButton.status = "disabled";
- this.socket.emit("stations.toggleLock", this.station._id, res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.locked = res.data;
- new Toast({
- content: `Toggled queue lock successfully to ${res.data}`,
- timeout: 4000
- });
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- new Toast({
- content: "Failed to toggle queue lock.",
- timeout: 8000
- });
- return this.$refs.saveButton.handleFailedSave();
- });
- },
- updateThemeLocal(theme) {
- if (this.station.theme === theme) return;
- this.station.theme = theme;
- this.themeDropdownActive = false;
- },
- updateTheme() {
- this.$refs.saveButton.status = "disabled";
- this.socket.emit(
- "stations.updateTheme",
- this.station._id,
- this.station.theme,
- res => {
- new Toast({ content: res.message, timeout: 8000 });
- if (res.status === "success") {
- this.originalStation.theme = this.station.theme;
- return this.$refs.saveButton.handleSuccessfulSave();
- }
- return this.$refs.saveButton.handleFailedSave();
- }
- );
- },
- deleteStation() {
- this.socket.emit("stations.remove", this.station._id, res => {
- if (res.status === "success")
- this.closeModal({
- sector: "station",
- modal: "editStation"
- });
- return new Toast({ content: res.message, timeout: 8000 });
- });
- },
- blurGenreInput() {
- this.genreInputFocussed = false;
- },
- focusGenreInput() {
- this.genreInputFocussed = true;
- },
- keydownGenreInput() {
- clearTimeout(this.keydownGenreInputTimeout);
- this.keydownGenreInputTimeout = setTimeout(() => {
- if (this.genreInputValue.length > 1) {
- this.genreAutosuggestItems = this.genres.filter(genre => {
- return genre
- .toLowerCase()
- .startsWith(this.genreInputValue.toLowerCase());
- });
- } else this.genreAutosuggestItems = [];
- }, 1000);
- },
- focusGenreContainer() {
- this.genreAutosuggestContainerFocussed = true;
- },
- blurGenreContainer() {
- this.genreAutosuggestContainerFocussed = false;
- },
- selectGenreAutosuggest(value) {
- this.genreInputValue = value;
- },
- blurBlacklistGenreInput() {
- this.blacklistGenreInputFocussed = false;
- },
- focusBlacklistGenreInput() {
- this.blacklistGenreInputFocussed = true;
- },
- keydownBlacklistGenreInput() {
- clearTimeout(this.keydownBlacklistGenreInputTimeout);
- this.keydownBlacklistGenreInputTimeout = setTimeout(() => {
- if (this.blacklistGenreInputValue.length > 1) {
- this.blacklistGenreAutosuggestItems = this.genres.filter(
- genre => {
- return genre
- .toLowerCase()
- .startsWith(
- this.blacklistGenreInputValue.toLowerCase()
- );
- }
- );
- } else this.blacklistGenreAutosuggestItems = [];
- }, 1000);
- },
- focusBlacklistGenreContainer() {
- this.blacklistGenreAutosuggestContainerFocussed = true;
- },
- blurBlacklistGenreContainer() {
- this.blacklistGenreAutosuggestContainerFocussed = false;
- },
- selectBlacklistGenreAutosuggest(value) {
- this.blacklistGenreInputValue = value;
- },
- addTag(type) {
- if (type === "genres") {
- const genre = this.genreInputValue.toLowerCase().trim();
- if (this.station.genres.indexOf(genre) !== -1)
- return new Toast({
- content: "Genre already exists",
- timeout: 3000
- });
- if (genre) {
- this.station.genres.push(genre);
- this.genreInputValue = "";
- return false;
- }
- return new Toast({
- content: "Genre cannot be empty",
- timeout: 3000
- });
- }
- if (type === "blacklist-genres") {
- const genre = this.blacklistGenreInputValue
- .toLowerCase()
- .trim();
- if (this.station.blacklistedGenres.indexOf(genre) !== -1)
- return new Toast({
- content: "Blacklist genre already exists",
- timeout: 3000
- });
- if (genre) {
- this.station.blacklistedGenres.push(genre);
- this.blacklistGenreInputValue = "";
- return false;
- }
- return new Toast({
- content: "Blacklist genre cannot be empty",
- timeout: 3000
- });
- }
- return false;
- },
- removeTag(type, index) {
- if (type === "genres") this.station.genres.splice(index, 1);
- else if (type === "blacklist-genres")
- this.station.blacklistedGenres.splice(index, 1);
- },
- ...mapActions("modals/editStation", ["editStation"]),
- ...mapActions("modalVisibility", ["closeModal"])
- }
- };
- </script>
- <style lang="scss">
- .edit-station-modal .modal-card-foot {
- justify-content: flex-end;
- }
- </style>
- <style lang="scss" scoped>
- .night-mode {
- .modal-card,
- .modal-card-head,
- .modal-card-body,
- .modal-card-foot {
- background-color: var(--dark-grey-3);
- }
- .section {
- background-color: var(--dark-grey-3) !important;
- border: 0 !important;
- }
- .label,
- p,
- strong {
- color: var(--light-grey-2);
- }
- }
- .modal-card-title {
- text-align: center;
- margin-left: 24px;
- }
- .custom-modal-body {
- padding: 16px;
- display: flex;
- }
- .section {
- border: 1px solid var(--light-blue);
- background-color: var(--light-grey);
- border-radius: 5px;
- padding: 16px;
- }
- .left-section {
- width: 595px;
- display: grid;
- gap: 16px;
- grid-template-rows: min-content min-content auto;
- .control {
- input {
- width: 100%;
- height: 36px;
- }
- .add-button {
- width: 32px;
- &.blue {
- background-color: var(--primary-color) !important;
- }
- &.red {
- background-color: var(--red) !important;
- }
- i {
- font-size: 32px;
- }
- }
- }
- .col {
- > div {
- position: relative;
- }
- }
- .list-item-circle {
- width: 16px;
- height: 16px;
- border-radius: 8px;
- cursor: pointer;
- margin-right: 8px;
- float: left;
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- &.blue {
- background-color: var(--primary-color);
- i {
- color: var(--primary-color);
- }
- }
- &.red {
- background-color: var(--red);
- i {
- color: var(--red);
- }
- }
- i {
- font-size: 14px;
- margin-left: 1px;
- }
- }
- .list-item-circle:hover,
- .list-item-circle:focus {
- i {
- color: var(--white);
- }
- }
- .list-item > p {
- line-height: 16px;
- word-wrap: break-word;
- width: calc(100% - 24px);
- left: 24px;
- float: left;
- margin-bottom: 8px;
- }
- .list-item:last-child > p {
- margin-bottom: 0;
- }
- .autosuggest-container {
- position: absolute;
- background: var(--white);
- width: calc(100% + 1px);
- top: 57px;
- z-index: 200;
- overflow: auto;
- max-height: 100%;
- clear: both;
- .autosuggest-item {
- padding: 8px;
- display: block;
- border: 1px solid var(--light-grey-2);
- margin-top: -1px;
- line-height: 16px;
- cursor: pointer;
- -webkit-user-select: none;
- -ms-user-select: none;
- -moz-user-select: none;
- user-select: none;
- }
- .autosuggest-item:hover,
- .autosuggest-item:focus {
- background-color: var(--light-grey);
- }
- .autosuggest-item:first-child {
- border-top: none;
- }
- .autosuggest-item:last-child {
- border-radius: 0 0 3px 3px;
- }
- }
- }
- .right-section {
- width: 157px;
- min-height: 515px;
- margin-left: 16px;
- display: grid;
- gap: 16px;
- grid-template-rows: min-content min-content min-content;
- .button-wrapper {
- display: flex;
- flex-direction: column;
- button {
- width: 100%;
- height: 36px;
- border: 0;
- border-radius: 3px;
- font-size: 18px;
- color: var(--white);
- box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.25);
- display: block;
- text-align: center;
- justify-content: center;
- display: inline-flex;
- -ms-flex-align: center;
- align-items: center;
- -moz-user-select: none;
- user-select: none;
- cursor: pointer;
- margin-bottom: 10px;
- padding: 0;
- text-transform: capitalize;
- &.red {
- background-color: var(--red);
- }
- &.green {
- background-color: var(--green);
- }
- &.blue {
- background-color: var(--primary-color);
- }
- &.orange {
- background-color: var(--orange);
- }
- &.yellow {
- background-color: var(--yellow);
- }
- &.purple {
- background-color: var(--purple);
- }
- &.teal {
- background-color: var(--teal);
- }
- i {
- font-size: 20px;
- margin-right: 4px;
- }
- }
- }
- }
- .col {
- display: grid;
- grid-column-gap: 16px;
- }
- .col-1 {
- grid-template-columns: auto;
- }
- .col-2 {
- grid-template-columns: auto auto;
- }
- .slide-down-enter-active {
- transition: transform 0.25s;
- }
- .slide-down-enter {
- transform: translateY(-10px);
- }
- .modal-card {
- overflow: auto;
- }
- .modal-card-body {
- overflow: unset;
- }
- </style>
|