Skip to content

Commit e9762b4

Browse files
committed
Fixes port deletion for node allocations as well as server notes on allocations.
closes pterodactyl#305
1 parent 22da8d4 commit e9762b4

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
99
* `[pre.2]` — Fixes inability to edit a server due to owner_id issues.
1010
* `[pre.2]` — Fixes bug when trying to add new subusers.
1111
* Emails sending with 'Pterodactyl Panel' as the from name. Now configurable by using `php artisan pterodactyl:mail` to update.
12+
* `[pre.2]` — Fixes inability to delete accounts due to SQL changes.
13+
* `[pre.2]` — Fixes bug with checking power-permissions that showed the wrong buttons. Also adds check back to sidebar to only show options a user can use.
14+
* `[pre.2]` — Fixes allocation listing on node allocations tab as well as bug preventing deletion of port.
1215

1316
### Changed
1417
* `[pre.2]` — File Manager now displays relevant information on all screen sizes, and includes better button clicking mechanics for dropdown menu.
1518
* Reduced the number of database queries being executed when viewing a specific server. This is done by caching the query for up to 60 minutes in memcached.
1619
* User creation emails include more information and are sent by the event listener rather than the repository.
20+
* Account password reset emails now auto-fill the email when clicking the link.
1721

1822
### Added
1923
* Notifications when a user is added or removed as a subuser for a server.

app/Http/Controllers/Admin/NodesController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getView(Request $request, $id)
108108
'servers.user', 'servers.service',
109109
'servers.allocations', 'location'
110110
)->findOrFail($id);
111-
$node->setRelation('allocations', $node->allocations()->paginate(40));
111+
$node->setRelation('allocations', $node->allocations()->with('server')->paginate(40));
112112

113113
return view('admin.nodes.view', [
114114
'node' => $node,
@@ -151,7 +151,7 @@ public function postView(Request $request, $id)
151151

152152
public function deallocateSingle(Request $request, $node, $allocation)
153153
{
154-
$query = Models\Allocation::where('node', $node)->whereNull('server_id')->where('id', $allocation)->delete();
154+
$query = Models\Allocation::where('node_id', $node)->whereNull('server_id')->where('id', $allocation)->delete();
155155
if ((int) $query === 0) {
156156
return response()->json([
157157
'error' => 'Unable to find an allocation matching those details to delete.',

app/Models/Allocation.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ public function getHasAliasAttribute($value)
7474
{
7575
return ! is_null($this->ip_alias);
7676
}
77+
78+
/**
79+
* Gets information for the server associated with this allocation.
80+
*
81+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
82+
*/
83+
public function server()
84+
{
85+
return $this->belongsTo(Server::class);
86+
}
7787
}

resources/views/admin/nodes/view.blade.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,20 @@
356356
</thead>
357357
<tbody>
358358
@foreach($node->allocations as $allocation)
359-
<tr>
359+
<tr>
360360
<td class="col-sm-3 align-middle">{{ $allocation->ip }}</td>
361361
<td class="col-sm-3 align-middle">
362362
<input class="form-control input-sm" type="text" value="{{ $allocation->ip_alias }}" data-action="set-alias" data-id="{{ $allocation->id }}" placeholder="none" />
363363
<span class="input-loader"><i class="fa fa-refresh fa-spin fa-fw"></i></span>
364364
</td>
365365
<td class="col-sm-2 align-middle">{{ $allocation->port }}</td>
366-
<td class="col-sm-3 align-middle">@if(!is_null($allocation->assigned_to))<a href="{{ route('admin.servers.view', $allocation->assigned_to) }}">{{ $allocation->assigned_to_name }}</a>@endif</td>
366+
<td class="col-sm-3 align-middle">
367+
@if(! is_null($allocation->server))
368+
<a href="{{ route('admin.servers.view', $allocation->server_id) }}">{{ $allocation->server->name }}</a>
369+
@endif
370+
</td>
367371
<td class="col-sm-1 align-middle">
368-
@if(is_null($allocation->assigned_to))
372+
@if(is_null($allocation->server_id))
369373
<a href="#" data-action="deallocate" data-id="{{ $allocation->id }}"><span class="badge label-danger"><i class="fa fa-trash-o"></i></span></a>
370374
@else
371375
<span class="badge label-default"><i class="fa fa-trash-o"></i></span>

0 commit comments

Comments
 (0)