Merge branch 'UI'

This commit is contained in:
Sagi Dayan 2015-08-02 19:56:16 +03:00
commit 9ad25bff88
7 changed files with 48 additions and 52 deletions

View file

@ -307,8 +307,9 @@ def getProjectsByUser(token):
arr = []
for p in user.projects_id_list:
project = Project.get_by_id(int(p))
projDict = dict(json.loads(project.to_JSON()))
arr.append(projDict)
if project is not None:
projDict = dict(json.loads(project.to_JSON()))
arr.append(projDict)
if len(arr) != 0:
return Response(response=json.dumps(arr),

View file

@ -17,8 +17,17 @@ angular.module('SeHub')
var dayDeltaOfCourse;
var courseElapseTime;
$scope.isCourseOver = false;
$scope.isInProject = false;
$scope.createSctionStatus = "fa fa-angle-down";
for(var i = 0; i < $scope.user.courses_id_list.length; i++)
if($scope.user.courses_id_list[i] === classId)
$scope.isInCourse = true;
for(var i = 0; i < $scope.user.projects_id_list.length; i++)
if($scope.user.projects_id_list[i])
$scope.isInProject = true;
$scope.displayProjects = function() {
apiService.getCourseById(token, classId)
.success(function(data) {
@ -36,22 +45,21 @@ angular.module('SeHub')
courseElapseTime = dayDeltaOfCourse;
}
$scope.courseTimePresentege = ((courseElapseTime/dayDeltaOfCourse) * 100).toString();
console.log($scope.courseTimePresentege);
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
{
$scope.loadingData = false;
$scope.projects = data;
if ($scope.projects != null && $scope.projects.length > 0) {
$scope.projectsEmpty = false;
}
init(); // Executing the function to initialize projects display
}).error(function(err) {
console.error("Error: " + err);
{
$scope.loadingData = false;
$scope.projects = data;
if ($scope.projects != null && $scope.projects.length > 0) {
$scope.projectsEmpty = false;
}
init(); // Executing the function to initialize projects display
}).error(function(err) {
console.error(err.message);
});
})
.error(function(err) {
console.error("Error: " + err);
console.error(err.message);
})
}
$scope.joinCourse = function() {
@ -60,14 +68,11 @@ angular.module('SeHub')
$mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.')
.ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent())
.then(function() {
$location.path('/class/' + classId); // TODO TODO TODO
$location.path('/class/' + classId + '/' + $scope.project.courseName); // TODO TODO TODO
}); // Pop-up alert
}).error(function(err) {
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.')
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
// .then(function() {
// // $location.path('/newCourse'); // TODO TODO TODO
// });
});
}
@ -87,9 +92,6 @@ angular.module('SeHub')
'courseId': intClassId,
'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName
};
console.log("Look Down");
console.log(jsonNewProj);
if ($scope.project.logoUrl)
jsonNewProj.logo_url = $scope.project.logoUrl;
@ -115,7 +117,6 @@ angular.module('SeHub')
$scope.goToProject = function(projectId)
{
console.log("projects only from classID: " + projectId)
$location.path('/project/' + projectId);
}

View file

@ -56,10 +56,8 @@ angular.module('SeHub')
apiService.createMessage(token, jsonNewMsg).success(function(data)
{
console.log("create Msg!");
}).error(function(err)
{
console.log("Error Below");
console.log(err.message);
});
@ -85,7 +83,6 @@ angular.module('SeHub')
{
apiService.getProjectsByCourse(token, task.courseId).success(function(data)
{
// console.log($scope.user);
for(var i = 0; i < $scope.user.projects_id_list.length; i++)
for(var j = 0; j < data.length; j++)
{

View file

@ -14,27 +14,24 @@ angular.module('SeHub')
$scope.showMyClass = false;
$scope.coursesEmpty = true;
$scope.campusId;
$scope.isMemberInCourse = false;
var campusId = $routeParams.campusId;
$scope.goToClass = function(classId, className)
{
console.log("Done! " + className);
$location.path('/class/' + classId.toString() + '/' + className); // Will display all the projects in this course
}
$scope.chooseCampusClicked = function()
{
$scope.isCourse = true;
console.log("Choose campus Clicked!!");
apiService.getAllCampuses(token).success(function(data)
{
$scope.campuses = data;
console.log("Campuses: ");
console.log($scope.campuses);
}).error(function(err)
{
console.log("Error: " + err);
console.log(err.message);
});
}
@ -55,8 +52,6 @@ angular.module('SeHub')
$scope.campusId = $scope.campuses[i].id;
}
}
console.log("NOW: ");
console.log($scope.campusId);
var jsonNewCourse =
{
@ -77,11 +72,9 @@ angular.module('SeHub')
apiService.createCourse(token, jsonNewCourse).success(function(data)
{
console.log("createCourse API done");
$mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.')
.ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent())
.then(function() {
// $location.path('/newCourse'); // TODO TODO TODO
$location.path('/class/' + data.id + '/' + data.courseName); // Will display all the projects in this course
}); // Pop-up alert
}).error(function(err)
@ -118,15 +111,12 @@ angular.module('SeHub')
$scope.holdArrays.push(tempArr);
}
//$scope.courses = ["lala", "aaa", "bbb", "ccc", "rrr"];
var displayCourses = function()
{
apiService.getAllCoursesByCampus(token, campusId).success(function(data) // Shows all classes from this campus
{
$scope.loadingData = false;
$scope.courses = data;
console.log("success " + $scope.courses);
init(); // Executing the function to initialize course display
if($scope.courses && $scope.courses.length > 0)
{
@ -134,24 +124,17 @@ angular.module('SeHub')
}
}).error(function(err)
{
console.log("error: " + err);
console.log(err.message);
});
}
if($scope.user.isLecturer)
{
$scope.isStudent = false;
console.log("Lecturer Mode!");
}
else
{
$scope.isStudent = true;
console.log("Student Mode!");
}
displayCourses(); // Will display the courses that the user related to // TODO!!
}]);

View file

@ -9,6 +9,8 @@ angular.module('SeHub')
$scope.loadingData = true;
$scope.isMaster = false;
$scope.isMember = false;
$scope.project = [];
$scope.isInProject = false;
// $scope.thisProject = {};
// $scope.thisProject.courseName = $routeParams.className;
@ -22,7 +24,6 @@ angular.module('SeHub')
{
console.log(err.message);
});
}
$scope.joinProject = function(ev)
@ -57,6 +58,7 @@ angular.module('SeHub')
{
$mdDialog.show($mdDialog.alert().title('Project Removal').content('Project removed successfully.')
.ariaLabel('project remove alert dialog').ok('Ok').targetEvent(ev));
$location.path('/myProjects');
}).error(function(err)
{
$mdDialog.show($mdDialog.alert().title('Project Removal').content('Project removal failed - reason' + err.message)
@ -96,6 +98,19 @@ angular.module('SeHub')
$scope.isMember = true;
}
}
apiService.getProjectsByCourse(token, $scope.project.courseId).success(function(data)
{
if($scope.user.projects_id_list)
for(var i = 0; i < $scope.project.length; i++)
if($scope.user.projects_id_list[i].id === data[i].id.toString())
$scope.isInProject = true;
}).error(function(err)
{
console.log(err.message);
});
// if($scope.user === $scope.project.info.master_id)
// {
// $scope.isMasterOrLecturer = true;
@ -106,9 +121,8 @@ angular.module('SeHub')
// }
}).error(function(err)
{
console.log("Error: " + err.message);
console.log(err.message);
});
}
$scope.getProjectInfo(); // Get all this project data
}]);

View file

@ -27,7 +27,7 @@
<md-button ng-click = "joinCourse()" ng class = "md-raised md-primary" ng-disabled="isCourseOver"><i class="fa fa-plus"></i> Join Class</md-button>
</div>
<div layout-margin>
<md-content>
<md-content ng-if="isInCourse && !isInProject">
<md-button ng-click="createProjectClicked()" ng class="md-raised md-primary" ng-disabled="isCourseOver">Create Project <i ng-class="createSctionStatus"></i></md-button>
</md-content>
</div>

View file

@ -18,7 +18,7 @@
<div layout = "row" flex = "45">
<!-- <div ng-if = "isMasterOrLecturer"> -->
<md-card layout = "row">
<div ng-if="!isMember" layout-padding>
<div ng-if="!isMember && !isInProject" layout-padding>
<md-button ng-click="joinProject($event)" ng class = "md-raised md-primary" aria-label="jP">
<i class="fa fa-user-plus"></i>
</md-button>
@ -43,7 +43,7 @@
<div flex = "10" layout-padding layout-margin border = "1">
Team Members:
<ul layout-padding>
<div layout = "row">
<!-- <div layout = "row"> -->
<li ng-repeat = "member in project.members">
<div>
<a ng-href="#/profile/{{member.id}}" style="text-decoration:none; color:black;"> {{member.name}}</a>
@ -54,7 +54,7 @@
</md-button>
</div>
</li>
</div>
<!-- </div> -->
</ul>
</div>
<div flex = "40">