clean up node allocation
This commit is contained in:
parent
16222d1bd7
commit
bd7fd836ff
3 changed files with 26 additions and 14 deletions
|
@ -17,6 +17,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
### Fixed
|
### Fixed
|
||||||
* Team Fortress named 'Insurgency' in panel in database seeder. ([#96](https://github.com/Pterodactyl/Panel/issues/96), PR by [@MeltedLux](https://github.com/MeltedLux))
|
* Team Fortress named 'Insurgency' in panel in database seeder. ([#96](https://github.com/Pterodactyl/Panel/issues/96), PR by [@MeltedLux](https://github.com/MeltedLux))
|
||||||
* Server allocation listing display now showing the connection IP unless an alias was assigned.
|
* Server allocation listing display now showing the connection IP unless an alias was assigned.
|
||||||
|
* Fixed bug where node allocation would appear to be successful but actual encounter an error. Made it cleared how to enter ports.
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
### Removed
|
### Removed
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Alert;
|
||||||
use Debugbar;
|
use Debugbar;
|
||||||
use Log;
|
use Log;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
use Pterodactyl\Models;
|
use Pterodactyl\Models;
|
||||||
use Pterodactyl\Repositories\NodeRepository;
|
use Pterodactyl\Repositories\NodeRepository;
|
||||||
|
@ -116,6 +117,10 @@ class NodesController extends Controller
|
||||||
->orderBy('allocations.ip', 'asc')
|
->orderBy('allocations.ip', 'asc')
|
||||||
->orderBy('allocations.port', 'asc')
|
->orderBy('allocations.port', 'asc')
|
||||||
->paginate(20, ['*'], 'allocations'),
|
->paginate(20, ['*'], 'allocations'),
|
||||||
|
'allocation_ips' => Models\Allocation::select('id', 'ip')
|
||||||
|
->where('node', $node->id)
|
||||||
|
->groupBy('ip')
|
||||||
|
->get(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +174,7 @@ class NodesController extends Controller
|
||||||
Alert::success('Deleted all unallocated ports for <code>' . $request->input('ip') . '</code>.')->flash();
|
Alert::success('Deleted all unallocated ports for <code>' . $request->input('ip') . '</code>.')->flash();
|
||||||
return redirect()->route('admin.nodes.view', [
|
return redirect()->route('admin.nodes.view', [
|
||||||
'id' => $node,
|
'id' => $node,
|
||||||
'tab' => 'tab_allocations'
|
'tab' => 'tab_allocation'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,6 +203,19 @@ class NodesController extends Controller
|
||||||
|
|
||||||
public function postAllocations(Request $request, $id)
|
public function postAllocations(Request $request, $id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'allocate_ip.*' => 'required|string',
|
||||||
|
'allocate_port.*' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return redirect()->route('admin.nodes.view', [
|
||||||
|
'id' => $id,
|
||||||
|
'tab' => 'tab_allocation'
|
||||||
|
])->withErrors($validator->errors())->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
$processedData = [];
|
$processedData = [];
|
||||||
foreach($request->input('allocate_ip') as $ip) {
|
foreach($request->input('allocate_ip') as $ip) {
|
||||||
if (!array_key_exists($ip, $processedData)) {
|
if (!array_key_exists($ip, $processedData)) {
|
||||||
|
@ -217,9 +235,6 @@ class NodesController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(empty($processedData)) {
|
|
||||||
throw new DisplayException('It seems that no data was passed to this function.');
|
|
||||||
}
|
|
||||||
$node = new NodeRepository;
|
$node = new NodeRepository;
|
||||||
$node->addAllocations($id, $processedData);
|
$node->addAllocations($id, $processedData);
|
||||||
Alert::success('Successfully added new allocations to this node.')->flash();
|
Alert::success('Successfully added new allocations to this node.')->flash();
|
||||||
|
|
|
@ -275,7 +275,7 @@
|
||||||
},
|
},
|
||||||
"docker": {
|
"docker": {
|
||||||
"socket": "/var/run/docker.sock",
|
"socket": "/var/run/docker.sock",
|
||||||
"autoupdate_images": false
|
"autoupdate_images": true
|
||||||
},
|
},
|
||||||
"sftp": {
|
"sftp": {
|
||||||
"path": "{{ $node->daemonBase }}",
|
"path": "{{ $node->daemonBase }}",
|
||||||
|
@ -318,8 +318,8 @@
|
||||||
<div class="input-group-btn">
|
<div class="input-group-btn">
|
||||||
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
|
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
<ul class="dropdown-menu dropdown-menu-right">
|
||||||
@foreach($allocations as $ip => $ports)
|
@foreach($allocation_ips as $allocation)
|
||||||
<li data-action="alloc_dropdown_val" data-value="{{ $ip }}"><a href="#">{{ $ip }}</a></li>
|
<li data-action="alloc_dropdown_val" data-value="{{ $allocation->ip }}"><a href="#">{{ $allocation->ip }}</a></li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -334,7 +334,7 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-muted"><small>Please enter a comma (<code>,</code>) after each port or port range.</small></p>
|
<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>
|
||||||
<input name="allocate_port[]" type="hidden" class="pillboxMain"/>
|
<input name="allocate_port[]" type="hidden" class="pillboxMain"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-1 col-xs-2" style="margin-left: -10px;">
|
<div class="form-group col-md-1 col-xs-2" style="margin-left: -10px;">
|
||||||
|
@ -468,12 +468,8 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<select class="form-control" name="ip">
|
<select class="form-control" name="ip">
|
||||||
<?php $displayed = []; ?>
|
@foreach($allocation_ips as $allocation)
|
||||||
@foreach($allocations as $allocation)
|
<option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option>
|
||||||
@if(!array_key_exists($allocation->ip, $displayed))
|
|
||||||
<option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option>
|
|
||||||
<?php $displayed[$allocation->ip] = true; ?>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue