From 35ecdd1f60aa5418aaf7ba44d276c4054afc0d5e Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 2 Aug 2015 23:53:20 +0300 Subject: [PATCH] Tasks... --- templates/js/controllers/tasksController.js | 62 ++++++++++++++++++--- templates/js/services/apiService.js | 8 +++ templates/views/UserStateList.html | 46 +++++++++++++++ templates/views/tasks.html | 4 +- 4 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 templates/views/UserStateList.html diff --git a/templates/js/controllers/tasksController.js b/templates/js/controllers/tasksController.js index b176be4..46cc009 100644 --- a/templates/js/controllers/tasksController.js +++ b/templates/js/controllers/tasksController.js @@ -7,18 +7,32 @@ angular.module('SeHub') $scope.user = $scope.$parent.user; apiService.getAllUserTasks(token).success(function(data) { $scope.tasks = data; - - console.log(data); }).error(function(err) { - console.log(err.message); + console.error(err.message); }); - $scope.taskClicked = function(task, classId, isPersonal) { + $scope.taskClicked = function(task, classId, isPersonal, masterId, ev) { var ownerId = null; - if (classId === $scope.user.id) { + if (masterId === $scope.user.id) { ///This Is The Lecturer ///Need to show the List + $mdDialog.show({ + controller: DialogController, + templateUrl: 'templates/views/UserStateList.html?v=1', + parent: $scope, + targetEvent: ev, + locals: { + data: {task: task, token: token, isPersonal: isPersonal} + } + }) + .then(function(answer) { + $scope.alert = 'You said the information was "' + answer + '".'; + }, function() { + $scope.alert = 'You cancelled the dialog.'; + }); + + } else { if (!isPersonal) { apiService.getProjectsByCourse(token, task.courseId).success(function(data) { @@ -27,11 +41,11 @@ angular.module('SeHub') if (data[i].id.toString() === $scope.user.projects_id_list[j]) ownerId = $scope.user.projects_id_list[j]; } - apiService.isTaskSubmitted(token, task.id, ownerId).success(function(data){ - if(data.submitted) - $location.path('/tasks/overview/'+task.id+'/'+ownerId+'/'+ownerId) + apiService.isTaskSubmitted(token, task.id, ownerId).success(function(data) { + if (data.submitted) + $location.path('/tasks/overview/' + task.id + '/' + ownerId + '/' + ownerId) else - $location.path('/tasks/fill/'+task.id+'/'+ownerId) + $location.path('/tasks/fill/' + task.id + '/' + ownerId) }) }).error(function(err) { console.error('Error: ', err); @@ -41,5 +55,35 @@ angular.module('SeHub') } + function DialogController($scope, $mdDialog, data, apiService) { + + console.log(apiService); + $scope.task = data.task; + $scope.isPersonal = data.isPersonal; + var token = data.token; + $scope.loading = true; + + apiService.getUsersStateByTask(token, $scope.task.id).success(function(data){ + $scope.classList = data; + $scope.loading = false; + }).error(function(err){ + console.error(err); + $scope.hide(); + }) + + + $scope.hide = function() { + $mdDialog.hide(); + }; + $scope.cancel = function() { + $mdDialog.cancel(); + }; + $scope.answer = function(answer) { + $mdDialog.hide(answer); + }; + } + + + } ]); \ No newline at end of file diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 264cc5f..6e064d2 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -287,6 +287,14 @@ service.factory('apiService', ['$http', function($http) { url: url }; return $http(req); + }, + getUsersStateByTask: function(token, taskId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/tasks/getUsersStateByTask/" + token + '/' + taskId; + req = { + method: 'GET', + url: url + }; + return $http(req); } }; }]); \ No newline at end of file diff --git a/templates/views/UserStateList.html b/templates/views/UserStateList.html new file mode 100644 index 0000000..f698c19 --- /dev/null +++ b/templates/views/UserStateList.html @@ -0,0 +1,46 @@ + +
+ +
+

{{task.title}} - Class Status

+ + + X + +
+
+ +
+ +
+
+
+
+
+ +
+
+
{{obj.name || obj.projectName}}
+
+
+ {{obj.grade.grade || "Not Yet Reviewed"}} +
+
+ +
+
+ +
+ + More on Wikipedia + + + + Not Useful + + + Useful + +
+ +
\ No newline at end of file diff --git a/templates/views/tasks.html b/templates/views/tasks.html index f162b9a..3641064 100644 --- a/templates/views/tasks.html +++ b/templates/views/tasks.html @@ -63,7 +63,7 @@
- +
{{personalTask.title}}
@@ -81,7 +81,7 @@
- +
{{projectTask.title}}