Skip to content

Commit

Permalink
Fixed songs not submitting to database bug
Browse files Browse the repository at this point in the history
  • Loading branch information
itajenglish committed Mar 3, 2017
1 parent 51ff2c3 commit 90d6618
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 42 deletions.
32 changes: 0 additions & 32 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,3 @@ app.use(DASHBOARDS_ROUTER);
app.use('/Users', USERS_ROUTER);
app.use('/Queue', QUEUE_ROUTER);
app.use('/Api', API_ROUTER);


// app.post('/saveQueData', function(req, res) {
// data = req.body;
// var id = data.djID;
// var Title = data.Title;
// var Artist = data.Artist;
// var Album = data.Album;
// var Image = data.Image;
// var userID = req.session.user.id;
// db.none('INSERT INTO QUE (title,artist,album,img,djs_id,fans_id) VALUES ($1,$2,$3,$4,$5,$6)', [Title, Artist, Album, Image, id, userID]).then(function() {
// res.send("Song Added!")
// })
//
// });
//
// app.delete('/deleteQueData', function(req, res) {
// var user = req.session.user.id;
// var songID = req.body.songID;
// console.log(req.body.songID);
// db.none('DELETE FROM que WHERE id = $1 AND djs_id = $2', [songID, user]).then(function() {
// console.log("Song Deleted");
// });
// });
//
// app.get('/queData', function(req, res) {
// var userID = req.session.user.id;
// db.any('SELECT * FROM que WHERE djs_id = $1', [userID])
// .then(function(data) {
// res.send(data);
// })
// });
5 changes: 4 additions & 1 deletion models/Queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ const getOneQueue = (req, res, next) => {
// Adds songs to users que in database
const addToQueue = (req, res, next) => {
const data = req.body;
console.log(data);
const id = data.djID;
const Title = data.Title;
const Artist = data.Artist;
const Album = data.Album;
const Image = data.Image;
const userID = req.session.user.id;

console.log(req)

db.none('INSERT INTO QUE (title,artist,album,img,djs_id,fans_id) VALUES ($1,$2,$3,$4,$5,$6)', [Title, Artist, Album, Image, id, userID])
.then(() => {
next();
})
.catch((err) => {
console.log(err);
res.send('Ohh oh something went wrong with adding your song to the queue!');
res.write('Ohh oh something went wrong with adding your song to the queue!');
})
}

Expand Down
1 change: 0 additions & 1 deletion models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const getUserByName = (req, res, next) => {
.catch((err) => {
res.send('Something went wrong!');
console.log(err);
next();
})
}

Expand Down
2 changes: 1 addition & 1 deletion public/scripts/userboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const appendDom = (data) => {
let location = value.location;
let bio = value.bio;

$('#listDjs').append('<li class="collection-item avatar"> <img src="' + image + '" alt="image" class="circle"> <span class="title">'+name+'</span> <p>' + bio+ ' <br>' +'- ' + '<span class = "textColor">'+ location + '</span>' +'</p><a href="/user/'+fname+'-'+lname+'" class="textColor secondary-content">View</a>')
$('#listDjs').append('<li class="collection-item avatar"> <img src="' + image + '" alt="image" class="circle"> <span class="title">'+name+'</span> <p>' + bio+ ' <br>' +'- ' + '<span class = "textColor">'+ location + '</span>' +'</p><a href="/users/'+fname+'-'+lname+'" class="textColor secondary-content">View</a>')

});
}
7 changes: 5 additions & 2 deletions public/scripts/userprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ $(document).ready(() => {
appendDom(Title,Artist,Img,Album,Counter);

$('#song-num' + Counter).on('click', () => {
const djID = $('#djNum').text();

const djID = $('body').data('id');
console.log(djID)

const songData = {
'djID': djID,
'Title': Title,
Expand All @@ -64,7 +67,7 @@ $(document).ready(() => {
};

$.ajax({
url: 'https://quedj.herokuapp.com/saveQueData',
url: '/queue',
type: 'POST',
data: songData
})
Expand Down
7 changes: 2 additions & 5 deletions views/profiles/userprofile.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,20 @@
</nav>
</header>

<body>
<body data-id={{user.id}}>
<div class="row">
<div class="col card m4 s12 ">
<div class="card-image">
<img id="img" src="/{{user.image}}">
</div>
<span class="card-title">{{user.first_name}}</span> <span class="card-title textColor">{{user.last_name}}</span>
<div class="card-content">
<p>DJ# - <span id="userNum" class="textColor">{{user.id}}</span></p>
<p>Bio - <span class="textColor">{{user.bio}}</span></p>
<p>Location - <span class="textColor">{{user.location}}</span></p>
<p>Up Votes - {{user.upvotes}} </p>
<p>Down Votes - {{user.downvotes}} </p>
</div>
<!-- <div class="card-action">
<a href="#">This is a link</a>
</div> -->

</div>

<div class="col card m6 s12">
Expand Down

0 comments on commit 90d6618

Please sign in to comment.