瀏覽代碼

feat: added ability to open importAlbum from youtube/videos page

Kristian Vos 2 年之前
父節點
當前提交
f5135e6cfc

+ 4 - 0
frontend/src/components/AdvancedTable.vue

@@ -2376,6 +2376,10 @@ export default {
 		.delete-icon {
 			color: var(--dark-red);
 		}
+
+		.import-album-icon {
+			color: var(--purple);
+		}
 	}
 }
 </style>

+ 20 - 0
frontend/src/pages/Admin/YouTube/Videos.vue

@@ -115,6 +115,15 @@
 					>
 						music_note
 					</i>
+					<i
+						class="material-icons import-album-icon"
+						@click.prevent="importAlbum(slotProps.item)"
+						content="Import album from videos"
+						v-tippy
+						tabindex="0"
+					>
+						album
+					</i>
 					<i
 						class="material-icons delete-icon"
 						@click.prevent="
@@ -324,6 +333,17 @@ export default {
 				this.openModal({ modal: "editSongs", data: { songs } });
 			}
 		},
+		importAlbum(selectedRows) {
+			const songs = selectedRows.map(
+				({ youtubeId, title, author, duration }) => ({
+					youtubeId,
+					title,
+					artists: [author],
+					duration
+				})
+			);
+			this.openModal({ modal: "importAlbum", data: { songs } });
+		},
 		removeVideos(videoIds) {
 			this.socket.dispatch(
 				"youtube.removeVideos",

+ 4 - 0
frontend/src/store/modules/modals/importAlbum.js

@@ -12,6 +12,7 @@ export default {
 	},
 	getters: {},
 	actions: {
+		init: ({ commit }, data) => commit("init", data),
 		showDiscogsTab: ({ commit }, tab) => commit("showDiscogsTab", tab),
 		selectDiscogsAlbum: ({ commit }, discogsAlbum) =>
 			commit("selectDiscogsAlbum", discogsAlbum),
@@ -31,6 +32,9 @@ export default {
 			commit("updatePlaylistSong", updatedSong)
 	},
 	mutations: {
+		init(state, { songs }) {
+			state.playlistSongs = JSON.parse(JSON.stringify(songs));
+		},
 		showDiscogsTab(state, tab) {
 			state.discogsTab = tab;
 		},