Add ability to filter user list

This commit is contained in:
Dane Everitt 2016-12-02 18:41:52 -05:00
parent ed5b7559ec
commit 3cd0a8337f
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 35 additions and 1 deletions

View File

@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Added ### Added
* Changing node configuration values now automatically makes a call to the daemon and updates the configuration there. Changing daemon tokens now does not require any intervention, and takes effect immediately. SSL & Port configurations will still require a daemon reboot. * Changing node configuration values now automatically makes a call to the daemon and updates the configuration there. Changing daemon tokens now does not require any intervention, and takes effect immediately. SSL & Port configurations will still require a daemon reboot.
* New button in file manager that triggers the right click menu to enable support on mobile devices and those who cannot right click (blessed be them). * New button in file manager that triggers the right click menu to enable support on mobile devices and those who cannot right click (blessed be them).
* Support for filtering users when listing all users on the system.
### Changed ### Changed
* File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached. * File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached.

View File

@ -51,8 +51,33 @@ class UserController extends Controller
public function getIndex(Request $request) public function getIndex(Request $request)
{ {
$query = User::select('users.*');
if ($request->input('filter') && !is_null($request->input('filter'))) {
preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches);
foreach($matches[0] as $match) {
$match = str_replace('"', '', $match);
if (strpos($match, ':')) {
list($field, $term) = explode(':', $match);
$query->orWhere($field, 'LIKE', '%' . $term . '%');
} else {
$query->where('email', 'LIKE', '%' . $match . '%');
$query->orWhere([
['uuid', 'LIKE', '%' . $match . '%'],
['root_admin', 'LIKE', '%' . $match . '%']
]);
}
}
}
try {
$users = $query->paginate(20);
} catch (\Exception $ex) {
Alert::warning('There was an error with the search parameters provided.');
$users = User::all()->paginate(20);
}
return view('admin.users.index', [ return view('admin.users.index', [
'users' => User::paginate(20) 'users' => $users
]); ]);
} }

View File

@ -31,6 +31,14 @@
<li class="active">Accounts</li> <li class="active">Accounts</li>
</ul> </ul>
<h3>All Registered Users</h3><hr /> <h3>All Registered Users</h3><hr />
<form method="GET" style="margin-bottom:20px;">
<div class="input-group">
<input type="text" name="filter" class="form-control" value="{{ urldecode(Input::get('filter')) }}" placeholder="search term" />
<div class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary">Filter Users</button>
</div>
</div>
</form>
<table class="table table-striped table-bordered table-hover"> <table class="table table-striped table-bordered table-hover">
<thead> <thead>
<tr> <tr>