|
@@ -33,7 +33,7 @@ const props = defineProps({
|
|
|
const tabs = ref([]);
|
|
|
|
|
|
const userAuthStore = useUserAuthStore();
|
|
|
-const { loggedIn, userId, role } = storeToRefs(userAuthStore);
|
|
|
+const { loggedIn } = storeToRefs(userAuthStore);
|
|
|
|
|
|
const { socket } = useWebsocketsStore();
|
|
|
|
|
@@ -60,7 +60,8 @@ const {
|
|
|
updateStationPaused,
|
|
|
updateCurrentSong,
|
|
|
updateStation,
|
|
|
- updateIsFavorited
|
|
|
+ updateIsFavorited,
|
|
|
+ hasPermission
|
|
|
} = manageStationStore;
|
|
|
|
|
|
const { closeCurrentModal } = useModalsStore();
|
|
@@ -71,20 +72,14 @@ const showTab = payload => {
|
|
|
manageStationStore.showTab(payload);
|
|
|
};
|
|
|
|
|
|
-const isOwner = () =>
|
|
|
- loggedIn.value && station.value && userId.value === station.value.owner;
|
|
|
-
|
|
|
-const isAdmin = () => loggedIn.value && role.value === "admin";
|
|
|
-
|
|
|
-const isOwnerOrAdmin = () => isOwner() || isAdmin();
|
|
|
-
|
|
|
const canRequest = () =>
|
|
|
station.value &&
|
|
|
loggedIn.value &&
|
|
|
station.value.requests &&
|
|
|
station.value.requests.enabled &&
|
|
|
(station.value.requests.access === "user" ||
|
|
|
- (station.value.requests.access === "owner" && isOwnerOrAdmin()));
|
|
|
+ (station.value.requests.access === "owner" &&
|
|
|
+ hasPermission("stations.addToQueue")));
|
|
|
|
|
|
const removeStation = () => {
|
|
|
socket.dispatch("stations.remove", stationId.value, res => {
|
|
@@ -107,8 +102,10 @@ watch(
|
|
|
() => station.value.requests,
|
|
|
() => {
|
|
|
if (tab.value === "request" && !canRequest()) {
|
|
|
- if (isOwnerOrAdmin()) showTab("settings");
|
|
|
- else if (!(sector.value === "home" && !isOwnerOrAdmin()))
|
|
|
+ if (hasPermission("stations.update")) showTab("settings");
|
|
|
+ else if (
|
|
|
+ !(sector.value === "home" && !hasPermission("stations.update"))
|
|
|
+ )
|
|
|
closeCurrentModal();
|
|
|
}
|
|
|
}
|
|
@@ -126,7 +123,7 @@ onMounted(() => {
|
|
|
if (res.status === "success") {
|
|
|
editStation(res.data.station);
|
|
|
|
|
|
- if (!isOwnerOrAdmin()) showTab("request");
|
|
|
+ if (!hasPermission("stations.update")) showTab("request");
|
|
|
|
|
|
const currentSong = res.data.station.currentSong
|
|
|
? res.data.station.currentSong
|
|
@@ -154,7 +151,7 @@ onMounted(() => {
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- if (isOwnerOrAdmin()) {
|
|
|
+ if (hasPermission("stations.getPlaylist")) {
|
|
|
socket.dispatch(
|
|
|
"playlists.getPlaylistForStation",
|
|
|
stationId.value,
|
|
@@ -311,7 +308,7 @@ onMounted(() => {
|
|
|
{ modalUuid: props.modalUuid }
|
|
|
);
|
|
|
|
|
|
- if (isOwnerOrAdmin()) {
|
|
|
+ if (hasPermission("stations.getPlaylist")) {
|
|
|
socket.on(
|
|
|
"event:playlist.song.added",
|
|
|
res => {
|
|
@@ -381,7 +378,7 @@ onBeforeUnmount(() => {
|
|
|
() => {}
|
|
|
);
|
|
|
|
|
|
- if (isOwnerOrAdmin()) showTab("settings");
|
|
|
+ if (hasPermission("stations.update")) showTab("settings");
|
|
|
clearStation();
|
|
|
|
|
|
// Delete the Pinia store that was created for this modal, after all other cleanup tasks are performed
|
|
@@ -393,16 +390,20 @@ onBeforeUnmount(() => {
|
|
|
<modal
|
|
|
v-if="station"
|
|
|
:title="
|
|
|
- sector === 'home' && !isOwnerOrAdmin()
|
|
|
+ sector === 'home' && !hasPermission('stations.update')
|
|
|
? 'View Queue'
|
|
|
- : !isOwnerOrAdmin()
|
|
|
+ : !hasPermission('stations.update')
|
|
|
? 'Add Song to Queue'
|
|
|
: 'Manage Station'
|
|
|
"
|
|
|
:style="`--primary-color: var(--${station.theme})`"
|
|
|
class="manage-station-modal"
|
|
|
- :size="isOwnerOrAdmin() || sector !== 'home' ? 'wide' : null"
|
|
|
- :split="isOwnerOrAdmin() || sector !== 'home'"
|
|
|
+ :size="
|
|
|
+ hasPermission('stations.update') || sector !== 'home'
|
|
|
+ ? 'wide'
|
|
|
+ : null
|
|
|
+ "
|
|
|
+ :split="hasPermission('stations.update') || sector !== 'home'"
|
|
|
>
|
|
|
<template #body v-if="station && station._id">
|
|
|
<div class="left-section">
|
|
@@ -412,12 +413,19 @@ onBeforeUnmount(() => {
|
|
|
:station="station"
|
|
|
:station-paused="stationPaused"
|
|
|
:show-go-to-station="sector !== 'station'"
|
|
|
+ :sector="'manageStation'"
|
|
|
+ :modal-uuid="modalUuid"
|
|
|
/>
|
|
|
</div>
|
|
|
- <div v-if="isOwnerOrAdmin() || sector !== 'home'">
|
|
|
+ <div
|
|
|
+ v-if="
|
|
|
+ hasPermission('stations.update') ||
|
|
|
+ sector !== 'home'
|
|
|
+ "
|
|
|
+ >
|
|
|
<div class="tab-selection">
|
|
|
<button
|
|
|
- v-if="isOwnerOrAdmin()"
|
|
|
+ v-if="hasPermission('stations.update')"
|
|
|
class="button is-default"
|
|
|
:class="{ selected: tab === 'settings' }"
|
|
|
:ref="el => (tabs['settings-tab'] = el)"
|
|
@@ -436,7 +444,8 @@ onBeforeUnmount(() => {
|
|
|
</button>
|
|
|
<button
|
|
|
v-if="
|
|
|
- isOwnerOrAdmin() && station.autofill.enabled
|
|
|
+ hasPermission('stations.view.manage') &&
|
|
|
+ station.autofill.enabled
|
|
|
"
|
|
|
class="button is-default"
|
|
|
:class="{ selected: tab === 'autofill' }"
|
|
@@ -446,7 +455,7 @@ onBeforeUnmount(() => {
|
|
|
Autofill
|
|
|
</button>
|
|
|
<button
|
|
|
- v-if="isOwnerOrAdmin()"
|
|
|
+ v-if="hasPermission('stations.view.manage')"
|
|
|
class="button is-default"
|
|
|
:class="{ selected: tab === 'blacklist' }"
|
|
|
:ref="el => (tabs['blacklist-tab'] = el)"
|
|
@@ -456,7 +465,7 @@ onBeforeUnmount(() => {
|
|
|
</button>
|
|
|
</div>
|
|
|
<settings
|
|
|
- v-if="isOwnerOrAdmin()"
|
|
|
+ v-if="hasPermission('stations.update')"
|
|
|
class="tab"
|
|
|
v-show="tab === 'settings'"
|
|
|
:modal-uuid="modalUuid"
|
|
@@ -471,7 +480,10 @@ onBeforeUnmount(() => {
|
|
|
:modal-uuid="modalUuid"
|
|
|
/>
|
|
|
<playlist-tab-base
|
|
|
- v-if="isOwnerOrAdmin() && station.autofill.enabled"
|
|
|
+ v-if="
|
|
|
+ hasPermission('stations.view.manage') &&
|
|
|
+ station.autofill.enabled
|
|
|
+ "
|
|
|
class="tab"
|
|
|
v-show="tab === 'autofill'"
|
|
|
:type="'autofill'"
|
|
@@ -485,7 +497,7 @@ onBeforeUnmount(() => {
|
|
|
</template>
|
|
|
</playlist-tab-base>
|
|
|
<playlist-tab-base
|
|
|
- v-if="isOwnerOrAdmin()"
|
|
|
+ v-if="hasPermission('stations.view.manage')"
|
|
|
class="tab"
|
|
|
v-show="tab === 'blacklist'"
|
|
|
:type="'blacklist'"
|
|
@@ -519,11 +531,17 @@ onBeforeUnmount(() => {
|
|
|
</div>
|
|
|
</template>
|
|
|
<template #footer>
|
|
|
- <div v-if="isOwnerOrAdmin()" class="right">
|
|
|
- <quick-confirm @confirm="resetQueue()">
|
|
|
+ <div class="right">
|
|
|
+ <quick-confirm
|
|
|
+ v-if="hasPermission('stations.removeFromQueue')"
|
|
|
+ @confirm="resetQueue()"
|
|
|
+ >
|
|
|
<a class="button is-danger">Reset queue</a>
|
|
|
</quick-confirm>
|
|
|
- <quick-confirm @confirm="removeStation()">
|
|
|
+ <quick-confirm
|
|
|
+ v-if="hasPermission('stations.resetQueue')"
|
|
|
+ @confirm="removeStation()"
|
|
|
+ >
|
|
|
<button class="button is-danger">Delete station</button>
|
|
|
</quick-confirm>
|
|
|
</div>
|