#136: page of list of users
This commit is contained in:
parent
6aa219f265
commit
1ec1bca6fe
6 changed files with 102 additions and 3 deletions
|
@ -74,6 +74,7 @@
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li ng-class="{active: isActive('/events') || isActive('/event')}"><a ui-sref="events">{{'Events' | translate}}</a></li>
|
<li ng-class="{active: isActive('/events') || isActive('/event')}"><a ui-sref="events">{{'Events' | translate}}</a></li>
|
||||||
<li ng-if="hasPermission('admin|all')" ng-class="{active: isActive('/tickets')}"><a ui-sref="tickets">{{'All tickets' | translate}}</a></li>
|
<li ng-if="hasPermission('admin|all')" ng-class="{active: isActive('/tickets')}"><a ui-sref="tickets">{{'All tickets' | translate}}</a></li>
|
||||||
|
<li ng-if="hasPermission('admin|all')" ng-class="{active: isActive('/users')}"><a ui-sref="users">{{'Users' | translate}}</a></li>
|
||||||
<li ng-if="hasPermission('admin|all')" ng-class="{active: isActive('/import/persons')}"><a ui-sref="import.persons">{{'Import tickets' | translate}}</a></li>
|
<li ng-if="hasPermission('admin|all')" ng-class="{active: isActive('/import/persons')}"><a ui-sref="import.persons">{{'Import tickets' | translate}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -82,7 +83,7 @@
|
||||||
<li ng-if="info.user.username">
|
<li ng-if="info.user.username">
|
||||||
<span class="btn">{{info.user.username}}</span>
|
<span class="btn">{{info.user.username}}</span>
|
||||||
<span class="btn btn-link">
|
<span class="btn btn-link">
|
||||||
<a ng-controller="LoginCtrl" ng-click="logout()"><span class="fa fa-sign-out vcenter"></span> {{'logout' | translate}}</a>
|
<a ng-controller="UsersCtrl" ng-click="logout()"><span class="fa fa-sign-out vcenter"></span> {{'logout' | translate}}</a>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li ng-if="!info.user.username">
|
<li ng-if="!info.user.username">
|
||||||
|
|
7
angular_app/js/app.js
vendored
7
angular_app/js/app.js
vendored
|
@ -159,10 +159,15 @@ eventManApp.config(['$stateProvider', '$urlRouterProvider',
|
||||||
templateUrl: 'import-persons.html',
|
templateUrl: 'import-persons.html',
|
||||||
controller: 'FileUploadCtrl'
|
controller: 'FileUploadCtrl'
|
||||||
})
|
})
|
||||||
|
.state('users', {
|
||||||
|
url: '/users',
|
||||||
|
templateUrl: 'users-list.html',
|
||||||
|
controller: 'UsersCtrl'
|
||||||
|
})
|
||||||
.state('login', {
|
.state('login', {
|
||||||
url: '/login',
|
url: '/login',
|
||||||
templateUrl: 'login.html',
|
templateUrl: 'login.html',
|
||||||
controller: 'LoginCtrl'
|
controller: 'UsersCtrl'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
15
angular_app/js/controllers.js
vendored
15
angular_app/js/controllers.js
vendored
|
@ -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) {
|
function ($scope, $rootScope, $state, $log, User) {
|
||||||
$scope.loginData = {};
|
$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() {
|
$scope.register = function() {
|
||||||
User.add($scope.newUser, function(data) {
|
User.add($scope.newUser, function(data) {
|
||||||
|
|
18
angular_app/js/services.js
vendored
18
angular_app/js/services.js
vendored
|
@ -234,6 +234,19 @@ eventManServices.factory('Info', ['$resource', '$rootScope',
|
||||||
eventManServices.factory('User', ['$resource', '$rootScope',
|
eventManServices.factory('User', ['$resource', '$rootScope',
|
||||||
function($resource, $rootScope) {
|
function($resource, $rootScope) {
|
||||||
return $resource('users/:id', {id: '@_id'}, {
|
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: {
|
get: {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
interceptor : {responseError: $rootScope.errorHandler},
|
interceptor : {responseError: $rootScope.errorHandler},
|
||||||
|
@ -251,6 +264,11 @@ eventManServices.factory('User', ['$resource', '$rootScope',
|
||||||
interceptor : {responseError: $rootScope.errorHandler}
|
interceptor : {responseError: $rootScope.errorHandler}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
update: {
|
||||||
|
method: 'PUT',
|
||||||
|
interceptor : {responseError: $rootScope.errorHandler}
|
||||||
|
},
|
||||||
|
|
||||||
login: {
|
login: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/login',
|
url: '/login',
|
||||||
|
|
54
angular_app/users-list.html
Normal file
54
angular_app/users-list.html
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<!-- show the list of Users -->
|
||||||
|
<div class="container">
|
||||||
|
<h1>{{'Users' | translate}}
|
||||||
|
<button ng-click="$state.go('login')" class="btn btn-success">
|
||||||
|
<span class="fa fa-plus-circle vcenter"></span>
|
||||||
|
{{'Add user' | translate}}
|
||||||
|
</button>
|
||||||
|
</h1>
|
||||||
|
<div class="panel panel-primary table-striped top5">
|
||||||
|
<div class="panel-heading">{{'Users' | translate}}</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<form class="form-inline">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="query-users">{{'Search:' | translate}}</label>
|
||||||
|
<input userman-focus type="text" id="query-users" class="form-control" placeholder="{{'Username or email' | translate}}" ng-model="query" ng-model-options="{debounce: 600}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="users-order">Sort by:</label>
|
||||||
|
<select id="users-order" class="form-control" ng-model="usersOrderProp">
|
||||||
|
<option value="username">{{'Username' | translate}}</option>
|
||||||
|
<option value="-username">{{'Username (descending)' | translate}}</option>
|
||||||
|
<option value="email">{{'Email' | translate}}</option>
|
||||||
|
<option value="-email">{{'Email (descending)' | translate}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div ng-include=" 'modal-confirm-action.html' " class="hidden"></div>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><strong>{{'User' | translate}}</strong></th>
|
||||||
|
<th><strong>{{'Actions' | translate}}</strong></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="user in users | splittedFilter:query | orderBy:usersOrderProp">
|
||||||
|
<td>
|
||||||
|
<span>
|
||||||
|
<strong>
|
||||||
|
<a ui-sref="user.edit({id: user._id})">{{user.username}}</a><span ng-if="user.email && user.email != user.username"> <{{user.email}}></a>
|
||||||
|
</strong>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button ng-if="hasPermission('user|delete')" ng-click="deleteUser(user._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -733,6 +733,14 @@ class UsersHandler(CollectionHandler):
|
||||||
document = 'user'
|
document = 'user'
|
||||||
collection = 'users'
|
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):
|
def filter_input_post_all(self, data):
|
||||||
username = (data.get('username') or '').strip()
|
username = (data.get('username') or '').strip()
|
||||||
password = (data.get('password') or '').strip()
|
password = (data.get('password') or '').strip()
|
||||||
|
|
Loading…
Reference in a new issue