From 42a5e8b108044bc95aa41cff349f077aedcb2d7b Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 29 Jun 2015 19:20:56 +0300 Subject: [PATCH 1/4] - myProjects (work in progress) --- templates/js/app.js | 10 +- .../js/controllers/myClassesController.js | 2 +- .../js/controllers/myProjectsController.js | 32 +++-- .../js/controllers/projectsController.js | 124 ------------------ templates/views/index.html | 3 +- templates/views/myProjects.html | 21 +-- templates/views/projects.html | 75 ----------- 7 files changed, 42 insertions(+), 225 deletions(-) delete mode 100644 templates/js/controllers/projectsController.js delete mode 100644 templates/views/projects.html diff --git a/templates/js/app.js b/templates/js/app.js index af0d3eb..7fcca2e 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -54,9 +54,9 @@ app.config(['$routeProvider', '$locationProvider', templateUrl: 'templates/views/newTask.html', controller: 'newTasksController' }) - .when('/projects/:classId', { - templateUrl: 'templates/views/projects.html', - controller: 'projectsController' + .when('/class/:projectId', { + templateUrl: 'templates/views/class.html', + controller: 'classController' }) .when('/newCourse', { templateUrl: 'templates/views/newCourse.html', @@ -66,6 +66,10 @@ app.config(['$routeProvider', '$locationProvider', templateUrl: 'templates/views/campuses.html', controller: 'campusesController' }) + .when('/project/:projectId', { + templateUrl: 'templates/views/project.html', + controller: 'projectController' + }) .when('/myProjects', { templateUrl: 'templates/views/myProjects.html', controller: 'myProjectsController' diff --git a/templates/js/controllers/myClassesController.js b/templates/js/controllers/myClassesController.js index 6fc4029..627631f 100644 --- a/templates/js/controllers/myClassesController.js +++ b/templates/js/controllers/myClassesController.js @@ -18,7 +18,7 @@ angular.module('SeHub') $scope.goToClass = function(classId) { console.log("Done! " + $scope.courses); - $location.path('/projects/' + classId.toString()); // Will display all the projects in this course + $location.path('/class/' + classId.toString()); // Will display all the projects in this course } $scope.chooseCampusClicked = function() diff --git a/templates/js/controllers/myProjectsController.js b/templates/js/controllers/myProjectsController.js index 994bf4f..f6cc3e0 100644 --- a/templates/js/controllers/myProjectsController.js +++ b/templates/js/controllers/myProjectsController.js @@ -2,31 +2,39 @@ angular.module('SeHub') .controller('myProjectsController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { $scope.isEditPressed = false; - $scope.myProjectsEmpty = false; - var token = $cookies['com.sehub.www']; - + $scope.loadingDate = true; + $scope.myProjectsEmpty = true; $scope.user = $scope.$parent.user; + var token = $cookies['com.sehub.www']; + console.log(token); $scope.displayMyProjects = function() { apiService.getProjectsByUser(token).success(function(data) { - console.log("Success " + data); + $scope.loadingDate = false; $scope.myProjects = data; + if($scope.myProjects != null && $scope.myProjects.length > 0) + { + $scope.myProjectsEmpty = false; + } }).error(function(err) { - console.log("Error: " + err); + console.log("Error: " + err.message); }); - if($scope.myProjects === null) - { - $scope.myProjectsEmpty = true; - } + } - $scope.goToMyProject = function() + $scope.goToProject = function(projectId) { - console.log("projects only from classID: " + classId) - $location.path('/thisProject' + classId); + for (var i = 0; i < $scope.myProjects; i++) + { + if($scope.myProjects.id === projectId) + { + console.log("project ID: " + projectId) + $location.path('/project/' + projectId); + } + }; } var init = function() diff --git a/templates/js/controllers/projectsController.js b/templates/js/controllers/projectsController.js deleted file mode 100644 index ca55cdc..0000000 --- a/templates/js/controllers/projectsController.js +++ /dev/null @@ -1,124 +0,0 @@ -angular.module('SeHub') -.controller('projectsController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) -{ - var token = $cookies['com.sehub.www']; - var classId = $routeParams.classId; - $scope.projectsEmpty = true; - $scope.isCreateProjectClicked = false; - $scope.submitNewCourseClicked = false; - $scope.project = {}; - $scope.loadingData = true; - $scope.isInCourse = false; - - $scope.displayProjects = function() - { - console.log("in displayProjecs!!! "); - apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses - { - $scope.loadingData = false; - $scope.projects = data; - if($scope.projects != null && $scope.projects.length > 0) - { - $scope.projectsEmpty = false; - } - init(); // Executing the function to initialize projects display - console.log("project created! not rly!! " + classId); - }).error(function(err) - { - console.log("Error: " + err); - }); - - } - $scope.joinCourse = function() - { - apiService.joinCourse(token, classId).success(function(data) - { - $scope.isInCourse = true; - $mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.') - .ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent()) - .then(function() { - $location.path('/projects/' + classId); // TODO TODO TODO - }); // Pop-up alert - }).error(function(err) - { - $mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.') - .ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert - // .then(function() { - // // $location.path('/newCourse'); // TODO TODO TODO - // }); - }); - } - - $scope.createProjectClicked = function() - { - // console.log("project created! is it ?!???! " + classId); - $scope.isCreateProjectClicked = !$scope.isCreateProjectClicked; - } - - $scope.submitNewProject = function() - { - // debugger; - var intClassId = parseInt(classId); - // console.log($scope); - var jsonNewProj = - { - 'projectName': $scope.project.projectName, - 'courseId': intClassId, - 'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName - }; - console.log(jsonNewProj); - - if($scope.project.logoUrl) - jsonNewProj.logo_url = $scope.project.logoUrl; - - - apiService.create(token, jsonNewProj).success(function(data) - { - $mdDialog.show($mdDialog.alert().title('Project Created').content('You have successfully created project.') - .ariaLabel('Project created alert dialog').ok('Great!').targetEvent()); - // .then(function() { - // $location.path('/projects/' + classId); // TODO TODO TODO - // }); // Pop-up alert - - }).error(function(err) - { - console.log("Error: " + err.message); - $mdDialog.show($mdDialog.alert().title('Error Creating Project').content('You have failed Creating the project.') - .ariaLabel('Create project alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert - }); - - } - - $scope.goToProject = function() - { - console.log("projects only from classID: " + classId) - $location.path('/thisProject' + classId); - } - - var init = function() - { - $scope.arrayHolder = []; - var tempArr = []; - var sizeOfSmallArrays = 3; - for (var i = 0 ; i < $scope.projects.length ; i++) { - if(i % sizeOfSmallArrays !== 0){ - tempArr.push($scope.projects[i]); - }else{ - if(i !== 0){ - $scope.arrayHolder.push(tempArr); - tempArr = []; - tempArr.push($scope.projects[i]); - }else{ - tempArr.push($scope.projects[i]); - } - } - }; - $scope.arrayHolder.push(tempArr); - } - - - // Running... - $scope.displayProjects(); // Displaying all projects related to user - - -}]); \ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index 56f7232..0196f52 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -114,10 +114,11 @@ - + + \ No newline at end of file diff --git a/templates/views/myProjects.html b/templates/views/myProjects.html index 806c69c..a3ea717 100644 --- a/templates/views/myProjects.html +++ b/templates/views/myProjects.html @@ -1,12 +1,18 @@
- -

{{user.name}}'s projects

+

{{user.name}}'s projects

+
+ +
+
+ You Are Not Related To Any Project. +
+
- +

{{project.id}}

@@ -15,7 +21,7 @@
- +

{{project.id}}

@@ -30,7 +36,8 @@
- + +
- - -
-
diff --git a/templates/views/projects.html b/templates/views/projects.html deleted file mode 100644 index 9faa6b1..0000000 --- a/templates/views/projects.html +++ /dev/null @@ -1,75 +0,0 @@ -
-

Class {{project.title}}

-
- -
-
- You Are Not Related To Any Project. -
-
- -
-
- - {{project.projectName}} - - -
-
-
-
-
-
- Join Course -
- - Create Project - -
- -
-
- - - - -
-
-
- - - - -
- -
- - - - -
-
-
- - Example: http://www.github.com/userName/repoName -
userName will be GitHub Repository Owner -
repoName wil be GitHub Repository Name - -
-
- - - - -
-
- Submit Project -
-
-
-
- -
\ No newline at end of file From 61d40b4b25609c64142eeaf9b34512bc1c9f4f27 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 29 Jun 2015 19:22:52 +0300 Subject: [PATCH 2/4] -Class added -project Added --- templates/views/class.html | 78 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 templates/views/class.html diff --git a/templates/views/class.html b/templates/views/class.html new file mode 100644 index 0000000..4a12650 --- /dev/null +++ b/templates/views/class.html @@ -0,0 +1,78 @@ +
+

Class {{project.courseName}}

+
+ +
+
+ You Are Not Related To Any Project. +
+
+ +
+
+ + {{project.projectName}} + + +
+
+
+
+
+
+ Join Class +
+ + Create Project + +
+ +
+
+ + + + +
+
+
+ + + + +
+ +
+ + + + +
+
+
+ + Example: http://www.github.com/userName/repoName +
userName will be GitHub Repository Owner +
repoName wil be GitHub Repository Name + +
+
+ + + + +
+
+ Submit Project +
+ +
+
+
+
+
+ + \ No newline at end of file From 252f4440c6fca4ba4f9c13fcd0a94caec503cd60 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 29 Jun 2015 19:23:14 +0300 Subject: [PATCH 3/4] -Class added -project Added --- templates/js/controllers/classController.js | 129 ++++++++++++++++++ templates/js/controllers/projectController.js | 7 + templates/views/project.html | 15 ++ 3 files changed, 151 insertions(+) create mode 100644 templates/js/controllers/classController.js create mode 100644 templates/js/controllers/projectController.js create mode 100644 templates/views/project.html diff --git a/templates/js/controllers/classController.js b/templates/js/controllers/classController.js new file mode 100644 index 0000000..ce54da4 --- /dev/null +++ b/templates/js/controllers/classController.js @@ -0,0 +1,129 @@ +angular.module('SeHub') +.controller('classController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) +{ + var token = $cookies['com.sehub.www']; + var classId = $routeParams.projectId; + // var projectId = ""; + $scope.projectsEmpty = true; + $scope.isCreateProjectClicked = false; + $scope.submitNewCourseClicked = false; + $scope.project = {}; + $scope.loadingData = true; + $scope.isInCourse = false; + $scope.project.courseName = classId; + + $scope.displayProjects = function() + { + console.log("in displayProjecs!!! "); + apiService.getProjectsByCourse(token, classId).success(function(data) // Get all the campuses + { + $scope.loadingData = false; + $scope.projects = data; + if($scope.projects != null && $scope.projects.length > 0) + { + $scope.projectsEmpty = false; + } + init(); // Executing the function to initialize projects display + console.log("project created! not rly!! " + classId); + }).error(function(err) + { + console.log("Error: " + err); + }); + + } + $scope.joinCourse = function() + { + apiService.joinCourse(token, classId).success(function(data) + { + $scope.isInCourse = true; + $mdDialog.show($mdDialog.alert().title('Joined Course').content('You have successfully joined course.') + .ariaLabel('Join course alert dialog').ok('Lets Start!').targetEvent()) + .then(function() { + $location.path('/class/' + classId); // TODO TODO TODO + }); // Pop-up alert + }).error(function(err) + { + $mdDialog.show($mdDialog.alert().title('Error Joining Course').content(err.message + '.') + .ariaLabel('Join course alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert + // .then(function() { + // // $location.path('/newCourse'); // TODO TODO TODO + // }); + }); + } + + $scope.createProjectClicked = function() + { + // console.log("project created! is it ?!???! " + classId); + $scope.isCreateProjectClicked = !$scope.isCreateProjectClicked; + } + + $scope.submitNewProject = function() + { + loadingData = true; + // debugger; + var intClassId = parseInt(classId); + // console.log($scope); + var jsonNewProj = + { + 'projectName': $scope.project.projectName, + 'courseId': intClassId, + 'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName + }; + console.log(jsonNewProj); + + if($scope.project.logoUrl) + jsonNewProj.logo_url = $scope.project.logoUrl; + + + apiService.create(token, jsonNewProj).success(function(data) + { + loadingData = false; + projectId = data.id; + $mdDialog.show($mdDialog.alert().title('Project Created').content('You have successfully created project.') + .ariaLabel('Project created alert dialog').ok('Great!').targetEvent()) + .then(function() { + $location.path('/project/' + projectId); // TODO TODO TODO + }); // Pop-up alert + + }).error(function(err) + { + console.log("Error: " + err.message); + $mdDialog.show($mdDialog.alert().title('Error Creating Project').content('You have failed Creating the project.') + .ariaLabel('Create project alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert + }); + + } + + $scope.goToProject = function(projectId) + { + console.log("projects only from classID: " + projectId) + $location.path('/project/' + projectId); + } + + var init = function() + { + $scope.arrayHolder = []; + var tempArr = []; + var sizeOfSmallArrays = 3; + for (var i = 0 ; i < $scope.projects.length ; i++) { + if(i % sizeOfSmallArrays !== 0){ + tempArr.push($scope.projects[i]); + }else{ + if(i !== 0){ + $scope.arrayHolder.push(tempArr); + tempArr = []; + tempArr.push($scope.projects[i]); + }else{ + tempArr.push($scope.projects[i]); + } + } + }; + $scope.arrayHolder.push(tempArr); + } + + + // Running... + $scope.displayProjects(); // Displaying all projects related to user + + +}]); \ No newline at end of file diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js new file mode 100644 index 0000000..6db2fa2 --- /dev/null +++ b/templates/js/controllers/projectController.js @@ -0,0 +1,7 @@ +angular.module('SeHub') +.controller('projectController', ['$scope', '$routeParams', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', + function ($scope, $routeParams, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) +{ + + +}]); \ No newline at end of file diff --git a/templates/views/project.html b/templates/views/project.html new file mode 100644 index 0000000..8d4eba2 --- /dev/null +++ b/templates/views/project.html @@ -0,0 +1,15 @@ +
+ +

Project

+ Yipi Kayea Mother Fraker +
+ +
+ + + + + + +
+
\ No newline at end of file From e19f4fd03a65458430dd7dc8233e134fe4d6e572 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 29 Jun 2015 20:04:33 +0300 Subject: [PATCH 4/4] -Graphs - fixed --- templates/js/controllers/classController.js | 1 - .../js/controllers/myProjectsController.js | 15 +++--- templates/views/class.html | 21 ++++++-- templates/views/myProjects.html | 48 +++++++++---------- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/templates/js/controllers/classController.js b/templates/js/controllers/classController.js index ce54da4..e7e13ae 100644 --- a/templates/js/controllers/classController.js +++ b/templates/js/controllers/classController.js @@ -29,7 +29,6 @@ angular.module('SeHub') { console.log("Error: " + err); }); - } $scope.joinCourse = function() { diff --git a/templates/js/controllers/myProjectsController.js b/templates/js/controllers/myProjectsController.js index f6cc3e0..c55bf1d 100644 --- a/templates/js/controllers/myProjectsController.js +++ b/templates/js/controllers/myProjectsController.js @@ -2,7 +2,7 @@ angular.module('SeHub') .controller('myProjectsController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { $scope.isEditPressed = false; - $scope.loadingDate = true; + $scope.loadingData = true; $scope.myProjectsEmpty = true; $scope.user = $scope.$parent.user; var token = $cookies['com.sehub.www']; @@ -12,12 +12,15 @@ angular.module('SeHub') { apiService.getProjectsByUser(token).success(function(data) { - $scope.loadingDate = false; + $scope.loadingData = false; $scope.myProjects = data; if($scope.myProjects != null && $scope.myProjects.length > 0) { $scope.myProjectsEmpty = false; } + init(); // Executing the function to initialize my projects display + console.log(data); + console.log("Success"); }).error(function(err) { console.log("Error: " + err.message); @@ -42,16 +45,16 @@ angular.module('SeHub') $scope.arrayHolder = []; var tempArr = []; var sizeOfSmallArrays = 3; - for (var i = 0 ; i < $scope.projects.length ; i++) { + for (var i = 0 ; i < $scope.myProjects.length ; i++) { if(i % sizeOfSmallArrays !== 0){ - tempArr.push($scope.projects[i]); + tempArr.push($scope.myProjects[i]); }else{ if(i !== 0){ $scope.arrayHolder.push(tempArr); tempArr = []; - tempArr.push($scope.projects[i]); + tempArr.push($scope.myProjects[i]); }else{ - tempArr.push($scope.projects[i]); + tempArr.push($scope.myProjects[i]); } } }; diff --git a/templates/views/class.html b/templates/views/class.html index 4a12650..c61c87f 100644 --- a/templates/views/class.html +++ b/templates/views/class.html @@ -10,11 +10,22 @@
- - {{project.projectName}} - - +
+ + {{project.projectName}} +
+ +
+ +
+
+ + {{project.projectName}} + + + + +
diff --git a/templates/views/myProjects.html b/templates/views/myProjects.html index a3ea717..cb8af1f 100644 --- a/templates/views/myProjects.html +++ b/templates/views/myProjects.html @@ -6,34 +6,34 @@
You Are Not Related To Any Project.
-
+
-
+
-
-
- - - -

{{project.id}}

-
-
-
-
-
- - - -

{{project.id}}

-
-
-
-
+
+ + + +

{{project.projectName}}

+
+ +
+
+
+
+
+
+ + + +

{{project.projectName}}

+ +
+
+
-
- You Do Not Have Any Project, You May Create One. -