This is an automated email from the git hooks/post-receive script. New commit to branch feature/adminUser in repository pollen. See http://git.chorem.org/pollen.git commit 0074cdd28558a007db521001d083055d70284627 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon Jul 21 17:55:46 2014 +0200 can give the admin right at an user in user-list --- .../chorem/pollen/rest/api/v1/PollenUserApi.java | 5 +++ pollen-rest-api/src/main/resources/mapping | 1 + .../pollen/services/service/PollenUserService.java | 13 +++++- pollen-ui-angular/src/main/webapp/i18n/en.js | 2 + pollen-ui-angular/src/main/webapp/i18n/fr.js | 4 +- pollen-ui-angular/src/main/webapp/js/app.js | 2 +- .../src/main/webapp/js/controllers/userCtrl.js | 4 ++ pollen-ui-angular/src/main/webapp/js/services.js | 7 ++++ .../src/main/webapp/partials/user-admin-list.html | 49 ++++++++++++++++++++++ .../src/main/webapp/partials/user-list.html | 31 -------------- 10 files changed, 84 insertions(+), 34 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java index 5bf3b60..dfbf98b 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/PollenUserApi.java @@ -74,6 +74,11 @@ public class PollenUserApi extends WebMotionController { } + public PollenUserBean adminUser(PollenUserService pollenUserService, + PollenUserBean user) { + return pollenUserService.adminUser(user); + } + public void deleteUser(PollenUserService pollenUserService, PollenEntityId<PollenUser> userId) throws InvalidFormException { pollenUserService.deleteUser(userId.getEntityId()); diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index 1d55eb5..f3d8522 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -130,6 +130,7 @@ GET /v1/users/{userId} PollenUserApi.getUser POST /v1/users PollenUserApi.createUser PUT,POST /v1/users/{userId} PollenUserApi.editUser PUT,POST /v1/users/{userId}/password PollenUserApi.changePassword +POST /v1/users/{userId}/admin PollenUserApi.adminUser DELETE /v1/users/{userId} PollenUserApi.deleteUser PUT /v1/users/{userId}?token={} PollenUserApi.validateUserEmail diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index 484d3c9..d30fb32 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -120,6 +120,18 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer } + public PollenUserBean adminUser(PollenUserBean user) { + checkNotNull(user); + checkIsAdmin(); + + PollenUser userSaved = savePollenUser(user, false); + commit(); + + getNotificationService().onUserEdited(userSaved); + + return toBean(PollenUserBean.class, userSaved, pollenUserFunction); + } + public void deleteUser(String userId) { checkNotNull(userId); @@ -327,5 +339,4 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer return parameter; } - } diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index 8ba71b5..71dd0dc 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -25,7 +25,9 @@ var translateEN = { 'user.listPollInvited' : 'Invited Poll', 'user.name' : 'Name', +'user.myName' : 'Name', 'user.mail' : 'e-mail', +'user.isAdmin' : 'Is an administrator', 'user.password' : 'Password', 'user.password2' : 'Confirm', 'user.passwordNew' : 'New password', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index fb3ff29..acaa9cf 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -24,8 +24,10 @@ var translateFR = { 'user.listPollParticiped' : 'Sondage Participé', 'user.listPollInvited' : 'Sondage invité', -'user.name' : 'Votre Nom', +'user.name' : 'Nom d\'utilisateur', +'user.myName' : 'Votre Nom', 'user.mail' : 'Courriel', +'user.isAdmin' : 'Est Administrateur', 'user.password' : 'Mot de passe', 'user.password2' : 'Confirmation', 'user.passwordNew' : 'Nouveau Mot de passe', diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index ef73d67..f3e51ee 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -66,7 +66,7 @@ angular.module('pollen', ['pollenDirective', 'pollenServices', 'ngRoute', 'Polle .when('/poll/result/:pollId/:token?', {templateUrl: './partials/poll.html', controller :"PollResultCtrl"}) .when('/poll/comment/:pollId/:commentToken?', {templateUrl: './partials/poll.html', controller :"PollCommentCtrl"}) .when('/poll/list/:cmd?', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"}) - .when('/user/list', {templateUrl: './partials/user-list.html', controller:"UserListCtrl"}) + .when('/user/list', {templateUrl: './partials/user-admin-list.html', controller:"UserListCtrl"}) .when('/user/register', {templateUrl: './partials/user-register.html', controller:"UserRegisterCtrl"}) .when('/user/edit', {templateUrl: './partials/user-edit.html', controller:"UserEditCtrl"}) .when('/user/lostpassword', {templateUrl: './partials/user-lostPassword.html', controller:"UserLostPasswordCtrl"}) diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js index d93ee6a..0c6e424 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -146,6 +146,10 @@ angular.module('userControllers', []) $scope.data.users = data.elements; $scope.data.usersPagination = data.pagination }); + + $scope.saveUser = function (user) { + User.admin(user); + }; }]) .controller('UserLoginCtrl', ['$scope', 'UserLogin', 'UserLogout', 'User', 'SessionStorage', '$route', '$location', '$translate', function ($scope, UserLogin, UserLogout, User, SessionStorage, $route, $location, $translate) { diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index fc4fef3..82ef663 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -209,6 +209,13 @@ angular.module('pollenServices', ['ngResource']) return transformParam(data); } }, + 'admin': { + method : 'POST', + url: conf.restURL+'/users/:userId/admin', + transformRequest: function (data, headersGetter) { + return transformParam(data); + } + }, 'update' : { method:'POST', diff --git a/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html b/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html new file mode 100644 index 0000000..3a8571c --- /dev/null +++ b/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html @@ -0,0 +1,49 @@ +<!-- + #%L + Pollen :: UI (Angular) + %% + Copyright (C) 2009 - 2014 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> + +<div ng-if="!data.users[0]"><h1>{{ 'user.error.listEmpty' | translate }}</h1></div> + +<table class="table table-hover"> + <tr> + <th>{{ 'user.name' | translate }}</th> + <th>{{ 'user.isAdmin' | translate }}</th> + <th>{{ 'action' | translate }}</th> + </tr> + <tr ng-repeat="user in data.users"> + <td>{{user.name || user.email}}</td> + <td> + <input type="checkbox" ng-model="user.administrator" /> + </td> + <td class="action"> + <button class="btn btn-primary" ng-click="saveUser(user)"> <span class="glyphicon glyphicon-save"></span> </button> + <button class="btn btn-danger" ng-click="deleteUser(user)" disabled> <span class="glyphicon glyphicon-trash"></span> </button> + </td> + </tr> + <tr> + <td colspan="3"> + <make-pagination current-page="data.usersPagination.currentPage" + last-page="data.usersPagination.lastPage" + page-size="data.usersPagination.pageSize"></make-pagination> + + </td> + </tr> + +</table> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-list.html b/pollen-ui-angular/src/main/webapp/partials/user-list.html deleted file mode 100644 index c605945..0000000 --- a/pollen-ui-angular/src/main/webapp/partials/user-list.html +++ /dev/null @@ -1,31 +0,0 @@ -<!-- - #%L - Pollen :: UI (Angular) - %% - Copyright (C) 2009 - 2014 CodeLutin - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> - -<div ng-if="!data.users[0]"><h1>{{ 'user.error.listEmpty' | translate }}</h1></div> - -<div ng-repeat="user in data.users"> - <h2><a href="#/user/edit/{{user.id}}">{{user.name || user.email}}</a></h2> - <hr/> -</div> - -<make-pagination current-page="data.usersPagination.currentPage" - last-page="data.usersPagination.lastPage" - page-size="data.usersPagination.pageSize"></make-pagination> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.