- joinProject - added

-team members - fixed
This commit is contained in:
Matan Bar Yosef 2015-08-01 17:51:13 +03:00
parent aade478e5f
commit dbfaf90972
3 changed files with 35 additions and 0 deletions

View file

@ -8,10 +8,25 @@ angular.module('SeHub')
$scope.user = $scope.$parent.user; $scope.user = $scope.$parent.user;
$scope.loadingData = true; $scope.loadingData = true;
$scope.isMasterOrLecturer = false; $scope.isMasterOrLecturer = false;
$scope.isMember = false;
// $scope.thisProject = {}; // $scope.thisProject = {};
// $scope.thisProject.courseName = $routeParams.className; // $scope.thisProject.courseName = $routeParams.className;
$scope.joinProject = function()
{
apiService.joinProject(token, projectId).success(function(data)
{
$scope.isMember = true;
$scope.project = data;
$mdDialog.show($mdDialog.alert().title('Join Project').content('Joined successfully.')
.ariaLabel('Join project alert dialog').ok('Aight').targetEvent(ev));
}).error(function(err)
{
console.log("Error: " + err.message);
});
}
$scope.editProject = function(ev) $scope.editProject = function(ev)
{ {
$scope.isEditPressed = true; $scope.isEditPressed = true;
@ -46,6 +61,13 @@ angular.module('SeHub')
apiService.getProjectsById(token, projectId).success(function(data) apiService.getProjectsById(token, projectId).success(function(data)
{ {
$scope.project = data; $scope.project = data;
for(var i = 0; i < data.members.length; i++)
{
if($scope.user.id === data.members[i].id)
{
$scope.isMember = true;
}
}
// if($scope.user === $scope.project.info.master_id) // if($scope.user === $scope.project.info.master_id)
// { // {
// $scope.isMasterOrLecturer = true; // $scope.isMasterOrLecturer = true;

View file

@ -181,6 +181,14 @@ service.factory('apiService', ['$http', function($http) {
}; };
return $http(req); return $http(req);
}, },
joinProject: function(token, projectId){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/joinProject/" + token + "/" + projectId;
req = {
method: "PUT",
url: url
};
return $http(req);
},
getCourseById: function(token, id){ getCourseById: function(token, id){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + token + "/" + id; var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + token + "/" + id;
req = { req = {

View file

@ -18,6 +18,11 @@
<div layout = "row" flex = "45"> <div layout = "row" flex = "45">
<!-- <div ng-if = "isMasterOrLecturer"> --> <!-- <div ng-if = "isMasterOrLecturer"> -->
<md-card layout = "row"> <md-card layout = "row">
<div ng-if="isMember" layout-padding>
<md-button ng-click="joinProject()" ng class = "md-raised md-primary">
<i class="fa fa-user-plus"></i>
</md-button>
</div>
<div layout-padding> <div layout-padding>
<md-button ng-click="editProject($event)" ng class="md-raised md-primary"> <md-button ng-click="editProject($event)" ng class="md-raised md-primary">
<i class="fa fa-pencil-square-o"></i> <i class="fa fa-pencil-square-o"></i>