From 18ca8df227acbb9619a14958d1025274c95d62b9 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Fri, 26 Jun 2015 21:56:41 +0300 Subject: [PATCH] - campuses fixed - Work in progress (classes, projects) --- templates/css/theme.css | 32 +++++++++ .../js/controllers/campusesController.js | 26 +++---- .../js/controllers/myClassesController.js | 71 +++++++------------ templates/js/services/apiService.js | 8 +-- templates/views/campuses.html | 11 ++- templates/views/myClasses.html | 24 +++---- templates/views/projects.html | 8 +-- 7 files changed, 93 insertions(+), 87 deletions(-) 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/controllers/campusesController.js b/templates/js/controllers/campusesController.js index f7a1033..5f782d6 100644 --- a/templates/js/controllers/campusesController.js +++ b/templates/js/controllers/campusesController.js @@ -3,17 +3,16 @@ angular.module('SeHub') { $scope.threeSizedArray =[]; var token = $cookies['com.sehub.www']; - - $scope.campuses = ['Bezalel', 'Ben Gurion', 'Sami Shamoon', 'Afeka', 'Ivrit', 'Kaka', 'Opium']; // TODO REMOVE - - // apiService.getCampusesByUser().success(function(data) // Get all the campuses - // { - // console.log("INSIDE"); - // $scope.campuses = data; - // }).error(function() { - // // TODO - // }); + 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); @@ -49,10 +48,13 @@ angular.module('SeHub') } } } - console.log($scope.threeSizedArray); + console.log($scope.threeSizedArray); // TODO REMOVE } - init(); // Executing the function to initialize campuses show + $scope.goToCampus = function(campusId) // Will pass you to courses by specific campus + { + $location.path('/myClasses/' + campusId.toString()); + } diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index 9e68070..d301be6 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -1,16 +1,16 @@ 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', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { $scope.isStudent = false; $scope.isCourse = false; $scope.isNewCourse = false; $scope.newClassName = false; $scope.course = {}; - // $scope.globalVar = ''; var token = $cookies['com.sehub.www']; $scope.user.finalDate = ''; $scope.user.startDate = ''; $scope.showMyClass = false; + var campusId = $routeParams.campusId; if($scope.user.isLecturer) { @@ -23,58 +23,37 @@ angular.module('SeHub') console.log("Student Mode!"); } - - $scope.courses = ['SE', 'PC', 'Math', 'Calculus', 'Ivrit', 'English', 'Drugs']; - console.log($scope.courses); - - // apiService.getClassesByUser().success(function(data) // Get all the courses - // { - // $scope.courses = data; - // }).error(function() { - // // TODO - // }); - - var init = function() + apiService.getCoursesByUser(token, campusId).success(function(data) // Get all the courses for display { - 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 - } + $scope.courses = data; + console.log("success " + $scope.courses); + init(); // Executing the function to initialize course display + }).error(function(err) + { + console.log("error: " + err); + }); - $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); + $scope.goToClass = function(classId) + { + console.log("Done! " + $scope.courses); + $location.path('/projects/' + classId.toString()); // Will display all the projects in this course } - init(); // Executing the function to initialize course display - - $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() diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 56a40c0..9826c64 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -108,8 +108,8 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, - getClassesByUser: function(){ // Need to add campusName (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,8 +117,8 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, - getProjectsByCourse: function(){ // Need to add courseID (ngRoute) ~ sagi //TODO - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getProjectByCourse/" + token; + 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 diff --git a/templates/views/campuses.html b/templates/views/campuses.html index efc9846..d4e2523 100644 --- a/templates/views/campuses.html +++ b/templates/views/campuses.html @@ -1,15 +1,14 @@
-

My Campuses

+

Pick A Campus

- - - {{campus}} - - + + + {{campus.title}} +
diff --git a/templates/views/myClasses.html b/templates/views/myClasses.html index f0de7b5..e7ae43d 100644 --- a/templates/views/myClasses.html +++ b/templates/views/myClasses.html @@ -5,26 +5,15 @@ - - -
@@ -40,6 +29,11 @@ + + + + +
diff --git a/templates/views/projects.html b/templates/views/projects.html index 5391903..7cb6349 100644 --- a/templates/views/projects.html +++ b/templates/views/projects.html @@ -3,11 +3,11 @@