Fix allocation behavior, closes #712
This commit is contained in:
parent
036bea2b94
commit
22511c8e24
5 changed files with 34 additions and 5 deletions
|
@ -22,4 +22,12 @@ interface AllocationRepositoryInterface extends RepositoryInterface
|
|||
* @return \Illuminate\Support\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;
|
||||
}
|
||||
|
|
|
@ -210,15 +210,16 @@ class NodesController extends Controller
|
|||
*
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function viewAllocation(Node $node)
|
||||
{
|
||||
$this->repository->loadNodeAllocations($node);
|
||||
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,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,4 +40,18 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
|
|||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue