123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <div id="queue">
- <div
- id="queue-items"
- :class="{
- 'actionable-button-hidden': !actionableButtonVisible,
- 'scrollable-list': true
- }"
- >
- <queue-item
- v-for="(song, index) in songsList"
- :key="index + song.songId"
- :song="song"
- :station="{
- type: station.type,
- partyMode: station.partyMode
- }"
- />
- <p class="nothing-here-text" v-if="songsList.length < 1">
- There are no songs currently queued
- </p>
- </div>
- <button
- class="button is-primary tab-actionable-button"
- v-if="
- loggedIn &&
- ((station.type === 'community' &&
- station.partyMode &&
- ((station.locked && isOwnerOnly()) ||
- !station.locked ||
- (station.locked &&
- isAdminOnly() &&
- dismissedWarning))) ||
- station.type === 'official')
- "
- @click="
- openModal({
- sector: 'station',
- modal: 'addSongToQueue'
- })
- "
- >
- <i class="material-icons icon-with-button">queue</i>
- <span class="optional-desktop-only-text"> Add Song To Queue </span>
- </button>
- <div
- id="queue-locked"
- v-if="station.type === 'community' && station.locked"
- >
- <button
- v-if="isAdminOnly() && !isOwnerOnly() && !dismissedWarning"
- class="button tab-actionable-button"
- @click="dismissedWarning = true"
- >
- THIS STATION'S QUEUE IS LOCKED.
- </button>
- <button
- v-if="!isAdminOnly() && !isOwnerOnly()"
- class="button tab-actionable-button"
- >
- THIS STATION'S QUEUE IS LOCKED.
- </button>
- </div>
- </div>
- </template>
- <script>
- import { mapActions, mapState } from "vuex";
- import Toast from "toasters";
- import QueueItem from "./QueueItem.vue";
- export default {
- components: { QueueItem },
- data() {
- return {
- dismissedWarning: false,
- actionableButtonVisible: false
- };
- },
- computed: mapState({
- loggedIn: state => state.user.auth.loggedIn,
- userId: state => state.user.auth.userId,
- userRole: state => state.user.auth.role,
- station: state => state.station.station,
- songsList: state => state.station.songsList,
- noSong: state => state.station.noSong
- }),
- updated() {
- // check if actionable button is visible, if not: set max-height of queue items to 100%
- if (
- document
- .getElementById("queue")
- .querySelectorAll(".tab-actionable-button").length > 0
- )
- this.actionableButtonVisible = true;
- else this.actionableButtonVisible = false;
- },
- methods: {
- isOwnerOnly() {
- return this.loggedIn && this.userId === this.station.owner;
- },
- isAdminOnly() {
- return this.loggedIn && this.userRole === "admin";
- },
- removeFromQueue(songId) {
- window.socket.emit(
- "stations.removeFromQueue",
- this.station._id,
- songId,
- res => {
- if (res.status === "success") {
- new Toast({
- content:
- "Successfully removed song from the queue.",
- timeout: 4000
- });
- } else new Toast({ content: res.message, timeout: 8000 });
- }
- );
- },
- ...mapActions("modalVisibility", ["openModal"])
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../../../../styles/global.scss";
- .night-mode {
- #queue {
- background-color: $night-mode-bg-secondary !important;
- border: 0 !important;
- }
- }
- #queue {
- background-color: #fff;
- border-radius: 0 0 5px 5px;
- .actionable-button-hidden {
- max-height: 100%;
- }
- .queue-item:not(:last-of-type) {
- margin-bottom: 10px;
- }
- #queue-locked {
- display: flex;
- justify-content: center;
- }
- }
- </style>
|