Browse Source

Added option for different playlist types

Kristian Vos 4 years ago
parent
commit
3849741f97

+ 2 - 1
backend/logic/actions/playlists.js

@@ -403,7 +403,8 @@ export default {
 							displayName,
 							songs,
 							createdBy: session.userId,
-							createdAt: Date.now()
+							createdAt: Date.now(),
+							type: "user"
 						},
 						next
 					);

+ 4 - 2
backend/logic/actions/users.js

@@ -425,7 +425,8 @@ export default {
 				(userId, next) => {
 					PlaylistsModule.runJob("CREATE_READ_ONLY_PLAYLIST", {
 						userId,
-						displayName: "Liked Songs"
+						displayName: "Liked Songs",
+						type: "user"
 					})
 						.then(likedSongsPlaylist => {
 							next(null, likedSongsPlaylist, userId);
@@ -437,7 +438,8 @@ export default {
 				(likedSongsPlaylist, userId, next) => {
 					PlaylistsModule.runJob("CREATE_READ_ONLY_PLAYLIST", {
 						userId,
-						displayName: "Disliked Songs"
+						displayName: "Disliked Songs",
+						type: "user"
 					})
 						.then(dislikedSongsPlaylist => {
 							next(null, { likedSongsPlaylist, dislikedSongsPlaylist }, userId);

+ 4 - 2
backend/logic/app.js

@@ -328,7 +328,8 @@ class _AppModule extends CoreClass {
 						(userId, next) => {
 							PlaylistsModule.runJob("CREATE_READ_ONLY_PLAYLIST", {
 								userId,
-								displayName: "Liked Songs"
+								displayName: "Liked Songs",
+								type: "user"
 							})
 								.then(likedSongsPlaylist => {
 									next(null, likedSongsPlaylist, userId);
@@ -340,7 +341,8 @@ class _AppModule extends CoreClass {
 						(likedSongsPlaylist, userId, next) => {
 							PlaylistsModule.runJob("CREATE_READ_ONLY_PLAYLIST", {
 								userId,
-								displayName: "Disliked Songs"
+								displayName: "Disliked Songs",
+								type: "user"
 							})
 								.then(dislikedSongsPlaylist => {
 									next(null, { likedSongsPlaylist, dislikedSongsPlaylist }, userId);

+ 3 - 1
backend/logic/db/schemas/playlist.js

@@ -11,5 +11,7 @@ export default {
 	],
 	createdBy: { type: String, required: true },
 	createdAt: { type: Date, default: Date.now, required: true },
-	privacy: { type: String, enum: ["public", "private"], default: "private" }
+	createdFor: { type: String },
+	privacy: { type: String, enum: ["public", "private"], default: "private" },
+	type: { type: String, enum: ["user", "genre"], required: true }
 };

+ 2 - 1
backend/logic/playlists.js

@@ -120,7 +120,8 @@ class _PlaylistsModule extends CoreClass {
 					displayName: payload.displayName,
 					songs: [],
 					createdBy: payload.userId,
-					createdAt: Date.now()
+					createdAt: Date.now(),
+					type: payload.type
 				},
 				(err, playlist) => {
 					if (err) return reject(new Error(err));

+ 6 - 1
frontend/src/pages/Admin/tabs/Playlists.vue

@@ -6,11 +6,13 @@
 				<thead>
 					<tr>
 						<td>Display name</td>
+						<td>Type</td>
 						<td>Is user modifiable</td>
 						<td>Songs #</td>
 						<td>Playlist length</td>
 						<td>Created by</td>
 						<td>Created at</td>
+						<td>Created for</td>
 						<td>Playlist id</td>
 						<!-- <td>Options</td> -->
 					</tr>
@@ -18,10 +20,12 @@
 				<tbody>
 					<tr v-for="playlist in playlists" :key="playlist._id">
 						<td>{{ playlist.displayName }}</td>
+						<td>{{ playlist.type }}</td>
 						<td>{{ playlist.isUserModifiable }}</td>
 						<td>{{ playlist.songs.length }}</td>
 						<td>{{ totalLengthForPlaylist(playlist.songs) }}</td>
-						<td>
+						<td v-if="playlist.createdBy === 'Musare'">Musare</td>
+						<td v-else>
 							<user-id-to-username
 								:user-id="playlist.createdBy"
 								:link="true"
@@ -30,6 +34,7 @@
 						<td :title="new Date(playlist.createdAt)">
 							{{ getDateFormatted(playlist.createdAt) }}
 						</td>
+						<td>{{ playlist.createdFor }}</td>
 						<td>{{ playlist._id }}</td>
 						<!-- <td>
 							<button