From 42a5e8b108044bc95aa41cff349f077aedcb2d7b Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 29 Jun 2015 19:20:56 +0300 Subject: [PATCH] - 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