123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <script setup lang="ts">
- import { computed } from "vue";
- import { useStore } from "vuex";
- import Toast from "toasters";
- const store = useStore();
- const props = defineProps({
- station: { type: Object, default: null },
- stationPaused: { type: Boolean, default: null },
- showManageStation: { type: Boolean, default: false },
- showGoToStation: { type: Boolean, default: false }
- });
- const loggedIn = computed(() => store.state.user.auth.loggedIn);
- const userId = computed(() => store.state.user.auth.userId);
- const role = computed(() => store.state.user.auth.role);
- const { socket } = store.state.websockets;
- function isOwnerOnly() {
- return loggedIn.value && userId.value === props.station.owner;
- }
- function isAdminOnly() {
- return loggedIn.value && role.value === "admin";
- }
- function isOwnerOrAdmin() {
- return isOwnerOnly() || isAdminOnly();
- }
- function resumeStation() {
- socket.dispatch("stations.resume", props.station._id, data => {
- if (data.status !== "success") new Toast(`Error: ${data.message}`);
- else new Toast("Successfully resumed the station.");
- });
- }
- function pauseStation() {
- socket.dispatch("stations.pause", props.station._id, data => {
- if (data.status !== "success") new Toast(`Error: ${data.message}`);
- else new Toast("Successfully paused the station.");
- });
- }
- function skipStation() {
- socket.dispatch("stations.forceSkip", props.station._id, data => {
- if (data.status !== "success") new Toast(`Error: ${data.message}`);
- else new Toast("Successfully skipped the station's current song.");
- });
- }
- function favoriteStation() {
- socket.dispatch("stations.favoriteStation", props.station._id, res => {
- if (res.status === "success") {
- new Toast("Successfully favorited station.");
- } else new Toast(res.message);
- });
- }
- function unfavoriteStation() {
- socket.dispatch("stations.unfavoriteStation", props.station._id, res => {
- if (res.status === "success") {
- new Toast("Successfully unfavorited station.");
- } else new Toast(res.message);
- });
- }
- const openModal = payload =>
- store.dispatch("modalVisibility/openModal", payload);
- </script>
- <template>
- <div class="about-station-container">
- <div class="station-info">
- <div class="row station-name">
- <h1>{{ station.displayName }}</h1>
- <i
- v-if="station.type === 'official'"
- class="material-icons verified-station"
- content="Verified Station"
- v-tippy
- >
- check_circle
- </i>
- <a>
- <!-- Favorite Station Button -->
- <i
- v-if="loggedIn && station.isFavorited"
- @click.prevent="unfavoriteStation()"
- content="Unfavorite Station"
- v-tippy
- class="material-icons"
- >star</i
- >
- <i
- v-if="loggedIn && !station.isFavorited"
- @click.prevent="favoriteStation()"
- class="material-icons"
- content="Favorite Station"
- v-tippy
- >star_border</i
- >
- </a>
- </div>
- <p>{{ station.description }}</p>
- </div>
- <div class="admin-buttons">
- <!-- (Admin) Pause/Resume Button -->
- <button
- class="button is-danger"
- v-if="isOwnerOrAdmin() && stationPaused"
- @click="resumeStation()"
- >
- <i class="material-icons icon-with-button">play_arrow</i>
- <span> Resume Station </span>
- </button>
- <button
- class="button is-danger"
- @click="pauseStation()"
- v-if="isOwnerOrAdmin() && !stationPaused"
- >
- <i class="material-icons icon-with-button">pause</i>
- <span> Pause Station </span>
- </button>
- <!-- (Admin) Skip Button -->
- <button
- class="button is-danger"
- @click="skipStation()"
- v-if="isOwnerOrAdmin()"
- >
- <i class="material-icons icon-with-button">skip_next</i>
- <span> Force Skip </span>
- </button>
- <!-- (Admin) Station Settings Button -->
- <button
- class="button is-primary"
- @click="
- openModal({
- modal: 'manageStation',
- data: {
- stationId: station._id,
- sector: 'station'
- }
- })
- "
- v-if="isOwnerOrAdmin() && showManageStation"
- >
- <i class="material-icons icon-with-button">settings</i>
- <span> Manage Station </span>
- </button>
- <router-link
- v-if="showGoToStation"
- :to="{
- name: 'station',
- params: { id: station.name }
- }"
- class="button is-primary"
- >
- Go To Station
- </router-link>
- </div>
- </div>
- </template>
- <style lang="less">
- .night-mode {
- .about-station-container {
- background-color: var(--dark-grey-3) !important;
- }
- }
- .about-station-container {
- padding: 20px;
- display: flex;
- flex-direction: column;
- flex-grow: unset;
- .row {
- display: flex;
- flex-direction: row;
- max-width: 100%;
- }
- .station-info {
- .station-name {
- flex-direction: row !important;
- h1 {
- margin: 0;
- font-size: 36px;
- line-height: 0.8;
- text-overflow: ellipsis;
- overflow: hidden;
- }
- i {
- margin-left: 10px;
- font-size: 30px;
- color: var(--yellow);
- &.stationMode {
- padding-left: 10px;
- margin-left: auto;
- color: var(--primary-color);
- }
- }
- .verified-station {
- color: var(--primary-color);
- }
- }
- p {
- display: -webkit-box;
- max-width: 700px;
- margin-bottom: 10px;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 3;
- }
- }
- .admin-buttons {
- display: flex;
- .button {
- margin: 3px;
- }
- }
- }
- </style>
|