Skip to content

Commit 6fda3b7

Browse files
committed
Display total servers user can access in the Admin CP
closes pterodactyl#356
1 parent 23e6e05 commit 6fda3b7

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

app/Http/Controllers/Admin/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class UserController extends Controller
4444
*/
4545
public function index(Request $request)
4646
{
47-
$users = User::withCount('servers');
47+
$users = User::withCount('servers', 'subuserOf');
4848

4949
if (! is_null($request->input('query'))) {
5050
$users->search($request->input('query'));

app/Models/User.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,14 @@ public function servers()
239239
{
240240
return $this->hasMany(Server::class, 'owner_id');
241241
}
242+
243+
/**
244+
* Return all servers that user is listed as a subuser of directly.
245+
*
246+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
247+
*/
248+
public function subuserOf()
249+
{
250+
return $this->hasMany(Subuser::class);
251+
}
242252
}

resources/themes/pterodactyl/admin/users/index.blade.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
<th>Email</td>
5858
<th>Client Name</th>
5959
<th>Username</th>
60-
<th>Servers</th>
60+
<th class="text-center" data-toggle="tooltip" data-placement="top" title="Servers that this user is marked as the owner of.">Servers Owned</th>
61+
<th class="text-center" data-toggle="tooltip" data-placement="top" title="Servers that this user can access because they are marked as a subuser.">Can Access</th>
6162
<th></th>
6263
</tr>
6364
</thead>
@@ -68,7 +69,8 @@
6869
<td><a href="{{ route('admin.users.view', $user->id) }}">{{ $user->email }}</a></td>
6970
<td>{{ $user->name_last }}, {{ $user->name_first }}</td>
7071
<td>{{ $user->username }}</td>
71-
<td>{{ $user->servers_count }}</td>
72+
<td class="text-center">{{ $user->servers_count }}</td>
73+
<td class="text-center">{{ $user->subuser_of_count }}</td>
7274
<td class="text-center"><img src="https://www.gravatar.com/avatar/{{ md5(strtolower($user->email)) }}?s=20" class="img-circle" /></td>
7375
</tr>
7476
@endforeach

resources/themes/pterodactyl/admin/users/view.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@
136136
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
137137
<td>
138138
@if($server->owner_id === $user->id)
139-
@lang('strings.owner')
139+
<span class="label bg-purple">Owner</span>
140140
@else
141-
@lang('strings.subuser')
141+
<span class="label bg-blue">Subuser</span>
142142
@endif
143143
</td>
144144
<td><a href="{{ route('admin.nodes.view', $server->node->id) }}">{{ $server->node->name }}</a></td>

0 commit comments

Comments
 (0)