Skip to content

Commit 0c21d40

Browse files
lancepiochDaneEveritt
authored andcommitted
Combine Locations and Nodes on Create Server page (pterodactyl#641)
1 parent 2f696dd commit 0c21d40

File tree

3 files changed

+14
-36
lines changed

3 files changed

+14
-36
lines changed

app/Models/Server.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Server extends Model implements CleansAttributes, ValidableContract
8181
'disk' => 'required',
8282
'service_id' => 'required',
8383
'option_id' => 'required',
84+
'node_id' => 'required',
85+
'allocation_id' => 'required',
8486
'pack_id' => 'sometimes',
8587
'auto_deploy' => 'sometimes',
8688
'custom_id' => 'sometimes',

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ $(document).ready(function() {
2727
$('#pPackId').select2({
2828
placeholder: 'Select a Service Pack',
2929
});
30-
$('#pLocationId').select2({
31-
placeholder: 'Select a Location',
32-
}).change();
3330
$('#pNodeId').select2({
3431
placeholder: 'Select a Node',
3532
});
@@ -100,29 +97,9 @@ $(document).on('click', function (event) {
10097
lastActiveBox.addClass('box-primary');
10198
});
10299

103-
var currentLocation = null;
104100
var curentNode = null;
105101
var NodeData = [];
106102

107-
$('#pLocationId').on('change', function (event) {
108-
showLoader();
109-
currentLocation = $(this).val();
110-
currentNode = null;
111-
112-
$.ajax({
113-
method: 'POST',
114-
url: Router.route('admin.servers.new.nodes'),
115-
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') },
116-
data: { location: currentLocation },
117-
}).done(function (data) {
118-
NodeData = data;
119-
$('#pNodeId').html('').select2({data: data}).change();
120-
}).fail(function (jqXHR) {
121-
cosole.error(jqXHR);
122-
currentLocation = null;
123-
}).always(hideLoader);
124-
});
125-
126103
$('#pNodeId').on('change', function (event) {
127104
currentNode = $(this).val();
128105
$.each(NodeData, function (i, v) {

resources/themes/pterodactyl/admin/servers/new.blade.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,28 @@
7878
</div>
7979
<div class="box-body row">
8080
<div class="form-group col-sm-4">
81-
<label for="pLocationId">Location</label>
82-
<select name="location_id" id="pLocationId" class="form-control">
81+
<label for="pNodeId">Node</label>
82+
<select name="node_id" id="pNodeId" class="form-control">
8383
@foreach($locations as $location)
84-
<option value="{{ $location->id }}"
85-
@if($location->id === old('location_id'))
86-
selected
87-
@endif
88-
>{{ $location->long }} ({{ $location->short }})</option>
84+
<optgroup label="{{ $location->long }} ({{ $location->short }})">
85+
@foreach($location->nodes as $node)
86+
87+
<option value="{{ $node->id }}"
88+
@if($location->id === old('location_id')) selected @endif
89+
>{{ $node->name }}</option>
90+
91+
@endforeach
92+
</optgroup>
8993
@endforeach
9094
</select>
91-
<p class="small text-muted no-margin">The location in which this server will be deployed.</p>
92-
</div>
93-
<div class="form-group col-sm-4">
94-
<label for="pNodeId">Node</label>
95-
<select name="node_id" id="pNodeId" class="form-control"></select>
9695
<p class="small text-muted no-margin">The node which this server will be deployed to.</p>
9796
</div>
9897
<div class="form-group col-sm-4">
9998
<label for="pAllocation">Default Allocation</label>
10099
<select name="allocation_id" id="pAllocation" class="form-control"></select>
101100
<p class="small text-muted no-margin">The main allocation that will be assigned to this server.</p>
102101
</div>
103-
<div class="form-group col-sm-12">
102+
<div class="form-group col-sm-4">
104103
<label for="pAllocationAdditional">Additional Allocation(s)</label>
105104
<select name="allocation_additional[]" id="pAllocationAdditional" class="form-control" multiple></select>
106105
<p class="small text-muted no-margin">Additional allocations to assign to this server on creation.</p>

0 commit comments

Comments
 (0)