Browse Source

Continued working on Playlists

theflametrooper 8 years ago
parent
commit
b086261ea9

+ 8 - 0
backend/logic/actions/playlists.js

@@ -71,6 +71,14 @@ module.exports = {
 		});
 	},
 
+	addSongToPlaylist: (session, _id, song, cb) => {
+		db.models.playlist.findOneAndUpdate({ _id }, { songs: songs.push(song) }, { upsert: true }, (err, data) => {
+			if (err) throw err;
+			console.log(data, 222);
+			return cb({ status: 'success', message: 'Song has been successfully added to the Playlist', data });
+		});
+	},
+
 	updateDisplayName: (session, _id, displayName, cb) => {
 		db.models.playlist.findOneAndUpdate({ _id }, { displayName }, { upsert: true }, (err, data) => {
 			if (err) throw err;

+ 5 - 5
backend/logic/utils.js

@@ -1,10 +1,10 @@
 'use strict';
 
-const 	moment = require('moment'),
-		io = require('./io'),
-		config = require('config'),
-		request = require('request'),
-		cache = require('./cache');
+const moment  = require('moment'),
+	  io      = require('./io'),
+	  config  = require('config'),
+	  request = require('request'),
+	  cache   = require('./cache');
 
 class Timer {
 	constructor(callback, delay, paused) {

+ 6 - 2
frontend/components/Modals/Playlists/Edit.vue

@@ -96,10 +96,14 @@
 					} else if (res.status == 'error') Toast.methods.addToast(res.message, 3000);
 				});
 			},
-			addSongToPlaylist: function (id) {},
+			addSongToPlaylist: function (id) {
+				this.socket.emit('playlists.addSongToPlaylist', id, res => {
+					if (res.status == 'success') Toast.methods.addToast(res.message, 3000);
+				});
+			},
 			removeSongFromPlaylist: function (id) {},
 			renamePlaylist: function () {
-				_this.socket.emit('playlists.updateDisplayName', _this.playlist._id, _this.playlist.displayName, res => {
+				this.socket.emit('playlists.updateDisplayName', this.playlist._id, this.playlist.displayName, res => {
 					if (res.status == 'success') Toast.methods.addToast(res.message, 3000);
 				});
 			}

+ 1 - 1
frontend/components/Station/Station.vue

@@ -311,7 +311,7 @@
 								});
 							} else {
 								if (_this.playerReady) _this.player.pauseVideo();
-								console.log("NO SONG TRUE1", res);
+								console.log("NO SONG TRUE1", res.data);
 								_this.noSong = true;
 							}
 							if (_this.type === 'community') {