Browse Source

Minor tweaks and bug fixes

Owen Diffey 3 years ago
parent
commit
3516a16a1e

+ 1 - 1
backend/logic/actions/apis.js

@@ -144,7 +144,7 @@ export default {
 	 * @param {string} page - the room to join
 	 * @param {Function} cb - callback
 	 */
-	 joinManageStationRoom: isAdminRequired((session, page, cb) => {
+	joinManageStationRoom: isAdminRequired((session, page, cb) => {
 		if (page.startsWith("manage-station.")) {
 			WSModule.runJob("SOCKET_JOIN_ROOM", {
 				socketId: session.socketId,

+ 8 - 4
backend/logic/actions/stations.js

@@ -126,7 +126,7 @@ CacheModule.runJob("SUB", {
 	channel: "station.newPlayMode",
 	cb: data => {
 		const { stationId, playMode } = data;
-		
+
 		WSModule.runJob("EMIT_TO_ROOM", {
 			room: `station.${stationId}`,
 			args: ["event:playMode.updated", { data: { playMode } }]
@@ -457,7 +457,7 @@ CacheModule.runJob("SUB", {
 					socket.dispatch("event:station.updateTheme", { data: { stationId, theme: station.theme } });
 				});
 			});
-		});		
+		});
 	}
 });
 
@@ -2776,7 +2776,9 @@ export default {
 														type,
 														privacy: "private",
 														playlist: playlist._id,
-														currentSong: null
+														currentSong: null,
+														partyMode: false,
+														playMode: "random"
 													},
 													(err, station) => {
 														next(
@@ -2822,7 +2824,9 @@ export default {
 											privacy: "private",
 											owner: session.userId,
 											queue: [],
-											currentSong: null
+											currentSong: null,
+											partyMode: true,
+											playMode: "random"
 										},
 										(err, station) => {
 											next(err, station, null, null);

+ 8 - 6
backend/logic/stations.js

@@ -1158,12 +1158,14 @@ class _StationsModule extends CoreClass {
 						socketIds,
 						1,
 						(socketId, next) => {
-							WSModule.runJob("SOCKET_FROM_SOCKET_ID", { socketId }, this).then(socket => {
-								sockets.push(socket);
-								next();
-							}).catch(err => {
-								reject(err);
-							});
+							WSModule.runJob("SOCKET_FROM_SOCKET_ID", { socketId }, this)
+								.then(socket => {
+									sockets.push(socket);
+									next();
+								})
+								.catch(err => {
+									reject(err);
+								});
 						},
 						err => {
 							if (err) reject(err);

+ 14 - 0
frontend/prod.nginx.conf

@@ -22,4 +22,18 @@ http {
             try_files $uri /build/$uri /build/index.html =404;
         }
     }
+
+    location /backend {
+        proxy_set_header X-Real-IP  $remote_addr;
+        proxy_set_header X-Forwarded-For $remote_addr;
+        proxy_set_header Host $host;
+
+        proxy_http_version 1.1;
+        proxy_set_header Upgrade $http_upgrade;
+        proxy_set_header Connection "upgrade";
+        proxy_redirect off;
+
+        rewrite ^/backend/?(.*) /$1 break;
+        proxy_pass http://backend:8080; 
+    }
 }

+ 16 - 13
frontend/src/components/modals/ManageStation/Tabs/Playlists.vue

@@ -112,6 +112,13 @@
 						:show-owner="true"
 					>
 						<div class="icons-group" slot="actions">
+							<i
+								v-if="isExcluded(playlist._id)"
+								class="material-icons stop-icon"
+								content="This playlist is blacklisted in this station"
+								v-tippy
+								>play_disabled</i
+							>
 							<confirm
 								v-if="
 									(isOwnerOrAdmin() ||
@@ -134,7 +141,8 @@
 									(isOwnerOrAdmin() ||
 										(station.type === 'community' &&
 											station.partyMode)) &&
-										!isSelected(playlist._id)
+										!isSelected(playlist._id) &&
+										!isExcluded(playlist._id)
 								"
 								@click="selectPlaylist(playlist)"
 								class="material-icons play-icon"
@@ -149,7 +157,6 @@
 							<confirm
 								v-if="
 									isOwnerOrAdmin() &&
-										!isSelected(playlist._id) &&
 										!isExcluded(playlist._id)
 								"
 								@confirm="blacklistPlaylist(playlist._id)"
@@ -224,6 +231,13 @@
 							:playlist="playlist"
 						>
 							<div slot="actions">
+								<i
+									v-if="isExcluded(playlist._id)"
+									class="material-icons stop-icon"
+									content="This playlist is blacklisted in this station"
+									v-tippy
+									>play_disabled</i
+								>
 								<i
 									v-if="
 										station.type === 'community' &&
@@ -444,7 +458,6 @@ export default {
 			}
 		},
 		isSelected(id) {
-			// TODO Also change this once it changes for a station
 			let selected = false;
 			this.currentPlaylists.forEach(playlist => {
 				if (playlist._id === id) selected = true;
@@ -513,16 +526,6 @@ export default {
 				}
 			);
 		},
-		removeExcludedPlaylist(id) {
-			this.socket.dispatch(
-				"stations.removeExcludedPlaylist",
-				this.station._id,
-				id,
-				res => {
-					new Toast(res.message);
-				}
-			);
-		},
 		addPartyPlaylistSongToQueue() {
 			let isInQueue = false;
 			if (

+ 7 - 2
frontend/src/components/modals/Report.vue

@@ -283,8 +283,13 @@ h6 {
 	}
 }
 
-.edit-report-wrapper {
-	padding: 20px;
+.card {
+	border-radius: 5px;
+}
+
+.columns {
+	margin-left: unset;
+	margin-right: unset;
 }
 
 .is-highlight-active {

+ 1 - 1
frontend/src/pages/Admin/index.vue

@@ -23,7 +23,7 @@
 						class="tab unverifiedsongs"
 						to="/admin/unverifiedsongs"
 					>
-						<i class="material-icons">music_note</i>
+						<i class="material-icons">unpublished</i>
 						<span>&nbsp;Unverified Songs</span>
 					</router-link>
 				</li>

+ 0 - 5
frontend/src/pages/Admin/tabs/UnverifiedSongs.vue

@@ -262,11 +262,6 @@ export default {
 			});
 		},
 		hide(id) {
-			// eslint-disable-next-line
-			const dialogResult = window.confirm(
-				"Are you sure you want to hide this song?"
-			);
-			if (dialogResult !== true) return;
 			this.socket.dispatch("songs.hide", id, res => {
 				new Toast(res.message);
 			});

+ 0 - 5
frontend/src/pages/Admin/tabs/VerifiedSongs.vue

@@ -349,11 +349,6 @@ export default {
 			this.openModal("editSong");
 		},
 		remove(id) {
-			// eslint-disable-next-line
-			const dialogResult = window.confirm(
-				"Are you sure you want to unverify this song?"
-			);
-			if (dialogResult !== true) return;
 			this.socket.dispatch("songs.unverify", id, res => {
 				if (res.status === "success") new Toast(res.message);
 				else new Toast(res.message);

+ 96 - 20
frontend/src/pages/Station/Sidebar/Playlists.vue

@@ -20,13 +20,19 @@
 					class="item-draggable"
 				>
 					<div class="icons-group" slot="actions">
+						<i
+							v-if="isExcluded(playlist._id)"
+							class="material-icons stop-icon"
+							content="This playlist is blacklisted in this station"
+							v-tippy
+							>play_disabled</i
+						>
 						<i
 							v-if="
 								station.type === 'community' &&
-									(userId === station.owner ||
-										role === 'admin' ||
-										station.partyMode) &&
-									!isSelected(playlist._id)
+									(isOwnerOrAdmin() || station.partyMode) &&
+									!isSelected(playlist._id) &&
+									!isExcluded(playlist._id)
 							"
 							@click="selectPlaylist(playlist)"
 							class="material-icons play-icon"
@@ -38,24 +44,36 @@
 							v-tippy
 							>play_arrow</i
 						>
-						<i
+						<confirm
 							v-if="
 								station.type === 'community' &&
-									(userId === station.owner ||
-										role === 'admin' ||
-										station.partyMode) &&
+									(isOwnerOrAdmin() || station.partyMode) &&
 									isSelected(playlist._id)
 							"
-							@click="deselectPlaylist(playlist._id)"
-							class="material-icons stop-icon"
-							:content="
-								station.partyMode
-									? 'Stop requesting songs from this playlist'
-									: 'Stop playing songs from this playlist'
-							"
-							v-tippy
-							>stop</i
+							@confirm="deselectPlaylist(playlist._id)"
 						>
+							<i
+								class="material-icons stop-icon"
+								:content="
+									station.partyMode
+										? 'Stop requesting songs from this playlist'
+										: 'Stop playing songs from this playlist'
+								"
+								v-tippy
+								>stop</i
+							>
+						</confirm>
+						<confirm
+							v-if="isOwnerOrAdmin() && !isExcluded(playlist._id)"
+							@confirm="blacklistPlaylist(playlist._id)"
+						>
+							<i
+								class="material-icons stop-icon"
+								content="Blacklist Playlist"
+								v-tippy
+								>block</i
+							>
+						</confirm>
 						<i
 							@click="edit(playlist._id)"
 							class="material-icons edit-icon"
@@ -87,9 +105,10 @@ import Toast from "toasters";
 
 import PlaylistItem from "@/components/PlaylistItem.vue";
 import SortablePlaylists from "@/mixins/SortablePlaylists.vue";
+import Confirm from "@/components/Confirm.vue";
 
 export default {
-	components: { PlaylistItem },
+	components: { PlaylistItem, Confirm },
 	mixins: [SortablePlaylists],
 	computed: {
 		currentPlaylists() {
@@ -100,7 +119,8 @@ export default {
 		},
 		...mapState({
 			role: state => state.user.auth.role,
-			userId: state => state.user.auth.userId
+			userId: state => state.user.auth.userId,
+			loggedIn: state => state.user.auth.loggedIn
 		}),
 		...mapState("station", {
 			partyPlaylists: state => state.partyPlaylists,
@@ -118,8 +138,45 @@ export default {
 			if (res.status === "success") this.setPlaylists(res.data.playlists);
 			this.orderOfPlaylists = this.calculatePlaylistOrder(); // order in regards to the database
 		});
+
+		this.socket.on("event:station.includedPlaylist", res => {
+			const { playlist } = res.data;
+			this.includedPlaylists.push(playlist);
+		});
+
+		this.socket.on("event:station.excludedPlaylist", res => {
+			const { playlist } = res.data;
+			this.excludedPlaylists.push(playlist);
+		});
+
+		this.socket.on("event:station.removedIncludedPlaylist", res => {
+			const { playlistId } = res.data;
+			const playlistIndex = this.includedPlaylists
+				.map(playlist => playlist._id)
+				.indexOf(playlistId);
+			if (playlistIndex >= 0)
+				this.includedPlaylists.splice(playlistIndex, 1);
+		});
+
+		this.socket.on("event:station.removedExcludedPlaylist", res => {
+			const { playlistId } = res.data;
+			const playlistIndex = this.excludedPlaylists
+				.map(playlist => playlist._id)
+				.indexOf(playlistId);
+			if (playlistIndex >= 0)
+				this.excludedPlaylists.splice(playlistIndex, 1);
+		});
 	},
 	methods: {
+		isOwner() {
+			return this.loggedIn && this.userId === this.station.owner;
+		},
+		isAdmin() {
+			return this.loggedIn && this.role === "admin";
+		},
+		isOwnerOrAdmin() {
+			return this.isOwner() || this.isAdmin();
+		},
 		edit(id) {
 			this.editPlaylist(id);
 			this.openModal("editPlaylist");
@@ -172,13 +229,32 @@ export default {
 			}
 		},
 		isSelected(id) {
-			// TODO Also change this once it changes for a station
 			let selected = false;
 			this.currentPlaylists.forEach(playlist => {
 				if (playlist._id === id) selected = true;
 			});
 			return selected;
 		},
+		isExcluded(id) {
+			let selected = false;
+			this.excludedPlaylists.forEach(playlist => {
+				if (playlist._id === id) selected = true;
+			});
+			return selected;
+		},
+		blacklistPlaylist(id) {
+			if (this.isSelected(id)) {
+				this.deselectPlaylist(id);
+			}
+			this.socket.dispatch(
+				"stations.excludePlaylist",
+				this.station._id,
+				id,
+				res => {
+					new Toast(res.message);
+				}
+			);
+		},
 		addPartyPlaylistSongToQueue() {
 			let isInQueue = false;
 			if (