2015-06-23 16:40:30 +00:00
|
|
|
angular.module('SeHub')
|
2015-06-27 09:45:44 +00:00
|
|
|
.controller('projectsController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
2015-06-23 16:40:30 +00:00
|
|
|
{
|
2015-06-27 09:45:44 +00:00
|
|
|
var token = $cookies['com.sehub.www'];
|
2015-06-29 11:41:17 +00:00
|
|
|
var classId = $routeParams.classId;
|
2015-06-27 09:45:44 +00:00
|
|
|
$scope.projectEmpty = false;
|
|
|
|
|
|
|
|
$scope.displayProjects = function()
|
|
|
|
{
|
|
|
|
console.log("in displayProjecs!!! ");
|
|
|
|
apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses
|
|
|
|
{
|
|
|
|
$scope.projects = data;
|
|
|
|
init(); // Executing the function to initialize projects display
|
|
|
|
console.log("project created! not rly!! " + classId);
|
|
|
|
}).error(function(err)
|
|
|
|
{
|
|
|
|
console.log("Error: " + err);
|
|
|
|
});
|
2015-06-27 09:58:04 +00:00
|
|
|
if($scope.projects = null)
|
|
|
|
{
|
|
|
|
$scope.projectEmpty = true;
|
|
|
|
}
|
2015-06-27 09:45:44 +00:00
|
|
|
}
|
2015-06-29 11:41:17 +00:00
|
|
|
$scope.joinCourse = function()
|
|
|
|
{
|
|
|
|
apiService.joinCourse(token, classId).success(function(data)
|
|
|
|
{
|
|
|
|
console.log("Success!!");
|
|
|
|
$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('/projects/' + classId); // TODO TODO TODO
|
|
|
|
}); // Pop-up alert
|
|
|
|
}).error(function(err)
|
|
|
|
{
|
|
|
|
$mdDialog.show($mdDialog.alert().title('Error Joining Course').content('You have failed joined the course.')
|
|
|
|
.ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert
|
|
|
|
// .then(function() {
|
|
|
|
// // $location.path('/newCourse'); // TODO TODO TODO
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
}
|
2015-06-23 16:40:30 +00:00
|
|
|
|
|
|
|
$scope.createProjectClicked = function()
|
|
|
|
{
|
2015-06-27 09:45:44 +00:00
|
|
|
console.log("project created! not rly!! " + classId);
|
2015-06-29 11:41:17 +00:00
|
|
|
|
2015-06-23 16:40:30 +00:00
|
|
|
// $window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page
|
|
|
|
}
|
|
|
|
|
2015-06-27 09:45:44 +00:00
|
|
|
// $scope.projects = ['AMI', 'LULU', 'XIN Zhau', 'LUMI lu', 'Shimi', 'Azligi zligi', 'Drugs'];
|
2015-06-23 16:40:30 +00:00
|
|
|
|
2015-06-27 09:45:44 +00:00
|
|
|
$scope.goToProject = function()
|
|
|
|
{
|
|
|
|
console.log("projects only from classID: " + classId)
|
|
|
|
$location.path('/thisProject' + classId);
|
|
|
|
}
|
2015-06-23 16:40:30 +00:00
|
|
|
|
2015-06-26 13:49:46 +00:00
|
|
|
var init = function()
|
|
|
|
{
|
2015-06-28 12:27:06 +00:00
|
|
|
$scope.arrayHolder = [];
|
|
|
|
var tempArr = [];
|
|
|
|
var sizeOfSmallArrays = 3;
|
|
|
|
for (var i = 0 ; i < $scope.courses.length ; i++) {
|
|
|
|
if(i % sizeOfSmallArrays !== 0){
|
|
|
|
tempArr.push($scope.courses[i]);
|
|
|
|
}else{
|
|
|
|
if(i !== 0){
|
|
|
|
$scope.arrayHolder.push(tempArr);
|
|
|
|
tempArr = [];
|
|
|
|
tempArr.push($scope.courses[i]);
|
|
|
|
}else{
|
|
|
|
tempArr.push($scope.courses[i]);
|
2015-06-27 09:58:04 +00:00
|
|
|
}
|
2015-06-28 12:27:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
$scope.arrayHolder.push(tempArr);
|
2015-06-27 09:45:44 +00:00
|
|
|
}
|
2015-06-26 13:49:46 +00:00
|
|
|
|
|
|
|
|
2015-06-29 11:41:17 +00:00
|
|
|
// Running...
|
|
|
|
$scope.displayProjects(); // Displaying all projects related to user
|
|
|
|
|
2015-06-27 09:45:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
var jsonNewCourse =
|
|
|
|
{
|
2015-06-29 11:41:17 +00:00
|
|
|
'projectName': $scope.course.courseName,
|
|
|
|
'courseId': classId,
|
2015-06-27 09:45:44 +00:00
|
|
|
'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
|
|
|
|
}
|
|
|
|
};*/
|
|
|
|
|
|
|
|
/*
|
2015-06-26 13:49:46 +00:00
|
|
|
{
|
2015-06-27 09:45:44 +00:00
|
|
|
'projectName': 'Advance Math',
|
|
|
|
'courseName': 'JCE',
|
|
|
|
'grade': 98,
|
|
|
|
'logo_url': 'http://location.domain.com/image.jpg',
|
|
|
|
'gitRepository': 'http://location.git.com/somthing',
|
|
|
|
'membersId': ['bob', 'dylan', 'quentin', 'terentino'],
|
|
|
|
'id' : 1234567890
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-26 13:49:46 +00:00
|
|
|
|
|
|
|
|
2015-06-23 16:40:30 +00:00
|
|
|
|
|
|
|
}]);
|