1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-10-27 04:12:28 +01:00

Fix bug listing allocations when making a new server.

closes #730
This commit is contained in:
Dane Everitt 2017-11-05 14:12:53 -06:00
parent 3b5e1fc7b1
commit ac2abd89e6
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
6 changed files with 9 additions and 31 deletions

View File

@ -9,6 +9,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* `[beta.1]` — Fixes bug that would prevent root admins from accessing servers they were not set as the owner of.
* `[beta.1]` — Fixes wrong URL redirect being provided when creating a subuser.
* `[beta.1]` — Fixes missing check in environment setup that would leave the Hashids salt empty.
* `[beta.1]` — Fixes bug preventing loading of allocations when trying to create a new server.
## v0.7.0-beta.1 (Derelict Dermodactylus)
### Added

View File

@ -60,10 +60,9 @@ interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterfa
public function getNodeServers($id);
/**
* Return a collection of nodes beloning to a specific location for use on frontend display.
* Return a collection of nodes for all locations to use in server creation UI.
*
* @param int $location
* @return mixed
*/
public function getNodesForLocation($location);
public function getNodesForServerCreation();
}

View File

@ -231,6 +231,7 @@ class ServersController extends Controller
$nests = $this->nestRepository->getWithEggs();
Javascript::put([
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
'nests' => $nests->map(function ($item) {
return array_merge($item->toArray(), [
'eggs' => $item->eggs->keyBy('id')->toArray(),
@ -262,17 +263,6 @@ class ServersController extends Controller
return redirect()->route('admin.servers.view', $server->id);
}
/**
* Returns a tree of all avaliable nodes in a given location.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Support\Collection
*/
public function nodes(Request $request)
{
return $this->nodeRepository->getNodesForLocation($request->input('location'));
}
/**
* Display the index when viewing a specific server.
*

View File

@ -129,9 +129,9 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
/**
* {@inheritdoc}
*/
public function getNodesForLocation($location)
public function getNodesForServerCreation()
{
$instance = $this->getBuilder()->with('allocations')->where('location_id', $location)->get();
$instance = $this->getBuilder()->with('allocations')->get();
return $instance->map(function ($item) {
$filtered = $item->allocations->where('server_id', null)->map(function ($map) {

View File

@ -29,7 +29,7 @@ $(document).ready(function() {
});
$('#pNodeId').select2({
placeholder: 'Select a Node',
});
}).change();
$('#pAllocation').select2({
placeholder: 'Select a Default Allocation',
});
@ -79,14 +79,6 @@ $(document).ready(function() {
});
});
function hideLoader() {
$('#allocationLoader').hide();
}
function showLoader() {
$('#allocationLoader').show();
}
var lastActiveBox = null;
$(document).on('click', function (event) {
if (lastActiveBox !== null) {
@ -97,12 +89,9 @@ $(document).on('click', function (event) {
lastActiveBox.addClass('box-primary');
});
var curentNode = null;
var NodeData = [];
$('#pNodeId').on('change', function (event) {
$('#pNodeId').on('change', function () {
currentNode = $(this).val();
$.each(NodeData, function (i, v) {
$.each(Pterodactyl.nodeData, function (i, v) {
if (v.id == currentNode) {
$('#pAllocation').html('').select2({
data: v.allocations,

View File

@ -95,7 +95,6 @@ Route::group(['prefix' => 'servers'], function () {
Route::get('/view/{server}/delete', 'ServersController@viewDelete')->name('admin.servers.view.delete');
Route::post('/new', 'ServersController@store');
Route::post('/new/nodes', 'ServersController@nodes')->name('admin.servers.new.nodes');
Route::post('/view/{server}/build', 'ServersController@updateBuild');
Route::post('/view/{server}/startup', 'ServersController@saveStartup');
Route::post('/view/{server}/database', 'ServersController@newDatabase');