1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 17:12:30 +01:00

Fix allocation behavior, closes #712

This commit is contained in:
Dane Everitt 2018-01-08 22:12:19 -06:00
parent 036bea2b94
commit 22511c8e24
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
5 changed files with 34 additions and 5 deletions

View File

@ -11,10 +11,14 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run. * `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run.
* `[beta.3]` — Fixes validation error when trying to use 'None' as the 'Copy Script From' option for an egg script. * `[beta.3]` — Fixes validation error when trying to use 'None' as the 'Copy Script From' option for an egg script.
* Fixes a design bug in the database that prevented the storage of negative numbers, thus preventing a server from being assigned unlimited swap. * Fixes a design bug in the database that prevented the storage of negative numbers, thus preventing a server from being assigned unlimited swap.
* Fixes a bug where the 'Assign New Allocations' box would only show IPs that were present in the current pagination block.
### Added ### Added
* Nest and Egg listings now show the associated ID in order to make API requests easier. * Nest and Egg listings now show the associated ID in order to make API requests easier.
### Changed
* Changed behavior of allocation IP Address/Ports box to automatically store the value entered if a user unfocuses the field without hitting space.
## v0.7.0-beta.3 (Derelict Dermodactylus) ## v0.7.0-beta.3 (Derelict Dermodactylus)
### Fixed ### Fixed
* `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances. * `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances.

View File

@ -22,4 +22,12 @@ interface AllocationRepositoryInterface extends RepositoryInterface
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
public function getAllocationsForNode(int $node): Collection; public function getAllocationsForNode(int $node): Collection;
/**
* Return all of the unique IPs that exist for a given node.
*
* @param int $node
* @return \Illuminate\Support\Collection
*/
public function getUniqueAllocationIpsForNode(int $node): Collection;
} }

View File

@ -210,15 +210,16 @@ class NodesController extends Controller
* *
* @param \Pterodactyl\Models\Node $node * @param \Pterodactyl\Models\Node $node
* @return \Illuminate\View\View * @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function viewAllocation(Node $node) public function viewAllocation(Node $node)
{ {
$this->repository->loadNodeAllocations($node); $this->repository->loadNodeAllocations($node);
Javascript::put(['node' => collect($node)->only(['id'])]); Javascript::put(['node' => collect($node)->only(['id'])]);
return view('admin.nodes.view.allocation', ['node' => $node]); return view('admin.nodes.view.allocation', [
'allocations' => $this->allocationRepository->setColumns(['ip'])->getUniqueAllocationIpsForNode($node->id),
'node' => $node,
]);
} }
/** /**

View File

@ -40,4 +40,18 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
{ {
return $this->getBuilder()->where('node_id', $node)->get($this->getColumns()); return $this->getBuilder()->where('node_id', $node)->get($this->getColumns());
} }
/**
* Return all of the unique IPs that exist for a given node.
*
* @param int $node
* @return \Illuminate\Support\Collection
*/
public function getUniqueAllocationIpsForNode(int $node): Collection
{
return $this->getBuilder()->where('node_id', $node)
->groupBy('ip')
->orderByRaw('INET_ATON(ip) ASC')
->get($this->getColumns());
}
} }

View File

@ -90,7 +90,7 @@
<label for="pAllocationIP" class="control-label">IP Address</label> <label for="pAllocationIP" class="control-label">IP Address</label>
<div> <div>
<select class="form-control" name="allocation_ip" id="pAllocationIP" multiple> <select class="form-control" name="allocation_ip" id="pAllocationIP" multiple>
@foreach($node->allocations->unique('ip')->values()->all() as $allocation) @foreach($allocations as $allocation)
<option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option> <option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option>
@endforeach @endforeach
</select> </select>
@ -132,7 +132,7 @@
<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">
@foreach($node->allocations->unique('ip')->values()->all() as $allocation) @foreach($allocations as $allocation)
<option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option> <option value="{{ $allocation->ip }}">{{ $allocation->ip }}</option>
@endforeach @endforeach
</select> </select>
@ -156,10 +156,12 @@
$('#pAllocationIP').select2({ $('#pAllocationIP').select2({
tags: true, tags: true,
maximumSelectionLength: 1, maximumSelectionLength: 1,
selectOnClose: true,
tokenSeparators: [',', ' '], tokenSeparators: [',', ' '],
}); });
$('#pAllocationPorts').select2({ $('#pAllocationPorts').select2({
tags: true, tags: true,
selectOnClose: true,
tokenSeparators: [',', ' '], tokenSeparators: [',', ' '],
}); });
$('button[data-action="deallocate"]').click(function (event) { $('button[data-action="deallocate"]').click(function (event) {