123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428 |
- <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>
- <!-- Choose a playlist -->
- <div
- v-if="
- station.type === 'community' &&
- !station.partyMode &&
- playlists.length > 0
- "
- >
- <hr style="margin: 10px 0 20px 0" />
- <h4 class="section-title">Choose a playlist</h4>
- <p class="section-description">
- Choose one of your playlists to add to the queue.
- </p>
- <br />
- <div id="playlists">
- <playlist-item
- :playlist="playlist"
- v-for="(playlist, index) in playlists"
- :key="index"
- >
- <div slot="actions">
- <a
- class="button is-danger"
- href="#"
- @click="deselectPlaylist()"
- v-if="isPlaylistSelected(playlist._id)"
- >
- <i
- class="material-icons icon-with-button"
- >stop</i
- >
- Stop playing
- </a>
- <a
- class="button is-success"
- href="#"
- @click="selectPlaylist(playlist._id)"
- v-else
- ><i
- class="material-icons icon-with-button"
- >play_arrow</i
- >Play in queue
- </a>
- </div>
- </playlist-item>
- </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"
- style="text-transform: capitalize"
- @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
- style="text-transform: capitalize"
- :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>
- <button class="button is-success" @click="update()">
- Update Settings
- </button>
- <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 PlaylistItem from "../ui/PlaylistItem.vue";
- import Modal from "../Modal.vue";
- import io from "../../io";
- import validation from "../../validation";
- export default {
- components: { Modal, PlaylistItem },
- 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"
- }
- },
- playlists: []
- };
- },
- computed: {
- // ...mapState("admin/stations", {
- // stations: state => state.stations
- // }),
- ...mapState("editStationModal", {
- 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.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"
- });
- }
- });
- this.socket.emit("playlists.indexMyPlaylists", true, res => {
- if (res.status === "success") this.playlists = res.data;
- });
- this.socket.on("event:playlist.create", playlist => {
- this.playlists.push(playlist);
- });
- this.socket.on("event:playlist.delete", playlistId => {
- this.playlists.forEach((playlist, index) => {
- if (playlist._id === playlistId) {
- this.playlists.splice(index, 1);
- }
- });
- });
- this.socket.on("event:playlist.addSong", data => {
- this.playlists.forEach((playlist, index) => {
- if (playlist._id === data.playlistId) {
- this.playlists[index].songs.push(data.song);
- }
- });
- });
- this.socket.on("event:playlist.removeSong", data => {
- this.playlists.forEach((playlist, index) => {
- if (playlist._id === data.playlistId) {
- this.playlists[index].songs.forEach((song, index2) => {
- if (song.songId === data.songId) {
- this.playlists[index].songs.splice(index2, 1);
- }
- });
- }
- });
- });
- this.socket.on("event:playlist.updateDisplayName", data => {
- this.playlists.forEach((playlist, index) => {
- if (playlist._id === data.playlistId) {
- this.playlists[index].displayName = data.displayName;
- }
- });
- });
- return socket;
- });
- },
- methods: {
- isPlaylistSelected(id) {
- // TODO Also change this once it changes for a station
- if (
- this.originalStation &&
- this.originalStation.privatePlaylist === id
- )
- return true;
- return false;
- },
- selectPlaylist(playlistId) {
- this.socket.emit(
- "stations.selectPrivatePlaylist",
- this.originalStation._id,
- playlistId,
- res => {
- if (res.status === "failure")
- return new Toast({
- content: res.message,
- timeout: 8000
- });
- return new Toast({ content: res.message, timeout: 4000 });
- }
- );
- },
- deselectPlaylist() {
- this.socket.emit(
- "stations.deselectPrivatePlaylist",
- this.originalStation._id,
- res => {
- if (res.status === "failure")
- return new Toast({
- content: res.message,
- timeout: 8000
- });
- return new Toast({ content: res.message, timeout: 4000 });
- }
- );
- },
- update() {
- if (this.originalStation.name !== this.station.name)
- this.updateName();
- if (this.originalStation.displayName !== this.station.displayName)
- this.updateDisplayName();
- if (this.originalStation.description !== this.station.description)
- this.updateDescription();
- if (this.originalStation.privacy !== this.station.privacy)
- this.updatePrivacy();
- if (
- this.originalStation.type === "community" &&
- this.originalStation.partyMode !== this.station.partyMode
- )
- this.updatePartyMode();
- if (
- this.originalStation.type === "community" &&
- this.station.partyMode &&
- this.originalStation.locked !== this.station.locked
- )
- this.updateQueueLock();
- if (
- this.originalStation.genres.toString() !==
- this.station.genres.toString()
- )
- this.updateGenres();
- if (
- this.originalStation.blacklistedGenres.toString() !==
- this.station.blacklistedGenres.toString()
- )
- this.updateBlacklistedGenres();
- if (this.originalStation.theme !== this.station.theme)
- this.updateTheme();
- },
- 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
- });
- return this.socket.emit(
- "stations.updateName",
- this.station._id,
- name,
- res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.name = name;
- else {
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[index].name = name;
- return name;
- }
- return false;
- });
- }
- }
- new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- 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
- });
- return this.socket.emit(
- "stations.updateDisplayName",
- this.station._id,
- displayName,
- res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.displayName = displayName;
- else {
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[
- index
- ].displayName = displayName;
- return displayName;
- }
- return false;
- });
- }
- }
- new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- 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
- });
- return this.socket.emit(
- "stations.updateDescription",
- this.station._id,
- description,
- res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.description = description;
- else {
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[
- index
- ].description = description;
- return description;
- }
- return false;
- });
- }
- return new Toast({
- content: res.message,
- timeout: 4000
- });
- }
- return new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- updatePrivacyLocal(privacy) {
- if (this.station.privacy === privacy) return;
- this.station.privacy = privacy;
- this.privacyDropdownActive = false;
- },
- updatePrivacy() {
- this.socket.emit(
- "stations.updatePrivacy",
- this.station._id,
- this.station.privacy,
- res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.privacy = this.station.privacy;
- else {
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[
- index
- ].privacy = this.station.privacy;
- return this.station.privacy;
- }
- return false;
- });
- }
- return new Toast({
- content: res.message,
- timeout: 4000
- });
- }
- return new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- updateGenres() {
- this.socket.emit(
- "stations.updateGenres",
- this.station._id,
- this.station.genres,
- res => {
- if (res.status === "success") {
- const genres = JSON.parse(
- JSON.stringify(this.station.genres)
- );
- if (this.originalStation)
- this.originalStation.genres = genres;
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[index].genres = genres;
- return genres;
- }
- return false;
- });
- return new Toast({
- content: res.message,
- timeout: 4000
- });
- }
- return new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- updateBlacklistedGenres() {
- this.socket.emit(
- "stations.updateBlacklistedGenres",
- this.station._id,
- this.station.blacklistedGenres,
- res => {
- if (res.status === "success") {
- const blacklistedGenres = JSON.parse(
- JSON.stringify(this.station.blacklistedGenres)
- );
- if (this.originalStation)
- this.originalStation.blacklistedGenres = blacklistedGenres;
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[
- index
- ].blacklistedGenres = blacklistedGenres;
- return blacklistedGenres;
- }
- return false;
- });
- return new Toast({
- content: res.message,
- timeout: 4000
- });
- }
- return new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- updatePartyModeLocal(partyMode) {
- if (this.station.partyMode === partyMode) return;
- this.station.partyMode = partyMode;
- this.modeDropdownActive = false;
- },
- updatePartyMode() {
- this.socket.emit(
- "stations.updatePartyMode",
- this.station._id,
- this.station.partyMode,
- res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.partyMode = this.station.partyMode;
- // if (this.originalStation)
- // this.originalStation.partyMode = this.station.partyMode;
- // this.originalStations.forEach((station, index) => {
- // if (station._id === this.station._id) {
- // this.originalStations[
- // index
- // ].partyMode = this.station.partyMode;
- // return this.station.partyMode;
- // }
- // return false;
- // });
- return new Toast({
- content: res.message,
- timeout: 4000
- });
- }
- return new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- updateQueueLockLocal(locked) {
- if (this.station.locked === locked) return;
- this.station.locked = locked;
- this.queueLockDropdownActive = false;
- },
- updateQueueLock() {
- this.socket.emit("stations.toggleLock", this.station._id, res => {
- console.log(res);
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.locked = res.data;
- return new Toast({
- content: `Toggled queue lock succesfully to ${res.data}`,
- timeout: 4000
- });
- }
- return new Toast({
- content: "Failed to toggle queue lock.",
- timeout: 8000
- });
- });
- },
- updateThemeLocal(theme) {
- if (this.station.theme === theme) return;
- this.station.theme = theme;
- this.themeDropdownActive = false;
- },
- updateTheme() {
- this.socket.emit(
- "stations.updateTheme",
- this.station._id,
- this.station.theme,
- res => {
- if (res.status === "success") {
- if (this.originalStation)
- this.originalStation.theme = this.station.theme;
- else {
- this.originalStations.forEach((station, index) => {
- if (station._id === this.station._id) {
- this.originalStations[
- index
- ].theme = this.station.theme;
- return this.station.theme;
- }
- return false;
- });
- }
- return new Toast({
- content: res.message,
- timeout: 4000
- });
- }
- return new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- 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("editStationModal", ["editStation"]),
- ...mapActions("modals", ["closeModal"])
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../styles/global.scss";
- .night-mode {
- .modal-card,
- .modal-card-head,
- .modal-card-body,
- .modal-card-foot {
- background-color: $night-mode-bg-secondary;
- }
- .section {
- background-color: $night-mode-bg-secondary !important;
- border: 0 !important;
- }
- .label,
- p,
- strong {
- color: $night-mode-text;
- }
- }
- .modal-card-title {
- text-align: center;
- margin-left: 24px;
- }
- .custom-modal-body {
- padding: 16px;
- display: flex;
- }
- .section {
- border: 1px solid #a3e0ff;
- background-color: #f4f4f4;
- 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: $musare-blue !important;
- }
- &.red {
- background-color: $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: $musare-blue;
- i {
- color: $musare-blue;
- }
- }
- &.red {
- background-color: $red;
- i {
- color: $red;
- }
- }
- i {
- font-size: 14px;
- margin-left: 1px;
- }
- }
- .list-item-circle:hover,
- .list-item-circle:focus {
- i {
- color: 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: 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 #dbdbdb;
- 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: #eee;
- }
- .autosuggest-item:first-child {
- border-top: none;
- }
- .autosuggest-item:last-child {
- border-radius: 0 0 3px 3px;
- }
- }
- }
- .right-section {
- width: 157px;
- min-height: 375px;
- 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: 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;
- &.red {
- background-color: $red;
- }
- &.green {
- background-color: $green;
- }
- &.blue {
- background-color: $musare-blue;
- }
- &.orange {
- background-color: $light-orange;
- }
- &.yellow {
- background-color: $yellow;
- }
- 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);
- }
- #playlists {
- overflow: auto;
- .playlist:not(:last-of-type) {
- margin-bottom: 10px;
- }
- .button {
- width: 148px;
- }
- }
- .modal-card {
- overflow: auto;
- }
- .modal-card-body {
- overflow: unset;
- }
- </style>
|