diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js index d3c3ebd..f51f37b 100644 --- a/templates/js/controllers/projectController.js +++ b/templates/js/controllers/projectController.js @@ -8,10 +8,25 @@ angular.module('SeHub') $scope.user = $scope.$parent.user; $scope.loadingData = true; $scope.isMasterOrLecturer = false; + $scope.isMember = false; // $scope.thisProject = {}; // $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.isEditPressed = true; @@ -46,6 +61,13 @@ angular.module('SeHub') apiService.getProjectsById(token, projectId).success(function(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) // { // $scope.isMasterOrLecturer = true; diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index ee40112..77f14dc 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -181,6 +181,14 @@ service.factory('apiService', ['$http', function($http) { }; 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){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + token + "/" + id; req = { diff --git a/templates/views/project.html b/templates/views/project.html index b880935..ccc573b 100644 --- a/templates/views/project.html +++ b/templates/views/project.html @@ -18,6 +18,11 @@
+
+ + + +