diff --git a/templates/css/theme.css b/templates/css/theme.css index b697697..ea3f3fe 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -151,6 +151,38 @@ body.noscroll /*width: 100%;*/ } +/*.hvr-curl-top-left { + display: inline-block; + vertical-align: middle; + -webkit-transform: translateZ(0); + transform: translateZ(0); + box-shadow: 0 0 1px rgba(0, 0, 0, 0); + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -moz-osx-font-smoothing: grayscale; + position: relative; +}*/ + +/* Grow Rotate */ +/*.campusCard { + display: inline-block; + vertical-align: middle; + -webkit-transform: translateZ(0); + transform: translateZ(0); + box-shadow: 0 0 1px rgba(0, 0, 0, 0); + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -moz-osx-font-smoothing: grayscale; + -webkit-transition-duration: 0.3s; + transition-duration: 0.3s; + -webkit-transition-property: transform; + transition-property: transform; +}*/ +.campusCard:hover, .campusCard:focus, .campusCard:active { + -webkit-transform: rotate(4deg); + transform: rotate(4deg); +} + /*.feedMessages { overflow: scroll; diff --git a/templates/js/app.js b/templates/js/app.js index bb9af14..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', { - 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 e1d796b..ead0ef2 100644 --- a/templates/js/controllers/campusesController.js +++ b/templates/js/controllers/campusesController.js @@ -1,17 +1,70 @@ angular.module('SeHub') -.controller('campusesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService, $rootScope) { +.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']; + + var init = function() + { + var i, j, counter = 0; + var newLength = 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]; + } + } + } + console.log($scope.threeSizedArray); // TODO REMOVE + } + + $scope.goToCampus = function(campusId) // Will pass you to courses by specific campus + { + $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 - - $scope.campuses = ['Bezalel', 'Ben Gurion', 'Sami Shamoon', 'Afeka', 'Ivrit', 'Kaka', 'Opium']; - console.log($scope.campuses); - - // apiService.getCampusesByUser(token).success(function(data) // Get all the campuses - // { - // $scope.campuses = data; - // }).error(function() { - // // TODO - // }); - -}]); \ No newline at end of file +}]); 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 d253908..9fd22a2 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": "/myClasses" + "route": "/myProjects" }, { "title": "Tasks", "icon": "fa fa-clipboard", diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index e4d69d6..ccabe30 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -1,5 +1,6 @@ angular.module('SeHub') -.controller('myClassesController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $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,7 +11,131 @@ angular.module('SeHub') $scope.user.finalDate = ''; $scope.user.startDate = ''; $scope.showMyClass = false; + $scope.coursesEmpty = false; + var campusId = $routeParams.campusId; + var displayCourses = function() + { + 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); + }); + if($scope.courses = null) + { + $scope.coursesEmpty = true; + } + } + + $scope.goToClass = function(classId) + { + console.log("Done! " + $scope.courses); + $location.path('/projects/' + classId.toString()); // Will display all the projects in this course + } + + $scope.chooseCourseClicked = function() + { + $scope.isCourse = true; + console.log("choose course Clicked!!"); + + apiService.getAllCampuses(token).success(function(data) + { + $scope.campuses = data; + console.log("Campuses: " + $scope.campuses.toString()); + }).error(function(err) + { + console.log("Error: " + err); + }); + } + + $scope.createCourseClicked = function() + { + $scope.isNewCourse = !$scope.isNewCourse; + } + + $scope.submitNewClassClicked = function() + { + if($scope.course.courseName != null && $scope.course.endDate != null && $scope.course.startDate != null) + { + 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 + } + }; + + console.log("Json here: " + $scope.chosenCampus); + console.log(jsonNewCourse); + + apiService.createCourse(token, jsonNewCourse).success(function(data) + { + console.log("createCourse API done"); + $mdDialog.show($mdDialog.alert().title('Course Created').content('You have created course successfully.') + .ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent()) + .then(function() { + $location.path('/newCourse'); // TODO TODO TODO + }); // Pop-up alert + }).error(function(err) + { + console.log(err); + }); + } + else + { + $mdDialog.show($mdDialog.alert().title('Error - Creating Course').content('Some fields are missing.') + .ariaLabel('Email verification alert dialog').ok('Try Again!').targetEvent()); + } + } + + var init = function() + { + var i, j, counter = 0; + var newLength = 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]; + } + } + } + console.log($scope.holdArrays); + } + + if($scope.user.isLecturer) { $scope.isStudent = false; @@ -22,72 +147,7 @@ angular.module('SeHub') console.log("Student Mode!"); } - - $scope.courses = ['SE', 'PC', 'Math', 'Calculus', 'Ivrit', 'English', 'Drugs']; - - - // apiService.getClassesByUser(token).success(function(data) // Get all the campuses - // { - // $scope.courses = data; - // }).error(function() { - // // TODO - // }); - - - $scope.chooseCourseClicked = function() - { - $scope.isCourse = true; - console.log("choose course Clicked!!"); - } - - $scope.createCourseClicked = function() - { - $scope.isNewCourse = !$scope.isNewCourse; - } - - $scope.submitNewClassClicked = function() - { - if($scope.course.courseName != '' && $scope.course.endDate != '' && $scope.course.startDate != '') - { - 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) - } - }; - - console.log("Json here:"); - 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.') - .ariaLabel('Email verification alert dialog').ok('Lets Start!').targetEvent()) - .then(function() { - $window.location.href = 'templates/views/newCourse.html'; // TODO TODO TODO - }); // Pop-up alert - - } - else - { - $mdDialog.show($mdDialog.alert().title('Error - Creating Course').content('You have encountered and error in creating the course.') - .ariaLabel('Email verification alert dialog').ok('Try Again!').targetEvent()); - } - } + displayCourses(); // Will display the courses that the user related to // TODO!! diff --git a/templates/js/controllers/newCourseController.js b/templates/js/controllers/newCourseController.js index f66f396..f330cdf 100644 --- a/templates/js/controllers/newCourseController.js +++ b/templates/js/controllers/newCourseController.js @@ -1,10 +1,9 @@ angular.module('SeHub') -.controller('newCourseController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) +.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'; + $location.path('/myClasses'); } - }]); \ No newline at end of file diff --git a/templates/js/controllers/projectsController.js b/templates/js/controllers/projectsController.js index 617a7a5..0bd6b99 100644 --- a/templates/js/controllers/projectsController.js +++ b/templates/js/controllers/projectsController.js @@ -1,23 +1,114 @@ 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); + }); + if($scope.projects = null) + { + $scope.projectEmpty = true; + } + } + + $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']; + + $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) + { + 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); + } + + + + + /* + 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 + } + */ + + + - // apiService.getProjectsByCourse(courseId).success(function(data) // Get all the campuses - // { - // $scope.projects = data; - // }).error(function() { - // // TODO - // }); }]); \ No newline at end of file diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 589c5fd..928bca6 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -90,7 +90,7 @@ angular.module('SeHub') }; $scope.createCampus = function(ev) { - $scope.createCampusClicked = true; + $scope.createCampusClicked = !$scope.createCampusClicked; if (!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing) { 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/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 9105c66..8d14f27 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -44,7 +44,7 @@ service.factory('apiService', ['$http', function($http) { return $http(req); }, getCourseByCampusName: function(token){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token; + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseByCampusName/" + token; req = { method : "GET", url : url @@ -95,7 +95,6 @@ service.factory('apiService', ['$http', function($http) { method : "POST", url : url, data: payLoad - }; return $http(req); }, @@ -108,8 +107,8 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, - getClassesByCourse: function(){ // Need to add camusName (ngRoute) ~ sagi //TODO - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/ClassesByCourse/" + token; + getCoursesByUser: function(token, campusId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + campusId; req = { method : "GET", url : url @@ -117,7 +116,16 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, - getProjectsByCourse: function(){ // Need to add courseID (ngRoute) ~ sagi //TODO + getProjectsByCourse: function(token, classId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token + "/" + classId; + req = { + method : "GET", + url : url + + }; + return $http(req); + }, + getProjectsByUser: function(token){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token; req = { method : "GET", @@ -126,6 +134,7 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, + getUserById: function(token, id){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserById/" + token + "/" + id; req = { @@ -142,7 +151,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 8d0ddf8..66d3654 100644 --- a/templates/views/campuses.html +++ b/templates/views/campuses.html @@ -1,16 +1,22 @@