Browse Source

Fixed logger, defaultSong/simpleSong not having a skipDuration, the YouTube player not loading, Redis deprecation error.

KrisVos130 8 years ago
parent
commit
debf9ccd17

+ 1 - 0
backend/logic/actions/stations.js

@@ -355,6 +355,7 @@ module.exports = {
 
 			(station, next) => {
 				utils.socketJoinRoom(session.socketId, `station.${station._id}`);
+				console.log(station.currentSong);
 				let data = {
 					_id: station._id,
 					type: station.type,

+ 15 - 25
backend/logic/logger.js

@@ -109,43 +109,33 @@ module.exports = {
 		success++;
 		successThisMinute++;
 		successThisHour++;
-		getTime((time) => {
-			let timeString = `${time.year}-${twoDigits(time.month)}-${twoDigits(time.day)} ${twoDigits(time.hour)}:${twoDigits(time.minute)}:${twoDigits(time.second)}`;
-			fs.appendFile(dir + '/all.log', `${timeString} SUCCESS - ${type} - ${message}\n`, ()=>{});
-			fs.appendFile(dir + '/success.log', `${timeString} SUCCESS - ${type} - ${message}\n`, ()=>{});
-			console.info('\x1b[32m', timeString, 'SUCCESS', '-', type, '-', message, '\x1b[0m');
-		});
+		let time = getTimeFormatted();
+		fs.appendFile(dir + '/all.log', `${time} SUCCESS - ${type} - ${message}\n`, ()=>{});
+		fs.appendFile(dir + '/success.log', `${time} SUCCESS - ${type} - ${message}\n`, ()=>{});
+		console.info('\x1b[32m', time, 'SUCCESS', '-', type, '-', message, '\x1b[0m');
 	},
 	error: (type, message) => {
 		error++;
 		errorThisMinute++;
 		errorThisHour++;
-		getTime((time) => {
-			let timeString = `${time.year}-${twoDigits(time.month)}-${twoDigits(time.day)} ${twoDigits(time.hour)}:${twoDigits(time.minute)}:${twoDigits(time.second)}`;
-			fs.appendFile(dir + '/all.log', `${timeString} ERROR - ${type} - ${message}\n`, ()=>{});
-			fs.appendFile(dir + '/error.log', `${timeString} ERROR - ${type} - ${message}\n`, ()=>{});
-			console.warn('\x1b[31m', timeString, 'ERROR', '-', type, '-', message, '\x1b[0m');
-		});
+		let time = getTimeFormatted();
+		fs.appendFile(dir + '/all.log', `${time} ERROR - ${type} - ${message}\n`, ()=>{});
+		fs.appendFile(dir + '/error.log', `${time} ERROR - ${type} - ${message}\n`, ()=>{});
+		console.warn('\x1b[31m', time, 'ERROR', '-', type, '-', message, '\x1b[0m');
 	},
 	info: (type, message) => {
 		info++;
 		infoThisMinute++;
 		infoThisHour++;
-		getTime((time) => {
-			let timeString = `${time.year}-${twoDigits(time.month)}-${twoDigits(time.day)} ${twoDigits(time.hour)}:${twoDigits(time.minute)}:${twoDigits(time.second)}`;
-			fs.appendFile(dir + '/all.log', `${timeString} INFO - ${type} - ${message}\n`, ()=>{});
-			fs.appendFile(dir + '/info.log', `${timeString} INFO - ${type} - ${message}\n`, ()=>{});
-
-			console.info('\x1b[36m', timeString, 'INFO', '-', type, '-', message, '\x1b[0m');
-		});
+		let time = getTimeFormatted();
+		fs.appendFile(dir + '/all.log', `${time} INFO - ${type} - ${message}\n`, ()=>{});
+		fs.appendFile(dir + '/info.log', `${time} INFO - ${type} - ${message}\n`, ()=>{});
+		console.info('\x1b[36m', time, 'INFO', '-', type, '-', message, '\x1b[0m');
 	},
 	stationIssue: (string) => {
-		getTime((time) => {
-			let timeString = `${time.year}-${twoDigits(time.month)}-${twoDigits(time.day)} ${twoDigits(time.hour)}:${twoDigits(time.minute)}:${twoDigits(time.second)}`;
-			fs.appendFile(dir + '/debugStation.log', `${timeString} - ${string}\n`, ()=>{});
-
-			console.info('\x1b[35m', timeString, '-', string, '\x1b[0m');
-		});
+		let time = getTimeFormatted();
+		fs.appendFile(dir + '/debugStation.log', `${time} - ${string}\n`, ()=>{});
+		console.info('\x1b[35m', time, '-', string, '\x1b[0m');
 	},
 	calculatePerSecond: function(number) {
 		let secondsRunning = Math.floor((Date.now() - started) / 1000);

+ 1 - 0
backend/logic/notifications.js

@@ -45,6 +45,7 @@ const lib = {
 	 * @param {Function} cb - gets called when the notification has been scheduled
 	 */
 	schedule: (name, time, cb, station) => {
+		if (!cb) cb = ()=>{};
 		time = Math.round(time);
 		logger.stationIssue(`SCHEDULE - Time: ${time}; Name: ${name}; Key: ${crypto.createHash('md5').update(`_notification:${name}_`).digest('hex')}; StationId: ${station._id}; StationName: ${station.name}`);
 		pub.set(crypto.createHash('md5').update(`_notification:${name}_`).digest('hex'), '', 'PX', time, 'NX', cb);

+ 2 - 0
backend/logic/stations.js

@@ -376,6 +376,7 @@ module.exports = {
 							songId: song.songId,
 							title: song.title,
 							duration: song.duration,
+							skipDuration: 0,
 							likes: -1,
 							dislikes: -1
 						};
@@ -462,6 +463,7 @@ module.exports = {
 		songId: '60ItHLz5WEA',
 		title: 'Faded - Alan Walker',
 		duration: 212,
+		skipDuration: 0,
 		likes: -1,
 		dislikes: -1
 	}

+ 11 - 2
frontend/components/Station/Station.vue

@@ -13,8 +13,8 @@
 	<playlist-sidebar v-if='sidebars.playlist'></playlist-sidebar>
 	<users-sidebar v-if='sidebars.users'></users-sidebar>
 
-	<div class='progress' v-if='!ready'></div>
-	<div class='station' v-else>
+	<div class='progress' v-show='!ready'></div>
+	<div class='station' v-show="ready">
 		<div v-show="noSong" class="no-song">
 			<h1>No song is currently playing</h1>
 			<h4 v-if='type === "community" && station.partyMode'>
@@ -395,9 +395,12 @@
 				}
 			},
 			joinStation: function () {
+				console.log("JOINSTATION");
 				let _this = this;
 				_this.socket.emit('stations.join', _this.stationName, res => {
+					console.log("SOCKET STATIONS JOIN");
 					if (res.status === 'success') {
+						console.log("SOCKET STATIONS JOIN SUCCESS");
 						_this.station = {
 							_id: res.data._id,
 							name: _this.stationName,
@@ -416,6 +419,7 @@
 						_this.userCount = res.data.userCount;
 						_this.users = res.data.users;
 						if (res.data.currentSong) {
+							console.log(">> HAS CURRENT SONG");
 							_this.noSong = false;
 							_this.simpleSong = (res.data.currentSong.likes === -1 && res.data.currentSong.dislikes === -1);
 							if (_this.simpleSong) {
@@ -430,6 +434,7 @@
 								}
 							});
 						} else {
+							console.log(">> HAS NO CURRENT SONG");
 							if (_this.playerReady) _this.player.pauseVideo();
 							_this.noSong = true;
 						}
@@ -469,6 +474,7 @@
 			}
 		},
 		ready: function() {
+			console.log("READY");
 			let _this = this;
 
 			Date.currently = () => {
@@ -480,11 +486,13 @@
 			window.stationInterval = 0;
 
 			io.getSocket(socket => {
+				console.log("SOCKET");
 				_this.socket = socket;
 
 				io.removeAllListeners();
 				if (_this.socket.connected) _this.joinStation();
 				io.onConnect(() => {
+					console.log("IO CONNECT");
 					_this.joinStation();
 				});
 				_this.socket.emit('stations.findByName', _this.stationName, res => {
@@ -496,6 +504,7 @@
 					}
 				});
 				_this.socket.on('event:songs.next', data => {
+					console.log("NEXT SONG EVENT");
 					_this.previousSong = (_this.currentSong.songId) ? _this.currentSong : null;
 					_this.currentSong = (data.currentSong) ? data.currentSong : {};
 					_this.startedAt = data.startedAt;

+ 2 - 2
windows-start.cmd

@@ -1,9 +1,9 @@
 start "Redis" "startRedis.cmd"
 start "Mongo" "startmongo.cmd"
 cd frontend
-start "Frotend" npm run development-watch
+start "Frontend" npm run development-watch
 cd ..
-SLEEP 60
+SLEEP 20
 cd backend
 start "Backend" "nodemon"
 cd ..