Fix user search in admin area; closes #2100

This commit is contained in:
Dane Everitt 2020-09-13 12:35:48 -07:00
parent 88300e5448
commit 8b4bd3945d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 16 additions and 7 deletions

View file

@ -185,11 +185,20 @@ class UserController extends Controller
*/ */
public function json(Request $request) public function json(Request $request)
{ {
$users = QueryBuilder::for(User::query())->allowedFilters(['email'])->paginate(25);
// Handle single user requests. // Handle single user requests.
if ($request->query('user_id')) { if ($request->query('user_id')) {
return $this->repository->filterById($request->input('user_id')); $user = User::query()->findOrFail($request->input('user_id'));
$user->md5 = md5(strtolower($user->email));
return $user;
} }
return $this->repository->filterUsersByQuery($request->input('q')); return $users->map(function ($item) {
$item->md5 = md5(strtolower($item->email));
return $item;
});
} }
} }

View file

@ -161,7 +161,7 @@ function initUserIdSelect(data) {
data: function (params) { data: function (params) {
return { return {
q: params.term, // search term filter: { email: params.term },
page: params.page, page: params.page,
}; };
}, },

View file

@ -31,7 +31,7 @@
<div class="box-tools search01"> <div class="box-tools search01">
<form action="{{ route('admin.nodes') }}" method="GET"> <form action="{{ route('admin.nodes') }}" method="GET">
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input type="text" name="query" class="form-control pull-right" value="{{ request()->input('query') }}" placeholder="Search Nodes"> <input type="text" name="filter[name]" class="form-control pull-right" value="{{ request()->input('filter.name') }}" placeholder="Search Nodes">
<div class="input-group-btn"> <div class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button> <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
<a href="{{ route('admin.nodes.new') }}"><button type="button" class="btn btn-sm btn-primary" style="border-radius: 0 3px 3px 0;margin-left:-1px;">Create New</button></a> <a href="{{ route('admin.nodes.new') }}"><button type="button" class="btn btn-sm btn-primary" style="border-radius: 0 3px 3px 0;margin-left:-1px;">Create New</button></a>

View file

@ -327,7 +327,7 @@
// END Persist 'Service Variables' // END Persist 'Service Variables'
</script> </script>
{!! Theme::js('js/admin/new-server.js') !!} {!! Theme::js('js/admin/new-server.js?v=20200913') !!}
<script type="application/javascript"> <script type="application/javascript">
$(document).ready(function() { $(document).ready(function() {

View file

@ -73,7 +73,7 @@
delay: 250, delay: 250,
data: function (params) { data: function (params) {
return { return {
q: params.term, // search term filter: { email: params.term },
page: params.page, page: params.page,
}; };
}, },

View file

@ -26,7 +26,7 @@
<div class="box-tools search01"> <div class="box-tools search01">
<form action="{{ route('admin.users') }}" method="GET"> <form action="{{ route('admin.users') }}" method="GET">
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input type="text" name="query" class="form-control pull-right" value="{{ request()->input('query') }}" placeholder="Search"> <input type="text" name="filter[email]" class="form-control pull-right" value="{{ request()->input('filter.email') }}" placeholder="Search">
<div class="input-group-btn"> <div class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button> <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
<a href="{{ route('admin.users.new') }}"><button type="button" class="btn btn-sm btn-primary" style="border-radius: 0 3px 3px 0;margin-left:-1px;">Create New</button></a> <a href="{{ route('admin.users.new') }}"><button type="button" class="btn btn-sm btn-primary" style="border-radius: 0 3px 3px 0;margin-left:-1px;">Create New</button></a>