Implement front-end server searching 🍬
This commit is contained in:
parent
27d472195f
commit
cbeecfe5e4
7 changed files with 30 additions and 15 deletions
|
@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Login attempts and pasword reset requests are now protected by invisible ReCaptcha. This feature can be disabled with a `.env` variable.
|
* Login attempts and pasword reset requests are now protected by invisible ReCaptcha. This feature can be disabled with a `.env` variable.
|
||||||
|
* Server listing for individual users is now searchable on the front-end.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Subuser permissions are now stored in `Permission::list()` to make views way cleaner and make adding to views significantly cleaner.
|
* Subuser permissions are now stored in `Permission::list()` to make views way cleaner and make adding to views significantly cleaner.
|
||||||
|
|
|
@ -31,7 +31,7 @@ class InfoController extends BaseController
|
||||||
{
|
{
|
||||||
public function me(Request $request)
|
public function me(Request $request)
|
||||||
{
|
{
|
||||||
return $request->user()->serverAccessCollection()->load('allocation', 'option')->map(function ($server) {
|
return $request->user()->access('service', 'node', 'allocation', 'option')->get()->map(function ($server) {
|
||||||
return [
|
return [
|
||||||
'id' => $server->uuidShort,
|
'id' => $server->uuidShort,
|
||||||
'uuid' => $server->uuid,
|
'uuid' => $server->uuid,
|
||||||
|
|
|
@ -38,8 +38,14 @@ class IndexController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getIndex(Request $request)
|
public function getIndex(Request $request)
|
||||||
{
|
{
|
||||||
|
$servers = $request->user()->access();
|
||||||
|
|
||||||
|
if (! is_null($request->input('query'))) {
|
||||||
|
$servers->search($request->input('query'));
|
||||||
|
}
|
||||||
|
|
||||||
return view('base.index', [
|
return view('base.index', [
|
||||||
'servers' => $request->user()->serverAccessCollection(config('pterodactyl.paginate.frontend.servers')),
|
'servers' => $servers->paginate(config('pterodactyl.paginate.frontend.servers')),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,8 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables TOTP on an account if the token is valid.
|
* Enables or disables TOTP on an account if the token is valid.
|
||||||
*
|
*
|
||||||
|
@ -200,18 +202,22 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||||
* Returns an array of all servers a user is able to access.
|
* Returns an array of all servers a user is able to access.
|
||||||
* Note: does not account for user admin status.
|
* Note: does not account for user admin status.
|
||||||
*
|
*
|
||||||
* @param int|null $paginate
|
* @param array $load
|
||||||
* @param array $load
|
* @return \Illuiminate\Database\Eloquent\Builder
|
||||||
* @return \Illuminate\Pagination\LengthAwarePagination|\Illuiminate\Database\Eloquent\Collection
|
|
||||||
*/
|
*/
|
||||||
public function serverAccessCollection($paginate = null, $load = ['service', 'node', 'allocation'])
|
public function access(...$load)
|
||||||
{
|
{
|
||||||
$query = Server::with($load);
|
if (count($load) > 0 && is_null($load[0])) {
|
||||||
|
$query = Server::query();
|
||||||
|
} else {
|
||||||
|
$query = Server::with(! empty($load) ? $load : ['service', 'node', 'allocation']);
|
||||||
|
}
|
||||||
|
|
||||||
if (! $this->isRootAdmin()) {
|
if (! $this->isRootAdmin()) {
|
||||||
$query->whereIn('id', $this->serverAccessArray());
|
$query->whereIn('id', $this->serverAccessArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (is_numeric($paginate)) ? $query->paginate($paginate) : $query->get();
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($user->serverAccessCollection() as $server)
|
@foreach($user->access()->get() as $server)
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td>
|
<td><a href="{{ route('server.index', $server->uuidShort) }}/"><i class="fa fa-tachometer"></i></a></td>
|
||||||
<td><code>{{ $server->uuidShort }}</code></td>
|
<td><code>{{ $server->uuidShort }}</code></td>
|
||||||
|
|
|
@ -38,12 +38,14 @@
|
||||||
<div class="box-header">
|
<div class="box-header">
|
||||||
<h3 class="box-title">@lang('base.index.list')</h3>
|
<h3 class="box-title">@lang('base.index.list')</h3>
|
||||||
<div class="box-tools">
|
<div class="box-tools">
|
||||||
<div class="input-group input-group-sm" style="width: 150px;">
|
<form action="{{ route('index') }}" method="GET">
|
||||||
<input type="text" name="table_search" class="form-control pull-right" placeholder="@lang('strings.search')">
|
<div class="input-group input-group-sm" style="width: 250px;">
|
||||||
<div class="input-group-btn">
|
<input type="text" name="query" class="form-control pull-right" value="{{ request()->input('query') }}" placeholder="@lang('strings.search')">
|
||||||
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
|
<div class="input-group-btn">
|
||||||
|
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body table-responsive no-padding">
|
<div class="box-body table-responsive no-padding">
|
||||||
|
|
|
@ -235,7 +235,7 @@
|
||||||
<aside class="control-sidebar control-sidebar-dark">
|
<aside class="control-sidebar control-sidebar-dark">
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<ul class="control-sidebar-menu">
|
<ul class="control-sidebar-menu">
|
||||||
@foreach (Auth::user()->serverAccessCollection(null, []) as $s)
|
@foreach (Auth::user()->access(null)->get() as $s)
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
@if(isset($server) && isset($node))
|
@if(isset($server) && isset($node))
|
||||||
|
|
Loading…
Reference in a new issue