From 380228947bf9504fbef39e44099fd25422715536 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sat, 27 Jun 2015 12:45:44 +0300 Subject: [PATCH] -Bugs fixing - Create class bug - fixed - Work in progress (classes, projects) - need to check API --- .../js/controllers/campusesController.js | 52 ++++--- templates/js/controllers/homeController.js | 23 ++- templates/js/controllers/mainController.js | 2 +- .../js/controllers/myClassesController.js | 127 +++++++++-------- .../js/controllers/newCourseController.js | 2 - .../js/controllers/projectsController.js | 133 +++++++++++++----- templates/js/controllers/tasksController.js | 1 - templates/js/services/apiService.js | 18 ++- templates/views/campuses.html | 21 ++- templates/views/home.html | 62 -------- templates/views/myClasses.html | 68 +++++---- templates/views/projects.html | 7 +- templates/views/tasks.html | 78 +++++----- templates/views/thisProject.html | 35 ++++- 14 files changed, 365 insertions(+), 264 deletions(-) diff --git a/templates/js/controllers/campusesController.js b/templates/js/controllers/campusesController.js index 5f782d6..18a79dd 100644 --- a/templates/js/controllers/campusesController.js +++ b/templates/js/controllers/campusesController.js @@ -2,6 +2,7 @@ angular.module('SeHub') .controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) { $scope.threeSizedArray =[]; + $scope.campusesEmpty = false; var token = $cookies['com.sehub.www']; apiService.getCampusesByUser(token).success(function(data) // Get all the campuses @@ -21,32 +22,39 @@ angular.module('SeHub') var i, j, counter = 0; var newLength = 0; - if(($scope.campuses.length % 3) === 0) + if($scope.campuses != null) { - newLength = ($scope.campuses.length / 3); + 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]; + } + } + } } 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]; - } - } + $scope.campusesEmpty = true; } console.log($scope.threeSizedArray); // TODO REMOVE } diff --git a/templates/js/controllers/homeController.js b/templates/js/controllers/homeController.js index 4dd0251..5dc7f83 100644 --- a/templates/js/controllers/homeController.js +++ b/templates/js/controllers/homeController.js @@ -13,7 +13,6 @@ angular.module('SeHub') var imagePath = $scope.user.avatar_url; //var campusName = ''; - $scope.course = ''; // $scope.campusName = ''; $scope.phones = [ @@ -51,8 +50,30 @@ angular.module('SeHub') } $scope.postMessageClicked = function() // Posting the message itself { + + if($scope.msg.msgToAdd != null) { + jsonNewMsg = { + 'courseName': 'A', // TODO Should be ===> $scope.course.courseName + 'message': $scope.msg.msgToAdd + }; + + // console.log("J: " + jsonNewMsg.toString() + "msg: " + $scope.msg.msgToAdd); + + // apiService.createMessage(token, jsonNewMsg).success(function(data) + // { + // console.log("create Msg!"); + // }).error(function(err) + // { + // console.log("Error: " + err); + // }); + + /* + 'courseName': 'Advance Math', + 'message': 'The lecture today is canceled' + */ + console.log($scope.msg.msgToAdd); $scope.messages.push({"text": $scope.msg.msgToAdd}); } diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index b9ac448..964b4ec 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -31,7 +31,7 @@ angular.module('SeHub') "title": "Projects", "icon": "fa fa-cube", "style": "", - "route": "/myClasses" + "route": "/projects" }, { "title": "Tasks", "icon": "fa fa-clipboard", diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index d301be6..4d5836d 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -1,5 +1,5 @@ angular.module('SeHub') -.controller('myClassesController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) +.controller('myClassesController', ['$scope', '$location', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $location, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { $scope.isStudent = false; $scope.isCourse = false; @@ -10,28 +10,21 @@ angular.module('SeHub') $scope.user.finalDate = ''; $scope.user.startDate = ''; $scope.showMyClass = false; + $scope.coursesEmpty = false; var campusId = $routeParams.campusId; - if($scope.user.isLecturer) + var displayCourses = function() { - $scope.isStudent = false; - console.log("Lecturer Mode!"); + apiService.getCoursesByUser(token, campusId).success(function(data) // Get all the courses for display + { + $scope.courses = data; + console.log("success " + $scope.courses); + init(); // Executing the function to initialize course display + }).error(function(err) + { + console.log("error: " + err); + }); } - else - { - $scope.isStudent = true; - console.log("Student Mode!"); - } - - apiService.getCoursesByUser(token, campusId).success(function(data) // Get all the courses for display - { - $scope.courses = data; - console.log("success " + $scope.courses); - init(); // Executing the function to initialize course display - }).error(function(err) - { - console.log("error: " + err); - }); $scope.goToClass = function(classId) { @@ -52,8 +45,6 @@ angular.module('SeHub') { console.log("Error: " + err); }); - - } $scope.createCourseClicked = function() @@ -63,7 +54,7 @@ angular.module('SeHub') $scope.submitNewClassClicked = function() { - if($scope.course.courseName != '' && $scope.course.endDate != '' && $scope.course.startDate != '') + if($scope.course.courseName != null && $scope.course.endDate != null && $scope.course.startDate != null) { var jsonNewCourse = { @@ -71,38 +62,35 @@ angular.module('SeHub') 'campusName': $scope.course.campusName, 'startDate': { 'year' : $scope.course.startDate.getFullYear(), - 'day' : $scope.course.startDate.getDate(), - 'month': ($scope.course.startDate.getMonth() + 1) + '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) + 'day' : $scope.course.endDate.getDate(), + 'month': $scope.course.endDate.getMonth() + 1 } }; - // $scope.globalVar = jsonNewCourse; - - console.log("Json here:"); + console.log("Json here: " + $scope.chosenCampus); console.log(jsonNewCourse); apiService.createCourse(token, jsonNewCourse).success(function(data) { console.log("createCourse API done"); - }).error(function(err) - { - console.log(err); - }); - $mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.') + $mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.') .ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent()) .then(function() { $window.location.href = 'templates/views/newCourse.html'; // TODO TODO TODO }); // Pop-up alert - + }).error(function(err) + { + console.log(err); + }); } else { - $mdDialog.show($mdDialog.alert().title('Error - Creating Course').content('You have encountered and error in creating the course.') + $mdDialog.show($mdDialog.alert().title('Error - Creating Course').content('Some fields are missing.') .ariaLabel('Email verification alert dialog').ok('Try Again!').targetEvent()); } } @@ -112,36 +100,57 @@ angular.module('SeHub') var i, j, counter = 0; var newLength = 0; - if(($scope.courses.length % 3) === 0) + if($scope.courses != null) { - newLength = ($scope.courses.length / 3); + 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]; + } + } + } } else { - newLength = (Math.ceil($scope.courses.length / 3)); // Rounds number up + $scope.coursesEmpty = true; } - - 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); + console.log($scope.holdArrays); } + 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!! + + }]); \ No newline at end of file diff --git a/templates/js/controllers/newCourseController.js b/templates/js/controllers/newCourseController.js index f66f396..3eccaea 100644 --- a/templates/js/controllers/newCourseController.js +++ b/templates/js/controllers/newCourseController.js @@ -1,10 +1,8 @@ angular.module('SeHub') .controller('newCourseController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { - $scope.goBack = function() { $window.location.href = 'templates/views/myClasses.html'; } - }]); \ No newline at end of file diff --git a/templates/js/controllers/projectsController.js b/templates/js/controllers/projectsController.js index 0a68d3b..a83fd6b 100644 --- a/templates/js/controllers/projectsController.js +++ b/templates/js/controllers/projectsController.js @@ -1,60 +1,121 @@ angular.module('SeHub') -.controller('projectsController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $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) { - console.log("in projects controller"); + var token = $cookies['com.sehub.www']; + var classId = $routeParams.id; + $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); + }); + } + + + + $scope.displayProjects(); // Displaying all projects related to user $scope.createProjectClicked = function() { - console.log("project created! not rly!! "); + console.log("project created! not rly!! " + classId); // $window.location.href = 'http://localhost:8080/home#/tasks/new'; // Reference to 'newTask' page - } - $scope.projects = ['AMI', 'LULU', 'XIN Zhau', 'LUMI lu', 'Shimi', 'Azligi zligi', 'Drugs']; + // $scope.projects = ['AMI', 'LULU', 'XIN Zhau', 'LUMI lu', 'Shimi', 'Azligi zligi', 'Drugs']; - // apiService.getProjectsByCourse(courseId).success(function(data) // Get all the campuses - // { - // $scope.projects = data; - // }).error(function() { - // // TODO - // }); + $scope.goToProject = function() + { + console.log("projects only from classID: " + classId) + $location.path('/thisProject' + classId); + } var init = function() { var i, j, counter = 0; var newLength = 0; - - if(($scope.projects.length % 3) === 0) + + if($scope.projects != null) { - newLength = ($scope.projects.length / 3); + if(($scope.projects.length % 3) === 0) + { + newLength = ($scope.projects.length / 3); + } + else + { + newLength = (Math.ceil($scope.projects.length / 3)); // Rounds number up + } + + console.log("length: " + newLength); + $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); } else { - newLength = (Math.ceil($scope.projects.length / 3)); // Rounds number up + $scope.projectEmpty = true; } - - console.log("length: " + newLength); - $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); } - init(); // Executing the function to initialize projects display + + + + /* + var jsonNewCourse = + { + 'courseName': $scope.course.courseName, + 'campusName': $scope.course.campusName, + '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 + } + };*/ + + /* + { + '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 + } + */ + + + + }]); \ No newline at end of file diff --git a/templates/js/controllers/tasksController.js b/templates/js/controllers/tasksController.js index 705ddb2..33196f4 100644 --- a/templates/js/controllers/tasksController.js +++ b/templates/js/controllers/tasksController.js @@ -8,7 +8,6 @@ angular.module('SeHub') var taskName = name; console.log("task created! " + taskName); $location.path("/tasks/new"); // Reference to 'newTask' page - } diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 9826c64..5c636aa 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -95,7 +95,6 @@ service.factory('apiService', ['$http', function($http) { method : "POST", url : url, data: payLoad - }; return $http(req); }, @@ -142,6 +141,23 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); + }, + joinCourse: function(token, courseId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserById/" + token + "/" + courseId; + req = { + method : "PUT", + url : url + }; + return $http(req); + }, + createMessage: function(token, payLoad){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/create/" + token; + req = { + method : "POST", + url : url, + data: payLoad + }; + return $http(req); } }; }]); \ No newline at end of file diff --git a/templates/views/campuses.html b/templates/views/campuses.html index d4e2523..66d3654 100644 --- a/templates/views/campuses.html +++ b/templates/views/campuses.html @@ -2,14 +2,21 @@

Pick A Campus

- -
-
- - - {{campus.title}} - + +
+
+
+ + + {{campus.title}} + +
+
> + + You Are Not Related To Any Course, You Can Join A Course By Press 'Join'. + +
\ No newline at end of file diff --git a/templates/views/home.html b/templates/views/home.html index dcce1b2..bec06f6 100644 --- a/templates/views/home.html +++ b/templates/views/home.html @@ -112,68 +112,6 @@
- - -

- Project Evaluation -

- - -
-
- - - Press On Me - - - - - Press On Me - - - - - - Press On Me - - -
-
- - - Press On Me - - - - - Press On Me - - - - - Press On Me - - -
-
- - - Press On Me - - - - - Press On Me - - - - - Press On Me - - -
-
-
diff --git a/templates/views/myClasses.html b/templates/views/myClasses.html index e7ae43d..637e792 100644 --- a/templates/views/myClasses.html +++ b/templates/views/myClasses.html @@ -5,15 +5,19 @@
- +
+ aaa {{course.id}} - +
+
+ You Are Not Related To Any Course, You May Join Any Course You Wish. +
- +
@@ -21,38 +25,32 @@
- - - -
-
- - - - - - - - - -
-
- - - - - - - - - - - - -
-
-
-
+ + +
+ + + + {{c.title}} + + +
+
+ + + + + + + + + + + + +
+
+
Submit New Class
diff --git a/templates/views/projects.html b/templates/views/projects.html index 7cb6349..dd163fd 100644 --- a/templates/views/projects.html +++ b/templates/views/projects.html @@ -3,11 +3,14 @@
- +
{{project.id}} - +
+
+
+ You Are Not Related To Any Course, You May Join Any Course You Wish.
diff --git a/templates/views/tasks.html b/templates/views/tasks.html index 02df80d..d38e8b4 100644 --- a/templates/views/tasks.html +++ b/templates/views/tasks.html @@ -3,40 +3,50 @@

Tasks

Create Task -
- -
- - - - - -

Commits

-

Commits...

-
-
- - -

Issues

-

Issues...

-
-
- - -

Bugs

-

Bugs Bugs Bugs..

-
-
- - -

WhatEver

-

Bla Bla Bla..

-
-
-
-
- -
+ +
+ + + + + +

Submitted

+

Submitted...

+
+
+ + +

Delayed

+

Delayed...

+
+
+ + +

Not Submitted

+

Not Submitted ..

+
+
+ + +

WhatEver

+

Bla Bla Bla..

+
+
+
+
+
+
+ +
+
+ + + {{project.title}} + +
+
+ +
\ No newline at end of file diff --git a/templates/views/thisProject.html b/templates/views/thisProject.html index 7d3292f..c42991f 100644 --- a/templates/views/thisProject.html +++ b/templates/views/thisProject.html @@ -13,7 +13,8 @@ Edit
- + Remove +
@@ -31,6 +32,38 @@
+
+ + + + + +

Commits

+

Commits...

+
+
+ + +

Issues

+

Issues...

+
+
+ + +

Bugs

+

Bugs Bugs Bugs..

+
+
+ + +

WhatEver

+

Bla Bla Bla..

+
+
+
+
+
+
\ No newline at end of file