Browse Source

refactor: Import album tweaks

Owen Diffey 2 years ago
parent
commit
994e862784

+ 0 - 3
backend/logic/actions/users.js

@@ -220,11 +220,8 @@ CacheModule.runJob("SUB", {
 CacheModule.runJob("SUB", {
 	channel: "longJob.added",
 	cb: ({ jobId, userId }) => {
-		console.log(1111, jobId, userId);
 		WSModule.runJob("SOCKETS_FROM_USER", { userId }).then(sockets => {
-			console.log(2222, sockets.length);
 			sockets.forEach(socket => {
-				console.log(3333);
 				socket.dispatch("keep.event:longJob.added", {
 					data: {
 						jobId

+ 0 - 75
frontend/src/components/modals/ImportAlbum.vue

@@ -224,22 +224,6 @@
 					</div>
 				</div>
 				<div class="import-youtube-playlist">
-					<p class="control is-expanded">
-						<input
-							class="input"
-							type="text"
-							placeholder="Enter YouTube Playlist URL here..."
-							v-model="search.playlist.query"
-							@keyup.enter="importPlaylist()"
-						/>
-					</p>
-					<button
-						class="button is-fullwidth is-info"
-						@click="importPlaylist()"
-					>
-						<i class="material-icons icon-with-button">publish</i
-						>Import
-					</button>
 					<button
 						class="button is-fullwidth is-danger"
 						@click="resetTrackSongs()"
@@ -343,12 +327,6 @@ export default {
 			isImportingPlaylist: false,
 			trackSongs: [],
 			songsToEdit: [],
-			// currentEditSongIndex: 0,
-			search: {
-				playlist: {
-					query: ""
-				}
-			},
 			discogsQuery: "",
 			discogs: {
 				apiResults: [],
@@ -459,59 +437,6 @@ export default {
 		log(evt) {
 			window.console.log(evt);
 		},
-		importPlaylist() {
-			if (this.isImportingPlaylist)
-				return new Toast("A playlist is already importing.");
-			this.isImportingPlaylist = true;
-
-			// import query is blank
-			if (!this.search.playlist.query)
-				return new Toast("Please enter a YouTube playlist URL.");
-
-			const regex = /[\\?&]list=([^&#]*)/;
-			const splitQuery = regex.exec(this.search.playlist.query);
-
-			if (!splitQuery) {
-				return new Toast({
-					content: "Please enter a valid YouTube playlist URL.",
-					timeout: 4000
-				});
-			}
-
-			// don't give starting import message instantly in case of instant error
-			setTimeout(() => {
-				if (this.isImportingPlaylist) {
-					new Toast(
-						"Starting to import your playlist. This can take some time to do."
-					);
-				}
-			}, 750);
-
-			return this.socket.dispatch(
-				"songs.requestSet",
-				this.search.playlist.query,
-				false,
-				true,
-				res => {
-					this.isImportingPlaylist = false;
-					const songs = res.songs.filter(song => !song.verified);
-					const songsAlreadyVerified =
-						res.songs.length - songs.length;
-					this.setPlaylistSongs(songs);
-					if (this.discogsAlbum.tracks) {
-						this.trackSongs = this.discogsAlbum.tracks.map(
-							() => []
-						);
-						this.tryToAutoMove();
-					}
-					if (songsAlreadyVerified > 0)
-						new Toast(
-							`${songsAlreadyVerified} songs were already verified, skipping those.`
-						);
-					return new Toast({ content: res.message, timeout: 20000 });
-				}
-			);
-		},
 		tryToAutoMove() {
 			const { tracks } = this.discogsAlbum;
 			const { trackSongs } = this;

+ 1 - 11
frontend/src/pages/Admin/Songs/Import.vue

@@ -473,16 +473,6 @@ export default {
 			socket: "websockets/getSocket"
 		})
 	},
-	mounted() {
-		// this.socket.dispatch("youtube.getRequestSetAdminLongJobs", {
-		// 	cb: res => {
-		// 		console.log(111, res);
-		// 	},
-		// 	onProgress: res => {
-		// 		console.log(222, res);
-		// 	}
-		// });
-	},
 	methods: {
 		openAdvancedTable(importJob) {
 			const filter = {
@@ -491,7 +481,7 @@ export default {
 						data: importJob._id,
 						filter: {
 							name: "importJob",
-							displayName: "Import%20job",
+							displayName: "Import Job",
 							property: "importJob",
 							filterTypes: ["special"],
 							defaultFilterType: "special"

+ 1 - 1
frontend/src/pages/Admin/YouTube/Videos.vue

@@ -286,7 +286,7 @@ export default {
 				},
 				{
 					name: "importJob",
-					displayName: "Import job",
+					displayName: "Import Job",
 					property: "importJob",
 					filterTypes: ["special"],
 					defaultFilterType: "special"

+ 3 - 9
frontend/src/store/modules/longJobs.js

@@ -1,14 +1,7 @@
 /* eslint no-param-reassign: 0 */
 
 const state = {
-	activeJobs: [
-		// {
-		// 	id: 1,
-		// 	name: "test",
-		// 	status: "success",
-		// 	message: "test"
-		// }
-	],
+	activeJobs: [],
 	removedJobIds: []
 };
 
@@ -27,7 +20,8 @@ const mutations = {
 				state.activeJobs.push({
 					id,
 					name,
-					status
+					status,
+					message
 				});
 			else
 				state.activeJobs.forEach((activeJob, index) => {

+ 1 - 8
frontend/src/store/modules/modals/importAlbum.js

@@ -19,8 +19,6 @@ export default {
 		toggleDiscogsAlbum: ({ commit }) => {
 			commit("toggleDiscogsAlbum");
 		},
-		setPlaylistSongs: ({ commit }, playlistSongs) =>
-			commit("setPlaylistSongs", playlistSongs),
 		updatePlaylistSongs: ({ commit }, playlistSongs) =>
 			commit("updatePlaylistSongs", playlistSongs),
 		updateEditingSongs: ({ commit }, editingSongs) =>
@@ -33,6 +31,7 @@ export default {
 	},
 	mutations: {
 		init(state, { songs }) {
+			state.originalPlaylistSongs = JSON.parse(JSON.stringify(songs));
 			state.playlistSongs = JSON.parse(JSON.stringify(songs));
 		},
 		showDiscogsTab(state, tab) {
@@ -50,12 +49,6 @@ export default {
 		toggleDiscogsAlbum(state) {
 			state.discogsAlbum.expanded = !state.discogsAlbum.expanded;
 		},
-		setPlaylistSongs(state, playlistSongs) {
-			state.originalPlaylistSongs = JSON.parse(
-				JSON.stringify(playlistSongs)
-			);
-			state.playlistSongs = JSON.parse(JSON.stringify(playlistSongs));
-		},
 		updatePlaylistSongs(state, playlistSongs) {
 			state.playlistSongs = JSON.parse(JSON.stringify(playlistSongs));
 		},