Skip to content

Commit

Permalink
Bug fixes and graph on front page
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatamohanty committed Jan 31, 2017
1 parent df17f9c commit ff2a9fd
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 126 deletions.
6 changes: 5 additions & 1 deletion datastructure/constants.js
Expand Up @@ -6,7 +6,11 @@ module.exports.relationships = [
"target_type" : "contribution",
"name" : "QUESTION_FOR"
},

{
"src_type" : "contribution",
"target_type" : "contribution",
"name" : "SUBMISSION_FOR"
},
{
"src_type" : "contribution",
"target_type" : "contribution",
Expand Down
Binary file added public/assets/images/studionet_graph.JPG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion public/user/javascripts/controllers/ContributionsCtrl.js
Expand Up @@ -174,7 +174,9 @@ angular.module('studionet')
// remove supernode
$scope.graph.getElementById(supernode.contribution).remove();

STUDIONET.GRAPH.draw_graph($scope.graph, 1);
// redraw graph
var threshold = 20;
STUDIONET.GRAPH.draw_graph($scope.graph, threshold);

// Display the entire node name
$scope.graph.on('mouseover','node', function(evt){
Expand Down
73 changes: 56 additions & 17 deletions public/user/javascripts/controllers/DetailsModalCtrl.js
Expand Up @@ -11,11 +11,12 @@ angular.module('studionet')

//todo: check why promise doesn't always get resolved
$scope.relationships = [{"src_type":"contribution","target_type":"contribution","name":"QUESTION_FOR"},
{"src_type":"contribution","target_type":"contribution","name":"SUBMISSION_FOR"},
{"src_type":"contribution","target_type":"contribution","name":"ANSWER_FOR"},
{"src_type":"contribution","target_type":"contribution","name":"COMMENT_FOR"},
{"src_type":"contribution","target_type":"contribution","name":"RESOURCE_FOR","createdBy":"__"},
{"src_type":"contribution","target_type":"contribution","name":"INSPIRED_FROM","createdBy":"__"},
{"src_type":"contribution","target_type":"contribution","name":"RELATED_TO","createdBy":"__","note":"__"},
{"src_type":"contribution","target_type":"contribution","name":"RESOURCE_FOR"},
{"src_type":"contribution","target_type":"contribution","name":"INSPIRED_FROM"},
{"src_type":"contribution","target_type":"contribution","name":"RELATED_TO"},
{"src_type":"user","target_type":"contribution","name":"LIKED","properties":[{"name":"count","type":0}]},
{"src_type":"user","target_type":"contribution","name":"VIEWED","properties":[{"name":"count","type":0},
{"name":"last_viewed","type":"2017-01-23T07:31:43.857Z"}]}];
Expand Down Expand Up @@ -43,11 +44,10 @@ angular.module('studionet')
}

$scope.showUpdateModal = function(id){

$scope.updateMode = true;
$scope.contributionData = jQuery.extend({}, $scope.contribution.db_data);

console.log("updating", $scope.contributionData);

if($scope.contributionData.attachments[0].id == null){
$scope.contributionData.attachments = [];
}
Expand Down Expand Up @@ -75,6 +75,25 @@ angular.module('studionet')
/* $scope.clickedContribution = null;
$scope.contributionTree = []; */

getRating = function(contribution_id){

var rating = 0;

for(var i=0; i < profile.contributions[0].length; i++){

var user_contribution = profile.contributions[0][i];
if( user_contribution.type == "RATED" && user_contribution.end == contribution_id ){
rating = user_contribution.properties.rating;
break;
}

}

return rating;


}

// setting data from scope calling ModalService
$scope.setData = function(data, activeContribution){

Expand All @@ -84,6 +103,9 @@ angular.module('studionet')

$scope.contribution = data[0];

// get rating
$scope.rate = getRating( $scope.contribution.id );

$scope.parents = ["parent1", "parent2", "parent3"];

}
Expand Down Expand Up @@ -123,14 +145,27 @@ angular.module('studionet')
$scope.max = 5;
$scope.overStar = null;
$scope.percent = 0;


$scope.hoveringOver = function(value) {
$scope.overStar = value;
$scope.percent = 100 * (value / $scope.max);
};

$scope.rateContribution = function(rating, id){

contribution.rateContribution(id, rating).then(function(){

console.log($scope.contributionData);

//$scope.contributionData.rateCount++;
//$scope.contributionData.rating += rating;
console.log("Contribution Rated Successfully");
})

//$scope.$apply();

})

}

// Attachments
Expand Down Expand Up @@ -203,6 +238,7 @@ angular.module('studionet')

if(contributionData.title == undefined || contributionData.title.length == 0 || contributionData.body == undefined || contributionData.body.length == 0){
alert("Contribution must have a title and body!");
return;
}

contributionData.ref = parentId;
Expand Down Expand Up @@ -255,9 +291,10 @@ angular.module('studionet')
}

updateContribution.tags = [];
updateContribution._tags.map(function(t){
updateContribution.tags.push(t.name);
});
if(updateContribution._tags.length > 0)
updateContribution._tags.map(function(t){
updateContribution.tags.push(t.name);
});
delete updateContribution._tags;

//Remove the attachments that have already existed in the database
Expand All @@ -268,15 +305,17 @@ angular.module('studionet')
}
}

contribution.updateContribtuion(updateContribution).then(function(res){
console.log("success");
//$scope.alert.success = true;
//$scope.alert.successMsg = "Contribution Id : " + updateContribution.id + " has been updated.";
contribution.updateContribution(updateContribution).then(function(res){
alert("Contribution Updated")
sendMessage( {status: 200, message: "Updated contribution successfully" } );
$scope.close();

}, function(error){
console.log("failure");
$scope.alert.error = true;
$scope.alert.errorMsg = error.data;
sendMessage( {status: 500, message: "Error updating contribution" } );
$scope.close();
//$scope.alert.error = true;
//$scope.alert.errorMsg = error.data;
});
}

Expand All @@ -292,12 +331,12 @@ angular.module('studionet')


sendMessage({status: 200, message: "Contribution Id : " + $scope.contribution.id + " was successfully deleted." });
close();
$scope.close();

}, function(error){

sendMessage({status: 500, message: "Error deleting Contribution Id : " + $scope.contribution.id });
close();
$scope.close();

});
} else {
Expand Down

0 comments on commit ff2a9fd

Please sign in to comment.