From dbfaf909724f8796d40a26a7fdc9ac2bbd0dd3e7 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sat, 1 Aug 2015 17:51:13 +0300 Subject: [PATCH 1/3] - joinProject - added -team members - fixed --- templates/js/controllers/projectController.js | 22 +++++++++++++++++++ templates/js/services/apiService.js | 8 +++++++ templates/views/project.html | 5 +++++ 3 files changed, 35 insertions(+) diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js index d3c3ebd..f51f37b 100644 --- a/templates/js/controllers/projectController.js +++ b/templates/js/controllers/projectController.js @@ -8,10 +8,25 @@ angular.module('SeHub') $scope.user = $scope.$parent.user; $scope.loadingData = true; $scope.isMasterOrLecturer = false; + $scope.isMember = false; // $scope.thisProject = {}; // $scope.thisProject.courseName = $routeParams.className; + $scope.joinProject = function() + { + apiService.joinProject(token, projectId).success(function(data) + { + $scope.isMember = true; + $scope.project = data; + $mdDialog.show($mdDialog.alert().title('Join Project').content('Joined successfully.') + .ariaLabel('Join project alert dialog').ok('Aight').targetEvent(ev)); + }).error(function(err) + { + console.log("Error: " + err.message); + }); + } + $scope.editProject = function(ev) { $scope.isEditPressed = true; @@ -46,6 +61,13 @@ angular.module('SeHub') apiService.getProjectsById(token, projectId).success(function(data) { $scope.project = data; + for(var i = 0; i < data.members.length; i++) + { + if($scope.user.id === data.members[i].id) + { + $scope.isMember = true; + } + } // if($scope.user === $scope.project.info.master_id) // { // $scope.isMasterOrLecturer = true; diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index ee40112..77f14dc 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -181,6 +181,14 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, + joinProject: function(token, projectId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/joinProject/" + token + "/" + projectId; + req = { + method: "PUT", + url: url + }; + return $http(req); + }, getCourseById: function(token, id){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + token + "/" + id; req = { diff --git a/templates/views/project.html b/templates/views/project.html index b880935..ccc573b 100644 --- a/templates/views/project.html +++ b/templates/views/project.html @@ -18,6 +18,11 @@
+
+ + + +
From 9bede4b39960a3c9af53c087d8193a45bca32ab5 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sat, 1 Aug 2015 18:18:21 +0300 Subject: [PATCH 2/3] -loadingData - in progress --- templates/js/controllers/classController.js | 6 ++---- templates/js/controllers/projectController.js | 3 ++- templates/views/class.html | 4 ++-- templates/views/project.html | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/templates/js/controllers/classController.js b/templates/js/controllers/classController.js index 00c985f..2690cdc 100644 --- a/templates/js/controllers/classController.js +++ b/templates/js/controllers/classController.js @@ -8,6 +8,7 @@ angular.module('SeHub') $scope.isCreateProjectClicked = false; $scope.submitNewCourseClicked = false; $scope.loadingData = true; + $scope.creatingProject = false; $scope.isInCourse = false; var startDate = null; var endDate = null; @@ -71,7 +72,6 @@ angular.module('SeHub') } $scope.createProjectClicked = function() { - // console.log("project created! is it ?!???! " + classId); $scope.isCreateProjectClicked = !$scope.isCreateProjectClicked; if($scope.isCreateProjectClicked) $scope.createSctionStatus = "fa fa-angle-up"; @@ -80,10 +80,8 @@ angular.module('SeHub') } $scope.submitNewProject = function() { - loadingData = true; - // debugger; + $scope.creatingProject = true; var intClassId = parseInt(classId); - // console.log($scope); var jsonNewProj = { 'projectName': $scope.project.projectName, 'courseId': intClassId, diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js index f51f37b..7fe243c 100644 --- a/templates/js/controllers/projectController.js +++ b/templates/js/controllers/projectController.js @@ -23,7 +23,8 @@ angular.module('SeHub') .ariaLabel('Join project alert dialog').ok('Aight').targetEvent(ev)); }).error(function(err) { - console.log("Error: " + err.message); + $mdDialog.show($mdDialog.alert().title('Join Project').content(err.message) + .ariaLabel('Join project alert dialog').ok('Try Again').targetEvent(ev)); }); } diff --git a/templates/views/class.html b/templates/views/class.html index ef3fe11..7baffb0 100644 --- a/templates/views/class.html +++ b/templates/views/class.html @@ -71,8 +71,8 @@
- Submit Project -
+ Submit Project +
diff --git a/templates/views/project.html b/templates/views/project.html index dbf7ee4..01a9f8c 100644 --- a/templates/views/project.html +++ b/templates/views/project.html @@ -18,7 +18,7 @@
-
+
From dfd141229c4868b2fa10e3b5fcff8ddb9bf9b4f6 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 2 Aug 2015 12:55:43 +0300 Subject: [PATCH 3/3] -getAllfutureCampusTasks - fixed -messages in dashboard - fixed --- templates/js/controllers/classController.js | 6 +- templates/js/controllers/homeController.js | 63 +++++++----- .../js/controllers/newTasksController.js | 1 - templates/js/controllers/projectController.js | 20 ++-- templates/js/services/apiService.js | 40 ++++++++ templates/views/home.html | 98 ++++++++++++++----- 6 files changed, 169 insertions(+), 59 deletions(-) diff --git a/templates/js/controllers/classController.js b/templates/js/controllers/classController.js index 2690cdc..2d9b4fb 100644 --- a/templates/js/controllers/classController.js +++ b/templates/js/controllers/classController.js @@ -87,6 +87,7 @@ angular.module('SeHub') 'courseId': intClassId, 'gitRepository': $scope.project.repoOwner + '/' + $scope.project.gitRepoName }; + console.log("Look Down"); console.log(jsonNewProj); if ($scope.project.logoUrl) @@ -94,7 +95,7 @@ angular.module('SeHub') apiService.createProject(token, jsonNewProj).success(function(data) { - loadingData = false; + $scope.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()) @@ -104,7 +105,8 @@ angular.module('SeHub') }).error(function(err) { - console.log("Error: " + err.message); + $scope.creatingProject = false; + console.log(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 }); diff --git a/templates/js/controllers/homeController.js b/templates/js/controllers/homeController.js index ddd8125..813f067 100644 --- a/templates/js/controllers/homeController.js +++ b/templates/js/controllers/homeController.js @@ -1,21 +1,21 @@ angular.module('SeHub') -.controller('homeController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) +.controller('homeController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', + function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { $scope.isStudent = false; $scope.addMsg = false; $scope.msgToPost = ""; $scope.oldText = ""; $scope.messages = []; + $scope.userMessages = []; $scope.messagesDisplay = []; $scope.courses = []; $scope.campuses = []; $scope.msg = {}; $scope.courseObj = {}; - // $scope.course = ""; // should be "" ? // {} ?? - + $scope.user = $scope.$parent.user; $rootScope.seToken = $cookies['com.sehub.www']; var token = $rootScope.seToken; - var imagePath = $scope.user.avatar_url; if($scope.user.isLecturer) { @@ -28,6 +28,20 @@ angular.module('SeHub') console.log("Student Mode!"); } + $scope.displayMessages = function() + { + apiService.getAllUserMessages(token).success(function(data) + { + console.log(data); + $scope.userMessages = data; + }).error(function(err) + { + console.log("Error: " + err.message); + }); + } + + $scope.displayMessages(); // + $scope.addMessageClicked = function() { $scope.addMsg = true; // Reveal the "POST" Button @@ -53,8 +67,8 @@ angular.module('SeHub') console.log(err); }); - console.log($scope.msg.msgToAdd); $scope.messages.push({"text": $scope.msg.msgToAdd}); + $location.path('/home/'); } else { @@ -66,30 +80,25 @@ angular.module('SeHub') $scope.displayTasks = function() { + apiService.getAllUserTasks(token).success(function(data) // Get all Tasks // TODO change to closest TASK + { + $scope.tasks = data; + console.log(data); + }).error(function(err) + { + + }); + // apiService.getAllFutureTasks(token, courseId).success(function(data) // need to check courseId // { - + // console.log("YE"); // }).error(function(err) // { - + // console.log("Error: " + err.message); // }); - } - $scope.displayMessages = function() - { - // apiService.getMessagesByGroupId(token, $scope.courseObj.id).success(function(data) - // { - // $scope.messages = data; - // console.log($scope.messages); - // }).error(function(err) - // { - // console.log(err); - // }); - } - - $scope.getCampuses = function() { apiService.getCampusesByUser(token).success(function(data) @@ -98,11 +107,11 @@ angular.module('SeHub') $scope.getCourses(); // Get all the courses info if($scope.messages) { - $scope.displayMessages(); // // Display all messages in message feed and the latest one + //$scope.displayMessages(); // // Display all messages in message feed and the latest one } }).error(function(err) { - console.log("Error: " + err); + console.log("Error: " + err.message); }); } @@ -122,14 +131,14 @@ angular.module('SeHub') } }).error(function(err) { - console.log("Error: " + err); + console.log("Error: " + err.message); }); } } $scope.clearAllClicked = function() // Clear Screen from text { - $scope.messages = []; + $scope.userMessages = []; } $scope.chooseCourseClicked = function() @@ -175,8 +184,8 @@ angular.module('SeHub') $scope.getCampuses(); // Get all the campuses info // animation - - // $scope.displayTasks(); // Display all tasks in task feed and the latest one + // $scope.displayMessages(); + $scope.displayTasks(); // Display all tasks in task feed and the latest one $scope.isEnterd = top.setIsEnterd; }]); \ No newline at end of file diff --git a/templates/js/controllers/newTasksController.js b/templates/js/controllers/newTasksController.js index be7922d..44a5242 100644 --- a/templates/js/controllers/newTasksController.js +++ b/templates/js/controllers/newTasksController.js @@ -110,6 +110,5 @@ angular.module('SeHub').controller('newTasksController', ['$scope', $scope.RB = function(comp){ console.info(comp); } - } ]); \ No newline at end of file diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js index 7fe243c..522f67a 100644 --- a/templates/js/controllers/projectController.js +++ b/templates/js/controllers/projectController.js @@ -35,11 +35,21 @@ angular.module('SeHub') $scope.removeProject = function(ev) { - $mdDialog.show($mdDialog.alert().title('Remove Project').content('Are you sure you want to remove the project ?') - .ariaLabel('Removing project alert dialog').ok('Yes').targetEvent(ev)); - // .then(function() { + $mdDialog.show($mdDialog.confirm().title('Remove Project').content('Are you sure you want to remove the project ?') + .ariaLabel('Removing project alert dialog').ok('Yes').cancel('No').targetEvent(ev)); + + /* + .than(function() + { + $scope.alert = 'You decided to get rid of your debt.'; + }, + function() + { + $scope.alert = 'You decided to keep your debt.'; + }); + */ + // $location.path('/class/' + data.id + '/' + data.courseName); // Will display all the projects in this course - // }); // Pop-up alert }; $scope.getProfileRoute = function(userName) @@ -48,8 +58,6 @@ angular.module('SeHub') { if(userName === $scope.project.members[i].name) { - console.log(userName); - console.log($scope.project.members[i].name); return '#/profile/' + $scope.project.members[i].id; } else diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 77f14dc..1b0c030 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -189,6 +189,46 @@ service.factory('apiService', ['$http', function($http) { }; return $http(req); }, + removeProject: function(token, projectId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/projects/deleteProject/" + token + "/" + projectId; + req = { + method: "DELETE", + url: url + }; + return $http(req); + }, + getAllFutureTasks: function(token, courseId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/tasks/getAllFutureCampusTasks/" + token + "/" + courseId; + req = { + method: "GET", + url: url + }; + return $http(req); + }, + getAllUserTasks: function(token){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/tasks/getAllUserTasks/" + token; + req = { + method: "GET", + url: url + }; + return $http(req); + }, + getAllTasksByCourse: function(token, courseId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/tasks/getAllTasksByCourse/" + token + "/" + courseId; + req = { + method: "GET", + url: url + }; + return $http(req); + }, + getAllUserMessages: function(token){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/messages/getAllUserMessages/" + token; + req = { + method: "GET", + url: url + }; + return $http(req); + }, getCourseById: function(token, id){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesById/" + token + "/" + id; req = { diff --git a/templates/views/home.html b/templates/views/home.html index 44820cf..316c0c4 100644 --- a/templates/views/home.html +++ b/templates/views/home.html @@ -30,17 +30,50 @@
Closest Task- - Will Be Here +
+ In Course: {{tasks[0].courseName}} +
Latest Message- - Will Be Here + {{userMessages[0].message}}
+ + +
@@ -49,30 +82,47 @@ - - -
-
-
- + +
+
+ +
+
+
+ {{msg.user.username}}
-
-
-
- {{user.name}} -
-
- {{courseObj.courseName}} -
-
+
+ {{msg.group.courseName}} +

+ {{msg.group.projectName}}
-
-
- {{msg.text}} -
-
+
+ {{msg.message}} +
+ + + + + @@ -81,7 +131,9 @@

Tasks

- One +
+ +