Bläddra i källkod

feat: added ability to open importAlbum from admin/songs page, and improved importAlbum on admin/youtube/videos page

Kristian Vos 2 år sedan
förälder
incheckning
6b73f0cb97
2 ändrade filer med 38 tillägg och 10 borttagningar
  1. 25 1
      frontend/src/pages/Admin/Songs/index.vue
  2. 13 9
      frontend/src/pages/Admin/YouTube/Videos.vue

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

@@ -187,6 +187,15 @@
 							cancel
 						</i>
 					</quick-confirm>
+					<i
+						class="material-icons import-album-icon"
+						@click.prevent="importAlbum(slotProps.item)"
+						content="Import Album"
+						v-tippy
+						tabindex="0"
+					>
+						album
+					</i>
 					<i
 						class="material-icons tag-songs-icon"
 						@click.prevent="setTags(slotProps.item)"
@@ -264,7 +273,7 @@ export default {
 				{
 					name: "options",
 					displayName: "Options",
-					properties: ["_id", "verified"],
+					properties: ["_id", "verified", "youtubeId"],
 					sortable: false,
 					hidable: false,
 					resizable: false,
@@ -598,6 +607,21 @@ export default {
 				}
 			);
 		},
+		importAlbum(selectedRows) {
+			const youtubeIds = selectedRows.map(({ youtubeId }) => youtubeId);
+			this.socket.dispatch(
+				"songs.getSongsFromYoutubeIds",
+				youtubeIds,
+				res => {
+					if (res.status === "success") {
+						this.openModal({
+							modal: "importAlbum",
+							data: { songs: res.data.songs }
+						});
+					}
+				}
+			);
+		},
 		setTags(selectedRows) {
 			this.openModal({
 				modal: "bulkActions",

+ 13 - 9
frontend/src/pages/Admin/YouTube/Videos.vue

@@ -174,7 +174,7 @@ export default {
 				{
 					name: "options",
 					displayName: "Options",
-					properties: ["_id"],
+					properties: ["_id", "youtubeId"],
 					sortable: false,
 					hidable: false,
 					resizable: false,
@@ -334,15 +334,19 @@ export default {
 			}
 		},
 		importAlbum(selectedRows) {
-			const songs = selectedRows.map(
-				({ youtubeId, title, author, duration }) => ({
-					youtubeId,
-					title,
-					artists: [author],
-					duration
-				})
+			const youtubeIds = selectedRows.map(({ youtubeId }) => youtubeId);
+			this.socket.dispatch(
+				"songs.getSongsFromYoutubeIds",
+				youtubeIds,
+				res => {
+					if (res.status === "success") {
+						this.openModal({
+							modal: "importAlbum",
+							data: { songs: res.data.songs }
+						});
+					} else new Toast("Could not get songs.");
+				}
 			);
-			this.openModal({ modal: "importAlbum", data: { songs } });
 		},
 		removeVideos(videoIds) {
 			this.socket.dispatch(