Skip to content

Commit bd7fd83

Browse files
committed
clean up node allocation
1 parent 16222d1 commit bd7fd83

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1717
### Fixed
1818
* Team Fortress named 'Insurgency' in panel in database seeder. ([#96](https://github.com/Pterodactyl/Panel/issues/96), PR by [@MeltedLux](https://github.com/MeltedLux))
1919
* Server allocation listing display now showing the connection IP unless an alias was assigned.
20+
* Fixed bug where node allocation would appear to be successful but actual encounter an error. Made it cleared how to enter ports.
2021

2122
### Deprecated
2223
### Removed

app/Http/Controllers/Admin/NodesController.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Debugbar;
2828
use Log;
2929
use DB;
30+
use Validator;
3031

3132
use Pterodactyl\Models;
3233
use Pterodactyl\Repositories\NodeRepository;
@@ -116,6 +117,10 @@ public function getView(Request $request, $id)
116117
->orderBy('allocations.ip', 'asc')
117118
->orderBy('allocations.port', 'asc')
118119
->paginate(20, ['*'], 'allocations'),
120+
'allocation_ips' => Models\Allocation::select('id', 'ip')
121+
->where('node', $node->id)
122+
->groupBy('ip')
123+
->get(),
119124
]);
120125
}
121126

@@ -169,7 +174,7 @@ public function deallocateBlock(Request $request, $node)
169174
Alert::success('Deleted all unallocated ports for <code>' . $request->input('ip') . '</code>.')->flash();
170175
return redirect()->route('admin.nodes.view', [
171176
'id' => $node,
172-
'tab' => 'tab_allocations'
177+
'tab' => 'tab_allocation'
173178
]);
174179
}
175180

@@ -198,6 +203,19 @@ public function getAllocationsJson(Request $request, $id)
198203

199204
public function postAllocations(Request $request, $id)
200205
{
206+
207+
$validator = Validator::make($request->all(), [
208+
'allocate_ip.*' => 'required|string',
209+
'allocate_port.*' => 'required'
210+
]);
211+
212+
if ($validator->fails()) {
213+
return redirect()->route('admin.nodes.view', [
214+
'id' => $id,
215+
'tab' => 'tab_allocation'
216+
])->withErrors($validator->errors())->withInput();
217+
}
218+
201219
$processedData = [];
202220
foreach($request->input('allocate_ip') as $ip) {
203221
if (!array_key_exists($ip, $processedData)) {
@@ -217,9 +235,6 @@ public function postAllocations(Request $request, $id)
217235
}
218236

219237
try {
220-
if(empty($processedData)) {
221-
throw new DisplayException('It seems that no data was passed to this function.');
222-
}
223238
$node = new NodeRepository;
224239
$node->addAllocations($id, $processedData);
225240
Alert::success('Successfully added new allocations to this node.')->flash();

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
},
276276
"docker": {
277277
"socket": "/var/run/docker.sock",
278-
"autoupdate_images": false
278+
"autoupdate_images": true
279279
},
280280
"sftp": {
281281
"path": "{{ $node->daemonBase }}",
@@ -318,8 +318,8 @@
318318
<div class="input-group-btn">
319319
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
320320
<ul class="dropdown-menu dropdown-menu-right">
321-
@foreach($allocations as $ip => $ports)
322-
<li data-action="alloc_dropdown_val" data-value="{{ $ip }}"><a href="#">{{ $ip }}</a></li>
321+
@foreach($allocation_ips as $allocation)
322+
<li data-action="alloc_dropdown_val" data-value="{{ $allocation->ip }}"><a href="#">{{ $allocation->ip }}</a></li>
323323
@endforeach
324324
</ul>
325325
</div>
@@ -334,7 +334,7 @@
334334
</li>
335335
</ul>
336336
</div>
337-
<p class="text-muted"><small>Please enter a comma (<code>,</code>) after each port or port range.</small></p>
337+
<p class="text-muted"><small>You <strong>must</strong> enter a comma (<code>,</code>) or press the enter key after each port or range that you enter. They should appear in a blue box.</small></p>
338338
<input name="allocate_port[]" type="hidden" class="pillboxMain"/>
339339
</div>
340340
<div class="form-group col-md-1 col-xs-2" style="margin-left: -10px;">
@@ -468,12 +468,8 @@
468468
<div class="row">
469469
<div class="col-md-12">
470470
<select class="form-control" name="ip">
471-
<?php $displayed = []; ?>
472-
@foreach($allocations as $allocation)
473-
@if(!array_key_exists($allocation->ip, $displayed))
474-
<option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option>
475-
<?php $displayed[$allocation->ip] = true; ?>
476-
@endif
471+
@foreach($allocation_ips as $allocation)
472+
<option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option>
477473
@endforeach
478474
</select>
479475
</div>

0 commit comments

Comments
 (0)