2015-06-23 16:04:41 +00:00
|
|
|
|
2015-06-09 17:16:29 +00:00
|
|
|
var DEBUG = true;
|
2015-05-09 19:00:14 +00:00
|
|
|
|
|
|
|
var service = angular.module('seHub.services', []);
|
|
|
|
|
|
|
|
service.factory('apiService', ['$http', function($http) {
|
|
|
|
return {
|
|
|
|
getUserByToken: function(token){
|
2015-06-15 13:23:42 +00:00
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserByToken/" + token;
|
2015-05-09 19:00:14 +00:00
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
2015-06-10 10:36:31 +00:00
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
getAllCampuses: function(token){
|
2015-06-15 13:51:13 +00:00
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getAll/" + token;
|
2015-06-10 10:36:31 +00:00
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
2015-05-09 19:00:14 +00:00
|
|
|
};
|
2015-06-11 20:36:26 +00:00
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
sendValidationMail: function(token, email){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/validation/sendmail/" + token;
|
|
|
|
payload = {
|
|
|
|
email: email
|
|
|
|
};
|
|
|
|
req = {
|
|
|
|
method: "POST",
|
|
|
|
url: url,
|
|
|
|
data: payload
|
|
|
|
};
|
2015-06-16 20:29:34 +00:00
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
updateUser: function(token, payLoad){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/updateUser/" + token;
|
|
|
|
|
|
|
|
req = {
|
2015-06-24 10:16:19 +00:00
|
|
|
method: "PUT",
|
2015-06-16 20:29:34 +00:00
|
|
|
url: url,
|
|
|
|
data: payLoad
|
|
|
|
};
|
2015-05-09 19:00:14 +00:00
|
|
|
return $http(req);
|
2015-06-22 10:06:56 +00:00
|
|
|
},
|
2015-06-23 16:04:41 +00:00
|
|
|
getCourseByCampusName: function(token){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
|
|
|
|
req = {
|
|
|
|
method : "GET",
|
2015-06-24 10:13:58 +00:00
|
|
|
url : url
|
2015-06-23 16:04:41 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
2015-06-22 10:06:56 +00:00
|
|
|
getAllCourses: function(token){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
|
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
|
|
|
|
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
getAllMessages: function(token){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllMessages/" + token;
|
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
|
|
|
|
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
2015-06-24 10:13:58 +00:00
|
|
|
createMessage: function(token, payLoad){
|
2015-06-24 11:01:08 +00:00
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/createMessage/" + token;
|
2015-06-24 10:13:58 +00:00
|
|
|
req = {
|
|
|
|
method : "POST",
|
|
|
|
url : url,
|
|
|
|
data: payLoad
|
|
|
|
|
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
2015-06-24 11:01:08 +00:00
|
|
|
getMessagesByCourseName: function(token, courseName){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getMessagesByCourseName/" + token + '/' + courseName;
|
2015-06-22 10:06:56 +00:00
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
|
|
|
|
2015-06-24 11:01:08 +00:00
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
createCourse: function(token, payLoad){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/create/" + token;
|
|
|
|
req = {
|
|
|
|
method : "POST",
|
|
|
|
url : url,
|
|
|
|
data: payLoad
|
|
|
|
|
2015-06-24 18:35:21 +00:00
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
getCampusesByUser: function(){
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCampusesByUser/" + token;
|
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
|
|
|
|
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getClassesByCourse: function(){ // Need to add camusName (ngRoute) ~ sagi //TODO
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/ClassesByCourse/" + token;
|
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
|
|
|
|
|
|
|
};
|
|
|
|
return $http(req);
|
|
|
|
},
|
|
|
|
getProjectsByCourse: function(){ // Need to add courseID (ngRoute) ~ sagi //TODO
|
|
|
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token;
|
|
|
|
req = {
|
|
|
|
method : "GET",
|
|
|
|
url : url
|
|
|
|
|
2015-06-22 10:06:56 +00:00
|
|
|
};
|
|
|
|
return $http(req);
|
2015-05-09 19:00:14 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}]);
|