diff --git a/angular_app/index.html b/angular_app/index.html index 7fbc973..4046451 100644 --- a/angular_app/index.html +++ b/angular_app/index.html @@ -74,6 +74,7 @@ @@ -82,7 +83,7 @@
  • {{info.user.username}} -  {{'logout' | translate}} +  {{'logout' | translate}}
  • diff --git a/angular_app/js/app.js b/angular_app/js/app.js index 1ec8870..21cbc29 100644 --- a/angular_app/js/app.js +++ b/angular_app/js/app.js @@ -159,10 +159,15 @@ eventManApp.config(['$stateProvider', '$urlRouterProvider', templateUrl: 'import-persons.html', controller: 'FileUploadCtrl' }) + .state('users', { + url: '/users', + templateUrl: 'users-list.html', + controller: 'UsersCtrl' + }) .state('login', { url: '/login', templateUrl: 'login.html', - controller: 'LoginCtrl' + controller: 'UsersCtrl' }); } ]); diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index 6d0fa3b..e285c65 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -652,9 +652,22 @@ eventManControllers.controller('PersonDetailsCtrl', ['$scope', '$state', 'Person ); -eventManControllers.controller('LoginCtrl', ['$scope', '$rootScope', '$state', '$log', 'User', +eventManControllers.controller('UsersCtrl', ['$scope', '$rootScope', '$state', '$log', 'User', function ($scope, $rootScope, $state, $log, User) { $scope.loginData = {}; + $scope.usersOrderProp = ['username']; + + $scope.updateUsersList = function() { + if ($state.is('users')) { + $scope.users = User.all(); + } + }; + + $scope.updateUsersList(); + + $scope.deleteUser = function(user_id) { + User.delete({id: user_id}, $scope.updateUsersList); + }; $scope.register = function() { User.add($scope.newUser, function(data) { diff --git a/angular_app/js/services.js b/angular_app/js/services.js index 5f7b449..2d2a46a 100644 --- a/angular_app/js/services.js +++ b/angular_app/js/services.js @@ -234,6 +234,19 @@ eventManServices.factory('Info', ['$resource', '$rootScope', eventManServices.factory('User', ['$resource', '$rootScope', function($resource, $rootScope) { return $resource('users/:id', {id: '@_id'}, { + all: { + method: 'GET', + interceptor : {responseError: $rootScope.errorHandler}, + isArray: true, + transformResponse: function(data, headers) { + data = angular.fromJson(data); + if (data.error) { + return data; + } + return data.users; + } + }, + get: { method: 'GET', interceptor : {responseError: $rootScope.errorHandler}, @@ -251,6 +264,11 @@ eventManServices.factory('User', ['$resource', '$rootScope', interceptor : {responseError: $rootScope.errorHandler} }, + update: { + method: 'PUT', + interceptor : {responseError: $rootScope.errorHandler} + }, + login: { method: 'POST', url: '/login', diff --git a/angular_app/users-list.html b/angular_app/users-list.html new file mode 100644 index 0000000..cebe5c4 --- /dev/null +++ b/angular_app/users-list.html @@ -0,0 +1,54 @@ + +
    +

    {{'Users' | translate}} + +

    +
    +
    {{'Users' | translate}}
    +
    +
    +
    + + +
    +
    + + +
    +
    + + + + + + + + + + + + + + + +
    {{'User' | translate}}{{'Actions' | translate}}
    + + + {{user.username}} <{{user.email}}> + + + + +
    +
    +
    +
    + diff --git a/eventman_server.py b/eventman_server.py index bdce279..70477d1 100755 --- a/eventman_server.py +++ b/eventman_server.py @@ -733,6 +733,14 @@ class UsersHandler(CollectionHandler): document = 'user' collection = 'users' + def filter_get_all(self, data): + if 'users' not in data: + return data + for user in data['users']: + if 'password' in user: + del user['password'] + return data + def filter_input_post_all(self, data): username = (data.get('username') or '').strip() password = (data.get('password') or '').strip()