Skip to content

Commit

Permalink
Bookmarks and blue logo
Browse files Browse the repository at this point in the history
  • Loading branch information
annatangzhao committed Sep 20, 2016
1 parent 5d3f0f7 commit e727ea5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
6 changes: 3 additions & 3 deletions client/components/about/about.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class='about_container'>
<img class="homepage_logo" src="/style/images/n-list-full_500.png">
<img class="homepage_logo" src="/style/images/blue-logo-top.png">
<br/>
<br/>

Expand All @@ -14,7 +14,7 @@ <h1>Team Hypnotoads</h1>
</p>


<br/>
<br/>
<br/>

<a target="_blank" href="https://www.linkedin.com/in/annazhao">
Expand Down Expand Up @@ -90,5 +90,5 @@ <h2 class="team_mate">Neekon Etemad</h2>
<div class="neekon_description"><h3>Hi! I'm Neekon</h3></div>
</div>
</a>

</div>
4 changes: 2 additions & 2 deletions client/components/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<div class="resource_item" ng-repeat="post in posts | orderBy: sortType:sortReverse | filter: languageFilter | filter:topicFilter | filter:search" ng-show="{{ post.likes - post.dislikes > -3 }} && !post.minimized">
<i class="fa fa-minus-circle" aria-hidden="true" ng-click="post.minimized = true"></i>
<i class="fa fa-trash-o" aria-hidden="true" ng-click="deletePost(post)" ng-show="user.id === post.id_users"></i>
<i class="fa fa-bookmark-o" aria-hidden="true" ng-click="post.saved = true" ng-show="!post.saved"></i>
<i class="fa fa-bookmark-o" aria-hidden="true" ng-click="addBookmark(post.id); post.saved = true" ng-show="!post.saved"></i>
<i class="fa fa-bookmark" aria-hidden="true" ng-show="post.saved"></i>
<a ng-href={{post.link}} target="_blank"> <!-- clicking on anything besides like or dislikes will lead you to the page -->

Expand Down Expand Up @@ -157,7 +157,7 @@
<div class="resource_item" style="min-height: 5em" ng-repeat="post in posts | orderBy: sortType:sortReverse | filter: languageFilter | filter:topicFilter | filter:search" ng-show="{{ post.likes - post.dislikes <= -3 }} || post.minimized">
<i class="fa fa-plus-circle" aria-hidden="true" ng-click="post.minimized = false"></i>
<i class="fa fa-trash-o" aria-hidden="true" ng-click="deletePost(post)" ng-show="user.id === post.id_users"></i>
<i class="fa fa-bookmark-o" aria-hidden="true" ng-click="post.saved = true" ng-show="!post.saved"></i>
<i class="fa fa-bookmark-o" aria-hidden="true" ng-click="addBookmark(post.id); post.saved = true" ng-show="!post.saved"></i>
<i class="fa fa-bookmark" aria-hidden="true" ng-show="post.saved"></i>

<a ng-href={{post.link}} target="_blank"> <!-- clicking on anything besides like or dislikes will lead you to the page -->
Expand Down
8 changes: 6 additions & 2 deletions client/components/home/homectrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ app.controller('homeCtrl',['$scope','links','checkUser',($scope, links, checkUse
$scope.comments = links.comments;
$scope.users = links.users;
$scope.userReputation = links.userReputation;
$scope.bookmarks = links.bookmarks;
$scope.sortType = 'date_added';
$scope.sortReverse = false;
$scope.searchFinish = '';
Expand Down Expand Up @@ -50,8 +51,11 @@ app.controller('homeCtrl',['$scope','links','checkUser',($scope, links, checkUse
links.addOneComment(newComment)
}

$scope.showComments = function () {

$scope.addBookmark = function (id) {
links.saveOne({
resource: id,
user: $scope.user.id
})
}

$scope.emailLink = function (id, name, email) {
Expand Down
18 changes: 17 additions & 1 deletion client/service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ app.factory('links', ['$http', ($http) => {
languages: [],
comments: [],
users: [],
userReputation: {}
userReputation: {},
bookmarks: []
};

n.getAll = function() {
Expand Down Expand Up @@ -104,6 +105,21 @@ app.factory('links', ['$http', ($http) => {
n.getAll();
});
};

n.getAllSaved = function() {
return $http.get('/bookmarks')
.success(function(data) {
angular.copy(data, n.bookmarks);
});
};

n.saveOne = function (post) {
return $http.post('/bookmarks', post)
.success(function(data) {
n.bookmarks.push(data);
n.getAllSaved();
});
}
return n;

}]);
Expand Down
13 changes: 5 additions & 8 deletions db/controller/links-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,23 @@ let Links = {
id_sub_topic, id_resource_type,\
link, date_added, keywords,\
likes, dislikes) value (?, ?,?, ?, ?, ?, NOW(), ?, ?, ?)';
db.query(query, data, (err, results) => callback(err, results) );
db.query(query, data, (err, results)=>callback(err, results));
},


// ****SAVE A RESOURCE (to a user)**** //
saveOne: (params, callback) =>{

let data = [params.user, params.resource];

const query = 'INSERT INTO saved_links(id_users, id_resources\
) value (?, ?)';
db.query(query, data, (err, results) => callback(err, results) );
const query = 'INSERT INTO saved_links(id_users, id_resources) value (?, ?)';
db.query(query, data, (err, results)=>callback(err, results));
},

getAllSaved: (params, callback) =>{
getAllSaved: (callback) =>{
const query = 'SELECT s.id, s.id_users, s.id_resources,\
r.title, r.link, r.keywords, r.id_languages \
FROM saved_links s\
JOIN users u ON u.id = s.id_users \
JOIN resources r ON r.id = r.id_resources \
JOIN resources r ON r.id = s.id_resources \
ORDER BY date_added DESC';
db.query(query, (err, results) => callback(err, results) );
},
Expand Down
4 changes: 2 additions & 2 deletions server/routes/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ module.exports.resourses = {
},

saveOne: (req, res)=>{
Links.saveOne((err, data)=>{
if (err) console.log(err);
Links.saveOne(req.body, (err,data)=>{
if(err) console.log(err);
res.json(data);
});
},
Expand Down

0 comments on commit e727ea5

Please sign in to comment.