diff --git a/templates/js/app.js b/templates/js/app.js
index d9b650a..87c3eaa 100644
--- a/templates/js/app.js
+++ b/templates/js/app.js
@@ -66,8 +66,8 @@ app.config(['$routeProvider', '$locationProvider',
templateUrl: 'templates/views/campuses.html',
controller: 'campusesController'
})
- .when('/thisProject/:projectId', {
- templateUrl: 'templates/views/thisProject.html',
+ .when('/myProjects', {
+ templateUrl: 'templates/views/myProjects.html',
controller: 'thisProjectController'
});
}
diff --git a/templates/js/controllers/campusesController.js b/templates/js/controllers/campusesController.js
index 18a79dd..ead0ef2 100644
--- a/templates/js/controllers/campusesController.js
+++ b/templates/js/controllers/campusesController.js
@@ -5,56 +5,37 @@ angular.module('SeHub')
$scope.campusesEmpty = false;
var token = $cookies['com.sehub.www'];
- apiService.getCampusesByUser(token).success(function(data) // Get all the campuses
- {
- $scope.campuses = data;
- console.log("INSIDE " + $scope.campuses);
- init(); // Executing the function to initialize campuses display
-
- }).error(function() {
- // TODO
- });
- console.log($scope.campuses);
-
-
var init = function()
{
var i, j, counter = 0;
var newLength = 0;
- if($scope.campuses != null)
+ if(($scope.campuses.length % 3) === 0)
{
- if(($scope.campuses.length % 3) === 0)
- {
- newLength = ($scope.campuses.length / 3);
- }
- else
- {
- newLength = (Math.ceil($scope.campuses.length / 3)); // Rounds number up
- }
-
- console.log("length: " + newLength);
- $scope.threeSizedArray.length = newLength;
-
- for(j = 0; j < newLength; j++)
- {
- $scope.threeSizedArray[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.campuses[(3*i) + j] != null)
- {
- $scope.threeSizedArray[i][j] = $scope.campuses[(3*i) + j];
- }
- }
- }
+ newLength = ($scope.campuses.length / 3);
}
else
{
- $scope.campusesEmpty = true;
+ newLength = (Math.ceil($scope.campuses.length / 3)); // Rounds number up
+ }
+
+ console.log("length: " + newLength);
+ $scope.threeSizedArray.length = newLength;
+
+ for(j = 0; j < newLength; j++)
+ {
+ $scope.threeSizedArray[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.campuses[(3*i) + j] != null)
+ {
+ $scope.threeSizedArray[i][j] = $scope.campuses[(3*i) + j];
+ }
+ }
}
console.log($scope.threeSizedArray); // TODO REMOVE
}
@@ -64,6 +45,26 @@ angular.module('SeHub')
$location.path('/myClasses/' + campusId.toString());
}
+ $scope.displayCampuses = function()
+ {
+ apiService.getCampusesByUser(token).success(function(data) // Get all the campuses
+ {
+ $scope.campuses = data;
+ console.log("INSIDE " + $scope.campuses);
+ init(); // Executing the function to initialize campuses display
+
+ }).error(function()
+ {
+ // TODO
+ });
+ if($scope.campuses != null)
+ {
+ $scope.campusesEmpty = true;
+ }
+ }
+
+ $scope.displayCampuses(); // Displaying all campuses by user
+
}]);
diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js
index 135b39c..fe0a671 100644
--- a/templates/js/controllers/mainController.js
+++ b/templates/js/controllers/mainController.js
@@ -28,10 +28,10 @@ angular.module('SeHub')
"style": "",
"route": "/campuses"
}, {
- "title": "Projects",
+ "title": "My Projects",
"icon": "fa fa-cube",
"style": "",
- "route": "/projects/" + $scope.user.id.toString()
+ "route": "/myProjects"
}, {
"title": "Tasks",
"icon": "fa fa-clipboard",
diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js
index 4d5836d..e1f7fa1 100644
--- a/templates/js/controllers/myClassesController.js
+++ b/templates/js/controllers/myClassesController.js
@@ -24,6 +24,10 @@ angular.module('SeHub')
{
console.log("error: " + err);
});
+ if($scope.courses = null)
+ {
+ $scope.coursesEmpty = true;
+ }
}
$scope.goToClass = function(classId)
@@ -99,42 +103,35 @@ angular.module('SeHub')
{
var i, j, counter = 0;
var newLength = 0;
-
- if($scope.courses != null)
+
+ if(($scope.courses.length % 3) === 0)
{
- if(($scope.courses.length % 3) === 0)
- {
- newLength = ($scope.courses.length / 3);
- }
- else
- {
- newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up
- }
-
- console.log("length: " + newLength);
- $scope.holdArrays.length = newLength;
-
- for(j = 0; j < newLength; j++)
- {
- $scope.holdArrays[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.courses[(3*i) + j] != null)
- {
- $scope.holdArrays[i][j] = $scope.courses[(3*i) + j];
- }
- }
- }
+ newLength = ($scope.courses.length / 3);
}
else
{
- $scope.coursesEmpty = true;
+ newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up
}
- console.log($scope.holdArrays);
+
+ console.log("length: " + newLength);
+ $scope.holdArrays.length = newLength;
+
+ for(j = 0; j < newLength; j++)
+ {
+ $scope.holdArrays[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.courses[(3*i) + j] != null)
+ {
+ $scope.holdArrays[i][j] = $scope.courses[(3*i) + j];
+ }
+ }
+ }
+ console.log($scope.holdArrays);
}
diff --git a/templates/js/controllers/projectsController.js b/templates/js/controllers/projectsController.js
index a2c835f..0bd6b99 100644
--- a/templates/js/controllers/projectsController.js
+++ b/templates/js/controllers/projectsController.js
@@ -23,8 +23,6 @@ angular.module('SeHub')
}
}
-
-
$scope.displayProjects(); // Displaying all projects related to user
$scope.createProjectClicked = function()
diff --git a/templates/js/controllers/thisProjectController.js b/templates/js/controllers/thisProjectController.js
deleted file mode 100644
index a1cb837..0000000
--- a/templates/js/controllers/thisProjectController.js
+++ /dev/null
@@ -1,16 +0,0 @@
-angular.module('SeHub')
-.controller('thisProjectController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope)
-{
- $scope.isEditPressed = false;
-
- $scope.editPressed = function()
- {
- $scope.isEditPressed = true;
- console.log("EditPressed " + $scope.isEditPressed);
- }
- $scope.removeProject = function()
- {
- console.log("Project has been removed!");
- }
-
-}]);
\ No newline at end of file
diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js
index 5c636aa..8d14f27 100644
--- a/templates/js/services/apiService.js
+++ b/templates/js/services/apiService.js
@@ -125,6 +125,16 @@ service.factory('apiService', ['$http', function($http) {
};
return $http(req);
},
+ getProjectsByUser: function(token){
+ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token;
+ req = {
+ method : "GET",
+ url : url
+
+ };
+ return $http(req);
+ },
+
getUserById: function(token, id){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserById/" + token + "/" + id;
req = {
diff --git a/templates/views/index.html b/templates/views/index.html
index f719a34..56f7232 100644
--- a/templates/views/index.html
+++ b/templates/views/index.html
@@ -117,7 +117,7 @@
-
+