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 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 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 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) ## v0.7.0-beta.1 (Derelict Dermodactylus)
### Added ### Added

View file

@ -60,10 +60,9 @@ interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterfa
public function getNodeServers($id); 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 * @return mixed
*/ */
public function getNodesForLocation($location); public function getNodesForServerCreation();
} }

View file

@ -231,6 +231,7 @@ class ServersController extends Controller
$nests = $this->nestRepository->getWithEggs(); $nests = $this->nestRepository->getWithEggs();
Javascript::put([ Javascript::put([
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
'nests' => $nests->map(function ($item) { 'nests' => $nests->map(function ($item) {
return array_merge($item->toArray(), [ return array_merge($item->toArray(), [
'eggs' => $item->eggs->keyBy('id')->toArray(), 'eggs' => $item->eggs->keyBy('id')->toArray(),
@ -262,17 +263,6 @@ class ServersController extends Controller
return redirect()->route('admin.servers.view', $server->id); 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. * Display the index when viewing a specific server.
* *

View file

@ -129,9 +129,9 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
/** /**
* {@inheritdoc} * {@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) { return $instance->map(function ($item) {
$filtered = $item->allocations->where('server_id', null)->map(function ($map) { $filtered = $item->allocations->where('server_id', null)->map(function ($map) {

View file

@ -29,7 +29,7 @@ $(document).ready(function() {
}); });
$('#pNodeId').select2({ $('#pNodeId').select2({
placeholder: 'Select a Node', placeholder: 'Select a Node',
}); }).change();
$('#pAllocation').select2({ $('#pAllocation').select2({
placeholder: 'Select a Default Allocation', placeholder: 'Select a Default Allocation',
}); });
@ -79,14 +79,6 @@ $(document).ready(function() {
}); });
}); });
function hideLoader() {
$('#allocationLoader').hide();
}
function showLoader() {
$('#allocationLoader').show();
}
var lastActiveBox = null; var lastActiveBox = null;
$(document).on('click', function (event) { $(document).on('click', function (event) {
if (lastActiveBox !== null) { if (lastActiveBox !== null) {
@ -97,12 +89,9 @@ $(document).on('click', function (event) {
lastActiveBox.addClass('box-primary'); lastActiveBox.addClass('box-primary');
}); });
var curentNode = null; $('#pNodeId').on('change', function () {
var NodeData = [];
$('#pNodeId').on('change', function (event) {
currentNode = $(this).val(); currentNode = $(this).val();
$.each(NodeData, function (i, v) { $.each(Pterodactyl.nodeData, function (i, v) {
if (v.id == currentNode) { if (v.id == currentNode) {
$('#pAllocation').html('').select2({ $('#pAllocation').html('').select2({
data: v.allocations, 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::get('/view/{server}/delete', 'ServersController@viewDelete')->name('admin.servers.view.delete');
Route::post('/new', 'ServersController@store'); 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}/build', 'ServersController@updateBuild');
Route::post('/view/{server}/startup', 'ServersController@saveStartup'); Route::post('/view/{server}/startup', 'ServersController@saveStartup');
Route::post('/view/{server}/database', 'ServersController@newDatabase'); Route::post('/view/{server}/database', 'ServersController@newDatabase');