Skip to content

Commit ac2abd8

Browse files
committed
Fix bug listing allocations when making a new server.
closes pterodactyl#730
1 parent 3b5e1fc commit ac2abd8

File tree

6 files changed

+9
-31
lines changed

6 files changed

+9
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
99
* `[beta.1]` — Fixes bug that would prevent root admins from accessing servers they were not set as the owner of.
1010
* `[beta.1]` — Fixes wrong URL redirect being provided when creating a subuser.
1111
* `[beta.1]` — Fixes missing check in environment setup that would leave the Hashids salt empty.
12+
* `[beta.1]` — Fixes bug preventing loading of allocations when trying to create a new server.
1213

1314
## v0.7.0-beta.1 (Derelict Dermodactylus)
1415
### Added

app/Contracts/Repository/NodeRepositoryInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ public function getNodeAllocations($id);
6060
public function getNodeServers($id);
6161

6262
/**
63-
* Return a collection of nodes beloning to a specific location for use on frontend display.
63+
* Return a collection of nodes for all locations to use in server creation UI.
6464
*
65-
* @param int $location
6665
* @return mixed
6766
*/
68-
public function getNodesForLocation($location);
67+
public function getNodesForServerCreation();
6968
}

app/Http/Controllers/Admin/ServersController.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public function create()
231231
$nests = $this->nestRepository->getWithEggs();
232232

233233
Javascript::put([
234+
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
234235
'nests' => $nests->map(function ($item) {
235236
return array_merge($item->toArray(), [
236237
'eggs' => $item->eggs->keyBy('id')->toArray(),
@@ -262,17 +263,6 @@ public function store(ServerFormRequest $request)
262263
return redirect()->route('admin.servers.view', $server->id);
263264
}
264265

265-
/**
266-
* Returns a tree of all avaliable nodes in a given location.
267-
*
268-
* @param \Illuminate\Http\Request $request
269-
* @return \Illuminate\Support\Collection
270-
*/
271-
public function nodes(Request $request)
272-
{
273-
return $this->nodeRepository->getNodesForLocation($request->input('location'));
274-
}
275-
276266
/**
277267
* Display the index when viewing a specific server.
278268
*

app/Repositories/Eloquent/NodeRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public function getNodeServers($id)
129129
/**
130130
* {@inheritdoc}
131131
*/
132-
public function getNodesForLocation($location)
132+
public function getNodesForServerCreation()
133133
{
134-
$instance = $this->getBuilder()->with('allocations')->where('location_id', $location)->get();
134+
$instance = $this->getBuilder()->with('allocations')->get();
135135

136136
return $instance->map(function ($item) {
137137
$filtered = $item->allocations->where('server_id', null)->map(function ($map) {

public/themes/pterodactyl/js/admin/new-server.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(document).ready(function() {
2929
});
3030
$('#pNodeId').select2({
3131
placeholder: 'Select a Node',
32-
});
32+
}).change();
3333
$('#pAllocation').select2({
3434
placeholder: 'Select a Default Allocation',
3535
});
@@ -79,14 +79,6 @@ $(document).ready(function() {
7979
});
8080
});
8181

82-
function hideLoader() {
83-
$('#allocationLoader').hide();
84-
}
85-
86-
function showLoader() {
87-
$('#allocationLoader').show();
88-
}
89-
9082
var lastActiveBox = null;
9183
$(document).on('click', function (event) {
9284
if (lastActiveBox !== null) {
@@ -97,12 +89,9 @@ $(document).on('click', function (event) {
9789
lastActiveBox.addClass('box-primary');
9890
});
9991

100-
var curentNode = null;
101-
var NodeData = [];
102-
103-
$('#pNodeId').on('change', function (event) {
92+
$('#pNodeId').on('change', function () {
10493
currentNode = $(this).val();
105-
$.each(NodeData, function (i, v) {
94+
$.each(Pterodactyl.nodeData, function (i, v) {
10695
if (v.id == currentNode) {
10796
$('#pAllocation').html('').select2({
10897
data: v.allocations,

routes/admin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
Route::get('/view/{server}/delete', 'ServersController@viewDelete')->name('admin.servers.view.delete');
9696

9797
Route::post('/new', 'ServersController@store');
98-
Route::post('/new/nodes', 'ServersController@nodes')->name('admin.servers.new.nodes');
9998
Route::post('/view/{server}/build', 'ServersController@updateBuild');
10099
Route::post('/view/{server}/startup', 'ServersController@saveStartup');
101100
Route::post('/view/{server}/database', 'ServersController@newDatabase');

0 commit comments

Comments
 (0)