diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index 879dcbb..d043e37 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -5,8 +5,11 @@ angular.module('SeHub') $scope.isCourse = false; $scope.isNewCourse = false; $scope.newClassName = false; - $scope.user.createNewCourse = ''; + // $scope.course.courseName = ''; + $scope.course = {}; + var token = $cookies['com.sehub.www']; $scope.user.finalDate = ''; + $scope.user.startDate = ''; $scope.showMyClass = false; if($scope.user.isLecturer) @@ -42,13 +45,38 @@ angular.module('SeHub') $scope.submitNewClassClicked = function() { - if($scope.user.createNewCourse != '' && $scope.user.finalDate != '') + if($scope.course.courseName != '' && $scope.course.endDate != '' && $scope.course.startDate != '') { - console.log("finalDate " + $scope.user.finalDate); - console.log($scope.user.createNewCourse); + var jsonNewCourse = + { + 'courseName': $scope.course.courseName, + 'campusName': $scope.course.campusName, + 'startDate': { + 'year' : $scope.course.startDate.getFullYear(), + 'day' : $scope.course.startDate.getDate(), + 'month': ($scope.course.startDate.getMonth() + 1) + }, + 'endDate': { + 'year' : $scope.course.endDate.getFullYear(), + 'day' : $scope.course.endDate.getDate(), + 'month': ($scope.course.endDate.getMonth() + 1) + } + }; + + console.log("Json here:"); + console.log(jsonNewCourse); + + apiService.createCourse(token, jsonNewCourse).success(function(data) + { + console.log("createCourse API done"); + }).error(function(err) + { + console.log(err); + }); $mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.') .ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent()); // $window.location.href = 'templates/views/newCourse.html'; // TODO TODO TODO + } else { diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index f8a877e..6c45506 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -71,7 +71,7 @@ service.factory('apiService', ['$http', function($http) { return $http(req); }, createMessage: function(token, payLoad){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseMessages/" + token; + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/createMessage/" + token; req = { method : "POST", url : url, @@ -80,12 +80,22 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, - getCourseMessages: function(token, courseName){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseMessages/" + token + '/' + courseName; + getMessagesByCourseName: function(token, courseName){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getMessagesByCourseName/" + token + '/' + courseName; req = { method : "GET", url : url + }; + 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 + }; return $http(req); } diff --git a/templates/views/myClasses.html b/templates/views/myClasses.html index de8a765..5086fbd 100644 --- a/templates/views/myClasses.html +++ b/templates/views/myClasses.html @@ -27,28 +27,24 @@