- Main menu nav - My Projects reference fixed to user projects

- Main menu nav - click on Courses -> Campuses -> Courses -> Projects (all class users)

- API function getProjectsByUser - Added
This commit is contained in:
Matan Bar Yosef 2015-06-27 14:20:21 +03:00
parent b630f0d696
commit eb1240f3c4
10 changed files with 85 additions and 165 deletions

View file

@ -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'
});
}

View file

@ -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
}]);

View file

@ -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",

View file

@ -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);
}

View file

@ -23,8 +23,6 @@ angular.module('SeHub')
}
}
$scope.displayProjects(); // Displaying all projects related to user
$scope.createProjectClicked = function()

View file

@ -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!");
}
}]);

View file

@ -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 = {

View file

@ -117,7 +117,7 @@
<script src="templates/js/controllers/projectsController.js"></script>
<script src="templates/js/controllers/newCourseController.js"></script>
<script src="templates/js/controllers/campusesController.js"></script>
<script src="templates/js/controllers/thisProjectController.js"></script>
<script src="templates/js/controllers/myProjectsController.js"></script>
</body>
</html>

View file

@ -6,7 +6,6 @@
<div flex = "99" class = "allcoursesShow" layout = "row" ng-repeat = "t in holdArrays" value = "{{t}}">
<div flex ="32" layout = "column" ng-repeat = "course in t" value = "{{course}}" layout-padding>
<div ng-of = "!scope.coursesEmpty">
aaa
<md-card ng-click = "goToClass(course.id)" style="width:32%; height:32%;" layout-padding class = "campusCard">
{{course.id}}
</md-card>

View file

@ -1,69 +0,0 @@
<div class = "thisProject">
<md-content layout-padding layout-margin>
<h1 layout-margin style="margin-left:15px"><i class="fa fa-graduation-cap"></i> {{user.name}}'s project</h1>
<div layout-padding layout-margin>
<div layout = "row" layout-padding layout-margin>
<div flex = "49">
Project Creator: {{user.name}} <!-- Should Be Project creator -->
</div>
<div flex = "49" >
<div ng-if="user.isLecturer">
<div layout = "row" layout-padding>
<div>
<md-button ng-click="editPressed()" class="md-raised md-primary">Edit</md-button>
</div>
<div ng-if="isEditPressed">
<md-button ng-click="removeProject()" class="md-raised md-primary">Remove</md-button>
<!-- <i class = "fa fa-trash-o"></i> -->
</div>
</div>
</div>
</div>
</div>
<div layout = "row" layout-padding layout-margin>
<div flex = "49">
<md-card>
Here Will Be Graph - Commits Over Period Of Time
</md-card>
</div>
<div flex = "49">
<md-card>
Here Will Be Graph (by columns) - Commits, Issues, Open Tasks
</md-card>
</div>
</div>
<div flex>
<md-card>
<md-content class="md-padding">
<md-tabs md-dynamic-height md-border-bottom>
<md-tab label="Commits">
<md-content class="md-padding">
<h1 class="md-display-2">Commits</h1>
<p>Commits...</p>
</md-content>
</md-tab>
<md-tab label="Issues">
<md-content class="md-padding">
<h1 class="md-display-2">Issues</h1>
<p>Issues...</p>
</md-content>
</md-tab>
<md-tab label="Bugs">
<md-content class="md-padding">
<h1 class="md-display-2">Bugs</h1>
<p> Bugs Bugs Bugs..</p>
</md-content>
</md-tab>
<md-tab label="WhatEver">
<md-content class="md-padding">
<h1 class="md-display-2">WhatEver</h1>
<p>Bla Bla Bla..</p>
</md-content>
</md-tab>
</md-tabs>
</md-content>
</md-card>
</div>
</div>
</md-content>
</div>