This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit a58eecbdb5e4e2e19dd80ee9bf1d06e2bdb8270b Author: Yannick Martel <martel@©odelutin.com> Date: Tue Feb 17 15:28:17 2015 +0100 manage notification for questions/projects --- .../services/CoselmarWebServiceSupport.java | 8 ++ .../coselmar/services/v1/QuestionsWebService.java | 2 +- coselmar-ui/src/main/webapp/i18n/en.js | 7 ++ coselmar-ui/src/main/webapp/i18n/fr.js | 7 ++ .../src/main/webapp/js/coselmar-controllers.js | 119 ++++++++++++--------- .../src/main/webapp/js/coselmar-error-services.js | 37 ++++--- 6 files changed, 111 insertions(+), 69 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarWebServiceSupport.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarWebServiceSupport.java index 5fdb1c1..1d52f0a 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarWebServiceSupport.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarWebServiceSupport.java @@ -242,6 +242,14 @@ public abstract class CoselmarWebServiceSupport extends WebMotionController impl log.error("Error during authorization check : user does not exist !", e); } throw new InvalidCredentialException("User not known"); + + } catch (IllegalStateException e) { + // No token set + if (log.isErrorEnabled()) { + log.error("Error during JWT verification : no token!", e); + } + throw new InvalidCredentialException("Seems no user connected"); + } } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java index cac8102..4c7e21c 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java @@ -306,10 +306,10 @@ public class QuestionsWebService extends CoselmarWebServiceSupport { for (Document document : documents) { document.removeRestrictedList(participantGroup); } + question.addAllContributors(participantGroup.getMembers()); } // Question become unavailable - question.addAllContributors(participantGroup.getMembers()); question.setUnavailable(true); getPersistenceContext().getCoselmarUserGroupDao().delete(participantGroup); diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index 6bcfa7d..d391cda 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -150,6 +150,12 @@ var translateEN = { "question.message.requiredType" : "Type is required.", "question.message.requiredSummary" : "A summary is required.", "question.message.requiredThemes" : "At least one theme is required.", +"question.message.saved" : "Project well saved.", +"question.message.deleted" : "Project well deleted.", +"question.message.closed" : "Project has been closed.", +"question.message.reopened" : "Project has been reopened.", +"question.message.adjourned" : "Project has been adjourned.", +"question.message.newDocuments.added" : "New documents has been added.", "question.button.add" : "Add a project", "question.button.reopen" : "Reopen", @@ -222,6 +228,7 @@ var translateEN = { "user.message.wannaSimpleLogin" : "Use simple login, not a mail (Warning : no password could be sent)", "user.message.invalidLogin" : "Login is mandatory.", "user.message.created" : "User well created.", +"user.message.updated" : "User well modified.", "user.message.deleted" : "User well deleted.", "user.message.disable" : "User well disable.", "user.message.enable" : "User well enable.", diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index 61534f1..f16d7b5 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -150,6 +150,12 @@ var translateFR = { "question.message.requiredType" : "Le type est requis..", "question.message.requiredSummary" : "Un résumé est requis.", "question.message.requiredThemes" : "Au moins un thème est requis.", +"question.message.saved" : "Projet enregistré.", +"question.message.deleted" : "Projet supprimé.", +"question.message.closed" : "Le projet a été fermé.", +"question.message.reopened" : "Le projet a été rouvert.", +"question.message.adjourned" : "Le projet a été ajourné.", +"question.message.newDocuments.added" : "Les nouveaux documents ont été ajoutés au projet", "question.button.add" : "Ajouter un projet", "question.button.reopen" : "Réouvrir", @@ -222,6 +228,7 @@ var translateFR = { "user.message.wannaSimpleLogin" : "Utiliser un simple identifiant et non un courriel (Attention : aucun mot de passe ne pourra être envoyé.)", "user.message.invalidLogin" : "L'identifiant est obligatoire.", "user.message.created" : "Utilisateur créé.", +"user.message.updated" : "Utilisateur modifié.", "user.message.deleted" : "Utilisateur supprimé.", "user.message.disable" : "Utilisateur désactivé.", "user.message.enable" : "Utilisateur réactivé.", diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index c76d677..58949cc 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -464,7 +464,7 @@ coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', // Notification notify({ message: "user.message.delete", - classes: "alert-success", + classes: "alert-warning", templateUrl: "views/notificationTemplate.html" }); // Go back to documents list @@ -479,7 +479,7 @@ coselmarControllers.controller("UsersCtrl", ['$scope', '$route', '$routeParams', // Notification notify({ message: "user.message.disable", - classes: "alert-success", + classes: "alert-warning", templateUrl: "views/notificationTemplate.html" }); // Go back to users list @@ -600,7 +600,7 @@ coselmarControllers.controller("UserViewCtrl", // Notification notify({ message: "user.message.deleted", - classes: "alert-success", + classes: "alert-warning", templateUrl: "views/notificationTemplate.html" }); // Go back to users list @@ -618,7 +618,7 @@ coselmarControllers.controller("UserViewCtrl", // Notification notify({ message: "user.message.disable", - classes: "alert-success", + classes: "alert-warning", templateUrl: "views/notificationTemplate.html" }); // Go back to users list @@ -656,6 +656,12 @@ coselmarControllers.controller("UserViewCtrl", if(isValidForm) { userService.saveUser($scope.user, function() { + // Notification + notify({ + message: "user.message.updated", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); // On success, back on users list for admin or supervisor if ($scope.currentUser.role == 'ADMIN' || $scope.currentUser.role == 'SUPERVISOR') { $location.path("/users"); @@ -745,8 +751,8 @@ coselmarControllers.directive('identicalCheck', [function () { ///////////////////////////////////////////////// // Controller for All Question View -coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routeParams', '$location', 'questionsService', - function($scope, $route, $routeParams, $location, questionsService){ +coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routeParams', '$location', 'questionsService', 'notify', 'errorService', + function($scope, $route, $routeParams, $location, questionsService, notify, errorService){ $scope.searchOptions = { 'privacy' : '', 'status' : '', 'keywords' : []}; @@ -754,15 +760,12 @@ coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routePara // success : just get the questions $scope.questions = questions; - }, function(error) { - // Fail function : TODO - console.log(error); - }); + }, errorService.defaultFailOnCall); $scope.searchQuestions = function() { questionsService.getQuestions($scope.searchOptions, function(questions) { $scope.questions = questions; - }); + }, errorService.defaultFailOnCall(error)); }; @@ -770,13 +773,16 @@ coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routePara $scope.deleteQuestion = function(questionId) { questionsService.deleteQuestion(questionId, function(questions) { - // success : just get the questions + // Notification + notify({ + message: "question.message.deleted", + classes: "alert-warning", + templateUrl: "views/notificationTemplate.html" + }); + // success : just reload the questions $route.reload(); - }, function(error) { - // Fail function : TODO - console.log(error); - }); + }, errorService.defaultFailOnCall); }; $scope.getUserNames = function(users) { @@ -803,8 +809,8 @@ coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routePara }]); // Controller for Question View -coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParams', '$location', '$modal', 'questionsService', - function($scope, $route, $routeParams, $location, $modal, questionsService){ +coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParams', '$location', '$modal', 'notify', 'questionsService', 'errorService', + function($scope, $route, $routeParams, $location, $modal, notify, questionsService, errorService){ $scope.editSession = $routeParams.edit ? $routeParams.edit : false; $scope.isCurrentParticipant = false; @@ -942,23 +948,21 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam bindUsers($scope.question.supervisors, $scope.supervisorsIndex); } - }, function(error) { - // Fail function : TODO - console.log("error during request"); - console.log(error); - }); + }, errorService.defaultFailOnCall); }; //Deletion $scope.deleteQuestion = function(){ questionsService.deleteQuestion($routeParams.questionId, function() { + notify({ + message: "question.message.deleted", + classes: "alert-warning", + templateUrl: "views/notificationTemplate.html" + }); // success : goto questions list - $location('#/questions'); + $location.path('/questions'); - }, function(error) { - // Fail function : TODO - console.log(error); - }); + }, errorService.defaultFailOnCall); }; $scope.saveQuestion = function() { @@ -972,16 +976,18 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam } else { // Call service to create a new question questionsService.saveQuestion($scope.question, function() { + // Notification + notify({ + message: "question.message.saved", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); if ($routeParams.questionId) { $location.search(""); } else { $location.path("/questions"); } - },function(error) { - //TODO ymartel 20141118 : deal with error.status or statusText - console.log("error occurs"); - console.log(error.s); - }); + }, errorService.defaultFailOnCall); } }; @@ -994,12 +1000,14 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam } questionsService.saveQuestion($scope.question, function() { + // Notification + notify({ + message: "question.message.closed", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $route.reload(); - },function(error) { - //TODO ymartel 20141118 : deal with error.status or statusText - console.log("error occurs"); - console.log(error.s); - }); + },errorService.defaultFailOnCall); }; $scope.openCloseQuestionSession = function(){ @@ -1019,12 +1027,14 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam } questionsService.saveQuestion($scope.question, function() { + // Notification + notify({ + message: "question.message.reopened", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $route.reload(); - },function(error) { - //TODO ymartel 20141118 : deal with error.status or statusText - console.log("error occurs"); - console.log(error.s); - }); + },errorService.defaultFailOnCall); }; $scope.adjournQuestion = function(){ @@ -1036,12 +1046,14 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam } questionsService.saveQuestion($scope.question, function() { + // Notification + notify({ + message: "question.message.adjourned", + classes: "alert-warning", + templateUrl: "views/notificationTemplate.html" + }); $route.reload(); - },function(error) { - //TODO ymartel 20141118 : deal with error.status or statusText - console.log("error occurs"); - console.log(error.s); - }); + },errorService.defaultFailOnCall); }; // New documents added @@ -1051,12 +1063,15 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam && $scope.question.newRelatedDocuments.length > 0) { questionsService.addNewDocuments($routeParams.questionId, $scope.question.newRelatedDocuments, function() { + // Notification + notify({ + message: "question.message.newDocuments.added", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $route.reload(); - }, function(error) { - // Fail function : TODO - console.log(error); - }); + }, errorService.defaultFailOnCall); } }; diff --git a/coselmar-ui/src/main/webapp/js/coselmar-error-services.js b/coselmar-ui/src/main/webapp/js/coselmar-error-services.js index c86de65..aca69b4 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-error-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-error-services.js @@ -22,32 +22,37 @@ * #L% */ coselmarServices.factory('errorService', ['$location', 'notify', function($location, notify){ + + var reject401 = function() { + // create return to path wanted + var returnTo = $location.path(); + $location.path("/401").search('returnTo', returnTo); + }; + var reject403 = function() { + // create return to path wanted + $location.path("/403"); + }; + var reject404 = function() { + // create return to path wanted + $location.path("/404"); + }; + return { - reject401 : function() { - // create return to path wanted - var returnTo = $location.path(); - $location.path("/401").search('returnTo', returnTo); - }, - reject403 : function() { - // create return to path wanted - $location.path("/403"); - }, - reject404 : function() { - // create return to path wanted - $location.path("/404"); - }, + reject401 : reject401, + reject403 : reject403, + reject404 : reject404, // Default function for error during call processing defaultFailOnCall : function(error) { if (error.status == 403) { - errorService.reject403(); + reject403(); } else if (error.status == 401) { - errorService.reject401(); + reject401(); } else if (error.status == 404) { - errorService.reject404(); + reject404(); } else { notify({ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.