Merge branch 'UI'
This commit is contained in:
commit
710bbb38eb
6 changed files with 97 additions and 47 deletions
|
@ -68,7 +68,7 @@ app.config(['$routeProvider', '$locationProvider',
|
||||||
})
|
})
|
||||||
.when('/myProjects', {
|
.when('/myProjects', {
|
||||||
templateUrl: 'templates/views/myProjects.html',
|
templateUrl: 'templates/views/myProjects.html',
|
||||||
controller: 'thisProjectController'
|
controller: 'myProjectsController'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
angular.module('SeHub')
|
angular.module('SeHub')
|
||||||
.controller('thisProjectController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
.controller('myProjectsController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||||
{
|
{
|
||||||
$scope.isEditPressed = false;
|
$scope.isEditPressed = false;
|
||||||
$scope.myProjectsEmpty = false;
|
$scope.myProjectsEmpty = false;
|
||||||
var token = $cookies['com.sehub.www'];
|
var token = $cookies['com.sehub.www'];
|
||||||
|
|
||||||
|
$scope.user = $scope.$parent.user;
|
||||||
|
|
||||||
|
|
||||||
$scope.displayMyProjects = function()
|
$scope.displayMyProjects = function()
|
||||||
{
|
{
|
||||||
|
@ -20,7 +19,7 @@ angular.module('SeHub')
|
||||||
});
|
});
|
||||||
if($scope.myProjects === null)
|
if($scope.myProjects === null)
|
||||||
{
|
{
|
||||||
myProjectsEmpty = true;
|
$scope.myProjectsEmpty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,37 +31,23 @@ angular.module('SeHub')
|
||||||
|
|
||||||
var init = function()
|
var init = function()
|
||||||
{
|
{
|
||||||
var i, j, counter = 0;
|
$scope.arrayHolder = [];
|
||||||
var newLength = 0;
|
var tempArr = [];
|
||||||
|
var sizeOfSmallArrays = 3;
|
||||||
if(($scope.projects.length % 3) === 0)
|
for (var i = 0 ; i < $scope.projects.length ; i++) {
|
||||||
{
|
if(i % sizeOfSmallArrays !== 0){
|
||||||
newLength = ($scope.projects.length / 3);
|
tempArr.push($scope.projects[i]);
|
||||||
}
|
}else{
|
||||||
else
|
if(i !== 0){
|
||||||
{
|
$scope.arrayHolder.push(tempArr);
|
||||||
newLength = (Math.ceil($scope.projects.length / 3)); // Rounds number up
|
tempArr = [];
|
||||||
}
|
tempArr.push($scope.projects[i]);
|
||||||
|
}else{
|
||||||
console.log("length: " + newLength);
|
tempArr.push($scope.projects[i]);
|
||||||
$scope.arrayHolder.length = newLength;
|
|
||||||
|
|
||||||
for(j = 0; j < newLength; j++)
|
|
||||||
{
|
|
||||||
$scope.arrayHolder[j] = [3]; // Creating array in size of 3 in each array cell
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < newLength; i++)
|
|
||||||
{
|
|
||||||
for(j = 0; j < newLength; j++)
|
|
||||||
{
|
|
||||||
if($scope.projects[(3*i) + j] != null)
|
|
||||||
{
|
|
||||||
$scope.arrayHolder[i][j] = $scope.projects[(3*i) + j];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
console.log($scope.arrayHolder);
|
$scope.arrayHolder.push(tempArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.editPressed = function()
|
$scope.editPressed = function()
|
||||||
|
|
|
@ -2,7 +2,7 @@ angular.module('SeHub')
|
||||||
.controller('projectsController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
.controller('projectsController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
|
||||||
{
|
{
|
||||||
var token = $cookies['com.sehub.www'];
|
var token = $cookies['com.sehub.www'];
|
||||||
var classId = $routeParams.id;
|
var classId = $routeParams.classId;
|
||||||
$scope.projectEmpty = false;
|
$scope.projectEmpty = false;
|
||||||
|
|
||||||
$scope.displayProjects = function()
|
$scope.displayProjects = function()
|
||||||
|
@ -22,12 +22,30 @@ angular.module('SeHub')
|
||||||
$scope.projectEmpty = true;
|
$scope.projectEmpty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$scope.joinCourse = function()
|
||||||
$scope.displayProjects(); // Displaying all projects related to user
|
{
|
||||||
|
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
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$scope.createProjectClicked = function()
|
$scope.createProjectClicked = function()
|
||||||
{
|
{
|
||||||
console.log("project created! not rly!! " + classId);
|
console.log("project created! not rly!! " + classId);
|
||||||
|
|
||||||
// $window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page
|
// $window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +79,16 @@ angular.module('SeHub')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Running...
|
||||||
|
$scope.displayProjects(); // Displaying all projects related to user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var jsonNewCourse =
|
var jsonNewCourse =
|
||||||
{
|
{
|
||||||
'courseName': $scope.course.courseName,
|
'projectName': $scope.course.courseName,
|
||||||
'campusName': $scope.course.campusName,
|
'courseId': classId,
|
||||||
'startDate': {
|
'startDate': {
|
||||||
'year' : $scope.course.startDate.getFullYear(),
|
'year' : $scope.course.startDate.getFullYear(),
|
||||||
'day' : $scope.course.startDate.getDate(),
|
'day' : $scope.course.startDate.getDate(),
|
||||||
|
|
|
@ -117,7 +117,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getProjectsByCourse: function(token, classId){
|
getProjectsByCourse: function(token, classId){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token + "/" + classId;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectsByCourse/" + token + "/" + classId;
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
@ -126,7 +126,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
getProjectsByUser: function(token){
|
getProjectsByUser: function(token){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/getProjectsByUser/" + token;
|
||||||
req = {
|
req = {
|
||||||
method : "GET",
|
method : "GET",
|
||||||
url : url
|
url : url
|
||||||
|
@ -153,7 +153,7 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
joinCourse: function(token, courseId){
|
joinCourse: function(token, courseId){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserById/" + token + "/" + courseId;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/joinCourse/" + token + "/" + courseId;
|
||||||
req = {
|
req = {
|
||||||
method : "PUT",
|
method : "PUT",
|
||||||
url : url
|
url : url
|
||||||
|
@ -169,6 +169,15 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
};
|
};
|
||||||
return $http(req);
|
return $http(req);
|
||||||
},
|
},
|
||||||
|
createProject: function(token, payLoad){
|
||||||
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/create/" + token;
|
||||||
|
req = {
|
||||||
|
method : "POST",
|
||||||
|
url : url,
|
||||||
|
data: payLoad
|
||||||
|
};
|
||||||
|
return $http(req);
|
||||||
|
},
|
||||||
getCoursesByUserID: function(token, userId){
|
getCoursesByUserID: function(token, userId){
|
||||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + userId;
|
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + userId;
|
||||||
req = {
|
req = {
|
||||||
|
|
|
@ -1,8 +1,38 @@
|
||||||
<div class = "myProjects">
|
<div class = "myProjects">
|
||||||
<md-content layout-padding layout-margin>
|
<md-content layout-padding layout-margin>
|
||||||
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> {{user.name}}'s projects</h1>
|
<h1 layout-margin style="margin-left:15px"><i class="fa fa-cube"></i> {{user.name}}'s projects</h1>
|
||||||
<md-card class="cardAllProjects">
|
<md-card class="cardAllProjects">
|
||||||
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
<div flex = "99" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}" layout-padding>
|
||||||
|
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" >
|
||||||
|
<div ng-if = "!scope.myProjectsEmpty">
|
||||||
|
<div ng-if="t.length != 1">
|
||||||
|
<md-button ng-click = "goToMyProjects(project.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">{{project.id}}</h2>
|
||||||
|
</md-card-content>
|
||||||
|
</md-card>
|
||||||
|
</md-button>
|
||||||
|
</div>
|
||||||
|
<div ng-if="t.length == 1">
|
||||||
|
<md-button ng-click = "goToMyProjects(project.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">{{project.id}}</h2>
|
||||||
|
</md-card-content>
|
||||||
|
</md-card>
|
||||||
|
</md-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<div ng-if = "scope.myProjectsEmpty">
|
||||||
|
You Do Not Have Any Project, You May Create One.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
||||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
||||||
<div ng-if = "!scope.myProjectsEmpty">
|
<div ng-if = "!scope.myProjectsEmpty">
|
||||||
<md-card layout-padding ng-click = "goToMyProject(project.id)" style="width:32%; height:32%;" class = "projectCard">
|
<md-card layout-padding ng-click = "goToMyProject(project.id)" style="width:32%; height:32%;" class = "projectCard">
|
||||||
|
@ -13,7 +43,9 @@
|
||||||
<div ng-if = "scope.myProjectsEmpty">
|
<div ng-if = "scope.myProjectsEmpty">
|
||||||
You Do Not Have Any Project, You May Create One.
|
You Do Not Have Any Project, You May Create One.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
</md-card>
|
</md-card>
|
||||||
</md-content>
|
</md-content>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<div class = "projects">
|
<div class = "projects">
|
||||||
<h1 style="margin-left:15px"><i class="fa fa-cube"></i> Projects</h1>
|
<h1 style="margin-left:15px"><i class="fa fa-graduation-cap"></i> Class {{course.courseName}}</h1>
|
||||||
|
<div layout-padding layout-margin>
|
||||||
|
<md-button ng-click = "joinCourse()" ng class = "md-raised"> Join Course</md-button>
|
||||||
|
</div>
|
||||||
<md-card class="cardAllProjects">
|
<md-card class="cardAllProjects">
|
||||||
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
<div flex ="99" class = "allProjectsShow" layout = "row" ng-repeat = "t in arrayHolder" value = "{{t}}">
|
||||||
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
<div flex = "32" layout = "column" ng-repeat = "project in t" value = "{{project}}" layout-padding>
|
||||||
|
|
Loading…
Reference in a new issue