04/05: List User for admin
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit a4d70d7750993dc86ac5260727e7dd5e10c0fa34 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jul 2 18:51:57 2014 +0200 List User for admin --- pollen-ui-angular/src/main/webapp/js/app.js | 1 + .../src/main/webapp/js/controllers/userCtrl.js | 56 ++++++++++++++++++---- .../src/main/webapp/partials/poll-link.html | 1 + .../src/main/webapp/partials/user-edit.html | 22 ++++----- .../src/main/webapp/partials/user-list.html | 11 +++++ 5 files changed, 71 insertions(+), 20 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index a8bf214..8c3d08f 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -64,6 +64,7 @@ angular.module('pollen', ['pollenDirective', 'pollenServices', 'ngRoute', 'pollC .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/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 20b38da..4935fad 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -73,19 +73,24 @@ -.controller('UserEditCtrl', ['$scope', '$rootScope', '$location', 'User', 'SessionStorage', function ($scope, $rootScope, $location, User, SessionStorage) { - $scope.currentUser = SessionStorage.get().user; +.controller('UserEditCtrl', ['$scope', '$rootScope', '$routeParams', '$route', '$location', 'User', 'SessionStorage', function ($scope, $rootScope, $routeParams, $route, $location, User, SessionStorage) { + if (angular.isUndefined($scope.data)) { + $scope.data = {user:{}}; + } + + $scope.data.user = angular.copy(SessionStorage.get().user); - if (angular.isUndefined($scope.currentUser)) { + if (angular.isUndefined($scope.data.user)) { $rootScope.$broadcast('newError', 'user.error.login.mandatory' ); $location.url('/'); } - $scope.currentUser.password = ''; + $scope.data.user.password = ''; $scope.editUser = function () { - User.update($scope.currentUser, function (data) { + User.update($scope.data.user, function (data) { SessionStorage.save({user:data}); + $rootScope.$broadcast('editUser'); $rootScope.$broadcast('newSuccess', 'user.edit.success'); }, function (error) { $scope.restError = error.data; @@ -93,9 +98,8 @@ } $scope.editPassword = function () { - if ($scope.currentUser.newPassword == $scope.currentUser.newPassword2) { - User.editPassword($scope.currentUser, function (data) { - SessionStorage.save({user:data}); + if ($scope.data.user.newPassword == $scope.data.user.newPassword2) { + User.editPassword($scope.data.user, function (data) { $rootScope.$broadcast('newSuccess', 'user.edit.success'); }, function (error) { $scope.restError = error.data; @@ -104,6 +108,36 @@ } }]) +.controller('UserListCtrl', ['$scope', '$routeParams', 'User', + function ($scope, $routeParams, User) { + if (angular.isUndefined($scope.data)) { + $scope.data = {user:{}}; + } + + if (angular.isDefined(conf.pollDefaultPageSize)) { + $scope.pageSize = conf.pollDefaultPageSize; + } + else { + $scope.pageSize = -1; + } + + var paginationParameter = {pageSize:$scope.pageSize}; + if (angular.isDefined($routeParams.page)) { + if (angular.isDefined($routeParams.pageSize)) { + paginationParameter = {pageSize:$routeParams.pageSize}; + $scope.pageSize = $routeParams.pageSize; + } + + paginationParameter.pageNumber = $routeParams.page; + } + + User.get({paginationParameter:paginationParameter}, function (data) { + console.log(data); + $scope.data.users = data.elements; + $scope.data.usersPagination = data.pagination + }); +}]) + .controller('UserLoginCtrl', ['$scope', 'UserLogin', 'UserLogout', 'User', 'SessionStorage', '$route', '$location', '$translate', function ($scope, UserLogin, UserLogout, User, SessionStorage, $route, $location, $translate) { if (angular.isUndefined($scope.data)) { $scope.data = {user:{}}; @@ -111,7 +145,11 @@ $scope.$on('sessionExpired', function() { $scope.logout(); - }) + }); + + $scope.$on('editUser', function() { + $scope.currentUser = SessionStorage.get().user; + }); $scope.currentUser = SessionStorage.get().user; diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-link.html b/pollen-ui-angular/src/main/webapp/partials/poll-link.html index 73822bc..21fd606 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-link.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-link.html @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --> + <ul> <li class="toMini" ng-click="toggleMinify()"> <a class="fakeLink" ng-show="globalVariables.minify"><span class="glyphicon glyphicon-chevron-right"></span></a> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-edit.html b/pollen-ui-angular/src/main/webapp/partials/user-edit.html index c995f7d..765d96e 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-edit.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-edit.html @@ -26,7 +26,7 @@ {{ 'user.name' | translate }} </label> <div class="col-sm-6"> - <input type="text" id="formName" class="form-control" ng-model="currentUser.name" auto-save="editUser()" /> + <input type="text" id="formName" class="form-control" ng-model="data.user.name" auto-save="editUser()" /> </div> <div class="col-sm-1"> </div> @@ -39,10 +39,10 @@ </label> <div class="col-sm-6"> - <input type="email" id="formEmail" name="email" class="form-control" ng-model="currentUser.email" auto-save="editUser()" /> + <input type="email" id="formEmail" name="email" class="form-control" ng-model="data.user.email" auto-save="editUser()" /> </div> <div class="col-sm-1"> - <info-error error="restError.email[0]" data="currentUser.email"></info-error> + <info-error error="restError.email[0]" data="data.user.email"></info-error> </div> </div> @@ -51,10 +51,10 @@ {{ 'user.passwordCurrent' | translate }} </label> <div class="col-sm-6"> - <input type="password" id="formPassword" class="form-control" ng-model="currentUser.password" auto-save="editUser()" /> + <input type="password" id="formPassword" class="form-control" ng-model="data.user.password" auto-save="editUser()" /> </div> <div class="col-sm-1"> - <info-error error="restError.password[0]" data="currentUser.password"></info-error> + <info-error error="restError.password[0]" data="data.user.password"></info-error> </div> </div> @@ -73,10 +73,10 @@ {{ 'user.passwordCurrent' | translate }} </label> <div class="col-sm-6"> - <input type="password" id="formCurrentPassword" class="form-control" ng-model="currentUser.password" /> + <input type="password" id="formCurrentPassword" class="form-control" ng-model="data.user.password" /> </div> <div class="col-sm-1"> - <info-error error="restError.password[0]" data="currentUser.password"></info-error> + <info-error error="restError.password[0]" data="data.user.password"></info-error> </div> </div> @@ -85,10 +85,10 @@ {{ 'user.passwordNew' | translate }} </label> <div class="col-sm-6"> - <input type="password" id="formNewPassword" class="form-control" ng-model="currentUser.newPassword" auto-save="editPassword()"/> + <input type="password" id="formNewPassword" class="form-control" ng-model="data.user.newPassword" auto-save="editPassword()"/> </div> <div class="col-sm-1"> - <info-error error="restError.newPassword[0]" data="currentUser.newPassword"></info-error> + <info-error error="restError.newPassword[0]" data="data.user.newPassword"></info-error> </div> </div> @@ -97,10 +97,10 @@ {{ 'user.password2' | translate }} </label> <div class="col-sm-6"> - <input type="password" id="formNewPassword2" class="form-control" ng-model="currentUser.newPassword2" auto-save="editPassword()"/> + <input type="password" id="formNewPassword2" class="form-control" ng-model="data.user.newPassword2" auto-save="editPassword()"/> </div> <div class="col-sm-1"> - <span class="glyphicon glyphicon-exclamation-sign danger" tooltip="{{ 'user.error.password.diff' | translate }}" ng-if="currentUser.newPassword != currentUser.newPassword2"></span> + <span class="glyphicon glyphicon-exclamation-sign danger" tooltip="{{ 'user.error.password.diff' | translate }}" ng-if="data.user.newPassword != data.user.newPassword2"></span> </div> </div> </form> diff --git a/pollen-ui-angular/src/main/webapp/partials/user-list.html b/pollen-ui-angular/src/main/webapp/partials/user-list.html new file mode 100644 index 0000000..02867b7 --- /dev/null +++ b/pollen-ui-angular/src/main/webapp/partials/user-list.html @@ -0,0 +1,11 @@ + +<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>.
participants (1)
-
chorem.org scm