diff --git a/SE_API/MessageRoutes.py b/SE_API/MessageRoutes.py index 5815c60..31d7d4f 100644 --- a/SE_API/MessageRoutes.py +++ b/SE_API/MessageRoutes.py @@ -92,7 +92,7 @@ def createMessage(token): db.put(msg) db.save - return Response(response=json.dumps(msg), + return Response(response=msg.to_JSON(), status=200, mimetype="application/json") diff --git a/templates/js/controllers/homeController.js b/templates/js/controllers/homeController.js index b0d3d59..0e617e3 100644 --- a/templates/js/controllers/homeController.js +++ b/templates/js/controllers/homeController.js @@ -4,7 +4,6 @@ angular.module('SeHub') { $scope.isStudent = false; $scope.addMsg = false; - $scope.msgToPost = ""; $scope.oldText = ""; $scope.messages = []; $scope.userMessages = []; @@ -40,11 +39,10 @@ angular.module('SeHub') $scope.addMessageClicked = function() { - $scope.addMsg = true; // Reveal the "POST" Button + $scope.addMsg = !$scope.addMsg; // Reveal the "POST" Button } $scope.postMessageClicked = function() // Posting the message itself - { - console.log($scope.courseObj); + { if($scope.msg.msgToAdd != null && $scope.courseObj.courseName) { jsonNewMsg = { @@ -68,9 +66,30 @@ angular.module('SeHub') $scope.msg.msgToAdd = null; } + $scope.reviewTask = function(task) + { + //tasks/overview/:taskId/:submitterId/:gId', { + if(task.isPersonal) // As Lecturer + { + $location.path('/tasks/overview/' + task.id + '/' + $scope.user.id + '/' + $scope.user.id); + } + else // it's a project task + { + apiService.getProjectsByCourse(token, task.courseId).success(function(data) + { + for(var i = 0; i < $scope.user.projects_id_list.length; i++) + for(var j = 0; j < data.length; j++) + if($scope.user.projects_id_list[i] === data[j].id.toString()) + $location.path('/tasks/overview/' + task.id + '/' + data[j].id + '/' + data[j].id); + }).error(function(err) + { + console.log(err.message); + }); + } + } + $scope.gotoTask = function(task) { - console.log(task); if(task.isPersonal) { $location.path('/tasks/fill/' + task.id + '/' + $scope.user.id); @@ -130,7 +149,6 @@ angular.module('SeHub') { console.log(err.message); }); - } $scope.getCourses = function() diff --git a/templates/js/controllers/projectController.js b/templates/js/controllers/projectController.js index 8757136..3312242 100644 --- a/templates/js/controllers/projectController.js +++ b/templates/js/controllers/projectController.js @@ -11,10 +11,28 @@ angular.module('SeHub') $scope.isMember = false; $scope.project = []; $scope.isInProject = false; + $scope.projectMessages = []; + $scope.msg = {}; // $scope.thisProject = {}; // $scope.thisProject.courseName = $routeParams.className; + + $scope.displayProjectMessages = function() + { + apiService.getAllUserMessages(token).success(function(data) + { + $scope.projectMessages = data; + }).error(function(err) + { + console.log(err.message); + }); + } + + $scope.goToProfile = function(memberId) + { + $location.path('#/profile/' + memberId); + } $scope.removeUserFromProject = function() { apiService.removeUserFromProject.success(function(data) @@ -67,12 +85,44 @@ angular.module('SeHub') }, function() { // No - Dont remove - console.log("Not removed"); - }); // $location.path('/class/' + data.id + '/' + data.courseName); // Will display all the projects in this course }; + $scope.addMessageClicked = function() + { + $scope.addMsg = !$scope.addMsg; // Reveal the "POST" Button + } + $scope.postMessageClicked = function() // Posting the message itself + { + if($scope.msg.msgToAdd != null) + { + // console.log(msg.msgToAdd); + jsonNewMsg = { + 'groupId': parseInt(projectId), // TODO Should be ===> $scope.courseObj.id + 'message': $scope.msg.msgToAdd, + 'isProject': true + }; + console.log(jsonNewMsg.message); + console.log(jsonNewMsg.groupId); + console.log(jsonNewMsg.isProject); + + apiService.createMessage(token, jsonNewMsg).success(function(data) + { + $scope.projectMessages.push(data); + }).error(function(err) + { + console.log(err.message); + }); + } + else + { + $mdDialog.show($mdDialog.alert().title('Error Creating Message').content('Message content or Course is missing') + .ariaLabel('Send Message alert dialog').ok('Try Again!').targetEvent()); // Pop-up alert + } + $scope.msg.msgToAdd = null; + } + $scope.getProfileRoute = function(userName) { for(var i = 0; i < $scope.project.members.length; i++) @@ -124,5 +174,7 @@ angular.module('SeHub') console.log(err.message); }); } + $scope.displayProjectMessages(); // Display all messages in project $scope.getProjectInfo(); // Get all this project data + }]); \ No newline at end of file diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js index ea62d41..1179bdf 100644 --- a/templates/js/controllers/taskController.js +++ b/templates/js/controllers/taskController.js @@ -21,7 +21,7 @@ angular.module('SeHub') $scope.isMaster = (user.id === data.master_id); }); if (!data.isPersonal) { - apiService.getProjectsById(token, groupId).sucsess(function(data) { + apiService.getProjectsById(token, groupId).success(function(data) { $scope.group = data; }); } else { diff --git a/templates/views/home.html b/templates/views/home.html index 67a2c43..24618b9 100644 --- a/templates/views/home.html +++ b/templates/views/home.html @@ -26,70 +26,10 @@

Dash Board

- -
- - - - - - -
- -
- -
- - -
-
- {{msg.user.username}} -
-
- {{msg.group.courseName}} - {{msg.group.projectName}} -
-
- - -
- {{msg.message}} -
- -
- - -
-
- -
- - - -
- Title: - - {{task.title}} - -

- Description: {{task.description}} -
-
-
-
- -
-
-
-
- + +
@@ -112,6 +52,51 @@
+ +
+ + + + + +
+
+ +
+
+
+ {{msg.user.username}} +
+
+ {{msg.group.courseName}} + {{msg.group.projectName}} +
+
+
+ {{msg.message}} +
+
+
+
+
+ + + +
+ Title: + + {{task.title}} + +

+ Description: {{task.description}} +
+
+
+
+
+
+
+
@@ -127,65 +112,15 @@
Latest Message- - + {{userMessages[0].message}} + + No Messages. +
- - -
- - - - - -
-
- -
-
-
- {{msg.user.username}} -
-
- {{msg.group.courseName}} - {{msg.group.projectName}} -
-
-
- {{msg.message}} -
-
-
-
- -
-
- - - -
- Title: - - {{task.title}} - -

- Description: {{task.description}} -
-
-
-
- -
-
-
-
+
@@ -193,7 +128,6 @@
Post - Clear All
@@ -210,6 +144,48 @@
+ + +
+ + + +
+
+ +
+
+
+ {{msg.user.username}} +
+
+ {{msg.group.courseName}} + {{msg.group.projectName}} +
+
+
+ {{msg.message}} +
+
+
+
+ + + +
+ Title: + + {{task.title}} + +

+ Description: {{task.description}} +
+
+
+
+
+
+
\ No newline at end of file diff --git a/templates/views/project.html b/templates/views/project.html index 9bfd82f..5c10ac8 100644 --- a/templates/views/project.html +++ b/templates/views/project.html @@ -43,18 +43,22 @@
Team Members:
@@ -73,6 +77,25 @@
+
+
+ +
+
+
+
+ Post +
+
+
+
+ + + + +
+
+
@@ -80,10 +103,25 @@ - -

Messages

-

Messages...

-
+ +
+
+ +
+
+
+ {{msg.user.username}} +
+
+ {{msg.group.courseName}} + {{msg.group.projectName}} +
+
+
+ {{msg.message}} +
+
+