This commit is contained in:
Sagi Dayan 2015-08-02 23:53:20 +03:00
parent 6437396125
commit 35ecdd1f60
4 changed files with 109 additions and 11 deletions

View file

@ -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);
};
}
}
]);

View file

@ -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);
}
};
}]);

View file

@ -0,0 +1,46 @@
<md-dialog aria-label="Class Status" style='width: 80%'>
<form>
<md-toolbar>
<div class="md-toolbar-tools">
<h2>{{task.title}} - Class Status</h2>
<span flex></span>
<md-button ng-click="answer('not applicable')">
X
</md-button>
</div>
</md-toolbar>
<md-dialog-conten layout-padding>
<div ng-if='loading'>
</div>
<div ng-if='!loading'>
<div ng-repeat="obj in classList">
<div layout='row' width='100%' >
<div>
<img ng-src="{{obj.avatar_url || obj.logo_url}}" alt="" class='campusAvatar' style='max-height:auto'>
</div>
<div class='spacer'></div>
<div>{{obj.name || obj.projectName}}</div>
<div class='spacer'></div>
<div>
{{obj.grade.grade || "Not Yet Reviewed"}}
</div>
</div>
<md-divider ng-if="!$last"></md-divider>
</div>
</div>
</md-dialog-content>
<div class="md-actions" layout="row">
<md-button href="http://en.wikipedia.org/wiki/Mango" target="_blank" hide show-md>
More on Wikipedia
</md-button>
<span flex></span>
<md-button ng-click="answer('not useful')" class="md-primary">
Not Useful
</md-button>
<md-button ng-click="answer('useful')" class="md-primary">
Useful
</md-button>
</div>
</form>
</md-dialog>

View file

@ -63,7 +63,7 @@
<div class="Personal" style='width:100%' >
<div layout='column' ng-repeat="personalTask in class.PersonalTasks">
<div>
<md-button style='width: 100%' layout='row'>
<md-button style='width: 100%' layout='row' ng-click="taskClicked(personalTask, class.courseId, true, class.master_id, $event)">
<div>
{{personalTask.title}}
</div>
@ -81,7 +81,7 @@
<div class="Project" style='width:100%'>
<div layout='column' ng-repeat="projectTask in class.projectTasks">
<md-button style='width: 100%' layout='row'>
<md-button style='width: 100%' layout='row' ng-click="taskClicked(projectTask, class.courseId, false, class.master_id, $event)">
<div>
{{projectTask.title}}
</div>