Browse Source

Fixed some bugs with admin tabs and errors with songs with negative durations

Kristian Vos 4 years ago
parent
commit
1179ae3bbd
3 changed files with 36 additions and 33 deletions
  1. 1 1
      backend/logic/db/schemas/song.js
  2. 21 18
      backend/logic/notifications.js
  3. 14 14
      frontend/src/pages/Admin/index.vue

+ 1 - 1
backend/logic/db/schemas/song.js

@@ -3,7 +3,7 @@ export default {
 	title: { type: String, required: true },
 	artists: [{ type: String }],
 	genres: [{ type: String }],
-	duration: { type: Number, required: true },
+	duration: { type: Number, min: 1, required: true },
 	skipDuration: { type: Number, required: true },
 	thumbnail: { type: String, required: true },
 	likes: { type: Number, default: 0, required: true },

+ 21 - 18
backend/logic/notifications.js

@@ -169,24 +169,27 @@ class _NotificationsModule extends CoreClass {
 	SCHEDULE(payload) {
 		return new Promise((resolve, reject) => {
 			const time = Math.round(payload.time);
-			NotificationsModule.log(
-				"STATION_ISSUE",
-				`SCHEDULE - Time: ${time}; Name: ${payload.name}; Key: ${crypto
-					.createHash("md5")
-					.update(`_notification:${payload.name}_`)
-					.digest("hex")}; StationId: ${payload.station._id}; StationName: ${payload.station.name}`
-			);
-			NotificationsModule.pub.set(
-				crypto.createHash("md5").update(`_notification:${payload.name}_`).digest("hex"),
-				"",
-				"PX",
-				time,
-				"NX",
-				err => {
-					if (err) reject(err);
-					else resolve();
-				}
-			);
+			if (time <= 0) reject(new Error("Time has to be higher than 0"));
+			else {
+				NotificationsModule.log(
+					"STATION_ISSUE",
+					`SCHEDULE - Time: ${time}; Name: ${payload.name}; Key: ${crypto
+						.createHash("md5")
+						.update(`_notification:${payload.name}_`)
+						.digest("hex")}; StationId: ${payload.station._id}; StationName: ${payload.station.name}`
+				);
+				NotificationsModule.pub.set(
+					crypto.createHash("md5").update(`_notification:${payload.name}_`).digest("hex"),
+					"",
+					"PX",
+					time,
+					"NX",
+					err => {
+						if (err) reject(err);
+						else resolve();
+					}
+				);
+			}
 		});
 	}
 

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

@@ -4,24 +4,24 @@
 		<div class="tabs is-centered">
 			<ul>
 				<li
-					:class="{ 'is-active': currentTab == 'unverifiedSongs' }"
-					@click="showTab('unverifiedSongs')"
+					:class="{ 'is-active': currentTab == 'unverifiedsongs' }"
+					@click="showTab('unverifiedsongs')"
 				>
 					<router-link
-						class="tab unverifiedSongs"
-						to="/admin/unverifiedSongs"
+						class="tab unverifiedsongs"
+						to="/admin/unverifiedsongs"
 					>
 						<i class="material-icons">music_note</i>
 						<span>&nbsp;Unverified Songs</span>
 					</router-link>
 				</li>
 				<li
-					:class="{ 'is-active': currentTab == 'verifiedSongs' }"
-					@click="showTab('verifiedSongs')"
+					:class="{ 'is-active': currentTab == 'verifiedsongs' }"
+					@click="showTab('verifiedsongs')"
 				>
 					<router-link
-						class="tab verifiedSongs"
-						to="/admin/verifiedSongs"
+						class="tab verifiedsongs"
+						to="/admin/verifiedsongs"
 					>
 						<i class="material-icons">music_note</i>
 						<span>&nbsp;Verified Songs</span>
@@ -108,8 +108,8 @@
 			</ul>
 		</div>
 
-		<unverified-songs v-if="currentTab == 'unverifiedSongs'" />
-		<verified-songs v-if="currentTab == 'verifiedSongs'" />
+		<unverified-songs v-if="currentTab == 'unverifiedsongs'" />
+		<verified-songs v-if="currentTab == 'verifiedsongs'" />
 		<stations v-if="currentTab == 'stations'" />
 		<playlists v-if="currentTab == 'playlists'" />
 		<reports v-if="currentTab == 'reports'" />
@@ -155,10 +155,10 @@ export default {
 		changeTab(path) {
 			switch (path) {
 				case "/admin/unverifiedsongs":
-					this.currentTab = "unverifiedSongs";
+					this.currentTab = "unverifiedsongs";
 					break;
 				case "/admin/verifiedsongs":
-					this.currentTab = "verifiedSongs";
+					this.currentTab = "verifiedsongs";
 					break;
 				case "/admin/stations":
 					this.currentTab = "stations";
@@ -215,11 +215,11 @@ export default {
 	padding-top: 10px;
 	margin-top: -10px;
 	background-color: var(--white);
-	.unverifiedSongs {
+	.unverifiedsongs {
 		color: var(--teal);
 		border-color: var(--teal);
 	}
-	.verifiedSongs {
+	.verifiedsongs {
 		color: var(--primary-color);
 		border-color: var(--primary-color);
 	}