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 3da9a3c413e5036005a0aad7c5a67f5c95cd08c7 Author: Yannick Martel <martel@©odelutin.com> Date: Mon Dec 7 12:15:14 2015 +0100 refs #6742 #7775 Add list of public project in homepage without connexion --- .../coselmar/services/v1/QuestionsWebService.java | 26 ++++++++++++++++++++++ coselmar-rest/src/main/resources/mapping | 1 + coselmar-ui/src/main/webapp/i18n/en.js | 2 +- coselmar-ui/src/main/webapp/i18n/fr.js | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 7 ++++++ .../main/webapp/js/coselmar-questions-services.js | 6 +++++ coselmar-ui/src/main/webapp/views/home.html | 10 ++++----- 7 files changed, 47 insertions(+), 7 deletions(-) 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 fc5c64e..64d3488 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 @@ -262,6 +262,32 @@ public class QuestionsWebService extends CoselmarWebServiceSupport { return result; } + public List<QuestionBean> getPublicQuestions() throws InvalidCredentialException, UnauthorizedException { + + // No authentication needed, just filter to get last 5 public questions + QuestionSearchBean searchOption = new QuestionSearchBean(); + searchOption.setPrivacy(Privacy.PUBLIC.name()); + searchOption.setStatus(Status.OPEN.name()); + searchOption.setLimit(5); + searchOption.setPage(1); + + PaginationParameter paginationParameter = PaginationParameter.of(0, 5, Question.PROPERTY_SUBMISSION_DATE, true); + + List<Question> questionList = getQuestionDao().findWithSearchBean(searchOption, paginationParameter); + + List<QuestionBean> result = new ArrayList<>(questionList.size()); + + for (Question question : questionList) { + TopiaIdFactory topiaIdFactory = getPersistenceContext().getTopiaIdFactory(); + + QuestionBean questionBean = BeanEntityConverter.toLightBean(topiaIdFactory, question); + + result.add(questionBean); + } + + return result; + } + public void deleteQuestion(String questionId) throws InvalidCredentialException, UnauthorizedException { // Check authentication diff --git a/coselmar-rest/src/main/resources/mapping b/coselmar-rest/src/main/resources/mapping index ec66430..b933d17 100644 --- a/coselmar-rest/src/main/resources/mapping +++ b/coselmar-rest/src/main/resources/mapping @@ -55,6 +55,7 @@ DELETE /v1/users/{userId} UsersWebService.deleteUser # Questions Api GET /v1/questions QuestionsWebService.getQuestions +GET /v1/questions/public QuestionsWebService.getPublicQuestions GET /v1/questions/themes QuestionsWebService.getThemes GET /v1/questions/types QuestionsWebService.getTypes GET /v1/questions/{questionId} QuestionsWebService.getQuestion diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index 4c39150..3a61d04 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -314,7 +314,7 @@ var translateEN = { <p>The knowledge base can be queried and the results of queries consulted a variety of views that can be exported. Recent features are being developed.</p>\ <p>Access to this platform is secure. To obtain a right of access to thank you for the request through the Coselmar website contact page (<a href='http://www.coselmar.fr/contact/' target='_blank'>http://www.coselmar.fr/contact/</a>).</p>\ </p>", -"home.connected.lastProjects" : "Last projects", +"home.lastProjects" : "Last projects", "error.message.authentication.title" : "Error with authentication", "error.message.authentication.body" : "Error with authentication, please try to log again.", diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index 71b57e7..0d6ede6 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -315,7 +315,7 @@ var translateFR = { Ces dernières fonctionnalités sont en cours de développement.</p>\ <p>L'accès à cette plateforme est sécurisé. Pour obtenir un droit d'accès merci d'en faire la demande au travers de la page contact du site Coselmar (<a href='http://www.coselmar.fr/contact/' target='_blank'>http://www.coselmar.fr/contact/</a>).\ </p>", -"home.connected.lastProjects" : "Derniers projets", +"home.lastProjects" : "Derniers projets", "error.message.authentication.title" : "Échec d'authentification", "error.message.authentication.body" : "Une erreur avec l'authentification est survenue, veuillez vous reconnecter svp.", diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index b49fcac..df83aa7 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -126,6 +126,13 @@ coselmarControllers.controller("homeConnectedCtrl", ['$scope', 'questionsService }, function(fail) { $scope.questions = []; }); + } else { + + questionsService.getPublicQuestions(function(questions) { + $scope.questions = questions; + }, function(fail) { + $scope.questions = []; + }); } }]); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js index e86196b..f8d64d6 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js @@ -78,6 +78,12 @@ function Question(resource, config){ questionResource.query().$promise.then(successFunction, failFunction); }; + this.getPublicQuestions = function(successFunction, failFunction) { + + var questionResource = resource(baseURL + "/public"); + questionResource.query().$promise.then(successFunction, failFunction); + }; + this.deleteQuestion = function(questionId, successFunction, failFunction) { var questionResource = resource(baseURL + "/" + questionId); questionResource.delete().$promise.then(successFunction, failFunction); diff --git a/coselmar-ui/src/main/webapp/views/home.html b/coselmar-ui/src/main/webapp/views/home.html index 0c0f7da..e5660ec 100644 --- a/coselmar-ui/src/main/webapp/views/home.html +++ b/coselmar-ui/src/main/webapp/views/home.html @@ -25,9 +25,9 @@ <div translate="home.presentation.title"></div> <div style="margin-top : 50px" translate="home.presentation.body"></div> - <!-- In case of user connected, show five last projects --> - <div ng-if="context.currentUser"> - <h2>{{ "home.connected.lastProjects" | translate }}</h2> + <!-- Show five last projects --> + <div> + <h2>{{ "home.lastProjects" | translate }}</h2> <table class="table table-bordered"> <thead> @@ -43,11 +43,11 @@ </thead> <tbody> <tr ng-repeat="question in questions" > - <td ng-if="context.currentUser.role != 'MEMBER'"> + <td ng-if="context.currentUser && context.currentUser.role != 'MEMBER'"> <span class="status-{{question.status|lowercase}}" title="{{question.status | translate}}"></span> <a href="#/questions/{{question.id}}" class="paddingLeft10" tooltip-placement="bottom" tooltip-html-unsafe="{{question.summary}}">{{question.title}}</a> </td> - <td ng-if="context.currentUser.role == 'MEMBER'">{{question.title}}</td> + <td ng-if="!context.currentUSer || context.currentUser.role == 'MEMBER'">{{question.title}}</td> <td>{{question.submissionDate | date:'mediumDate'}}</td> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.