Merge pull request #84 from sagidayan/UI

- create class is working again
This commit is contained in:
Sagi Dayan 2015-06-29 13:00:23 +03:00
commit 02a10aba63
4 changed files with 29 additions and 17 deletions

View file

@ -12,6 +12,7 @@ angular.module('SeHub')
$scope.user.startDate = '';
$scope.showMyClass = false;
$scope.coursesEmpty = false;
$scope.campusId;
var campusId = $routeParams.campusId;
$scope.goToClass = function(classId)
@ -20,15 +21,16 @@ angular.module('SeHub')
$location.path('/projects/' + classId.toString()); // Will display all the projects in this course
}
$scope.chooseCourseClicked = function()
$scope.chooseCampusClicked = function()
{
$scope.isCourse = true;
console.log("choose course Clicked!!");
console.log("Choose campus Clicked!!");
apiService.getAllCampuses(token).success(function(data)
{
$scope.campuses = data;
console.log("Campuses: " + $scope.campuses.toString());
console.log("Campuses: ");
console.log($scope.campuses);
}).error(function(err)
{
console.log("Error: " + err);
@ -42,12 +44,23 @@ angular.module('SeHub')
$scope.submitNewClassClicked = function()
{
var i;
if($scope.course.courseName != null && $scope.course.endDate != null && $scope.course.startDate != null)
{
for(i = 0; i < $scope.campuses.length; i++)
{
if($scope.course.campusName === $scope.campuses[i].title)
{
$scope.campusId = $scope.campuses[i].id;
}
}
console.log("NOW: ");
console.log($scope.campusId);
var jsonNewCourse =
{
'courseName': $scope.course.courseName,
'campusName': $scope.course.campusName,
'campusId': $scope.campusId,
'startDate': {
'year' : $scope.course.startDate.getFullYear(),
'day' : $scope.course.startDate.getDate(),
@ -108,7 +121,7 @@ angular.module('SeHub')
var displayCourses = function()
{
apiService.getCourseByCampusName(token).success(function(data) // Shows all classes from this campus
apiService.getCoursesByCampus(campusId).success(function(data) // Shows all classes from this campus
{
$scope.courses = data;
console.log("success " + $scope.courses);

View file

@ -43,8 +43,8 @@ service.factory('apiService', ['$http', function($http) {
};
return $http(req);
},
getCourseByCampusName: function(token){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseByCampusName/" + token;
getCoursesByCampus: function(campusId){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByCampus/" + campusId;
req = {
method : "GET",
url : url

View file

@ -3,31 +3,30 @@
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> My Classes</h1>
</md-content>
<md-card class="cardAllcourses">
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
<div flex = "32" layout = "column" ng-repeat = "course in t" value = "{{course}}" >
<div ng-if = "scope.coursesEmpty">
<div ng-if = "!scope.coursesEmpty">
<div ng-if="t.length != 1">
<md-button ng-click = "goToClass(course.id)" style="width:100%; height:32%;" layout-padding class = "md-raised" >
<md-card style="width:97%;height:97%">
<md-card-content>
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
<h2 class="md-title">{{course.courseName}}</h2> <!-- Should Be "course.title" -->
</md-card-content>
</md-2card>
</md-card>
</md-button>
</div>
<div ng-if="t.length == 1">
<md-button ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "md-raised" >
<md-card style="width:97%;height:97%">
<md-card-content>
<h2 class="md-title">{{course.title}}</h2> <!-- Should Be "course.title" -->
<h2 class="md-title">{{course.courseName}}</h2> <!-- Should Be "course.title" -->
</md-card-content>
</md-card>
</md-button>
</div>
</div>
<div class="spacer"></div>
<div ng-if = "!scope.coursesEmpty">
<div ng-if = "scope.coursesEmpty">
You Are Not Related To Any Course, You May Join Any Course You Wish.
</div>
</div>
@ -57,7 +56,7 @@
<md-card layout-padding>
<div layout layout-sm="column">
<!-- <input ng-model="course.campusName" required> -->
<md-select placeholder = "Campus name" ng-model="course.campusName" ng-click = "chooseCourseClicked()" required>
<md-select placeholder = "Campus name" ng-model="course.campusName" ng-click = "chooseCampusClicked()" required>
<md-option ng-repeat="c in campuses" value="{{c.title}}">
{{c.title}}
</md-option>