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

Add pack selection to view

This commit is contained in:
Dane Everitt 2016-11-27 14:30:44 -05:00
parent 9eb14614c2
commit 238f08f222
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 22 additions and 4 deletions

View File

@ -257,7 +257,7 @@ class ServersController extends Controller
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View * @return \Illuminate\Contracts\View\View
*/ */
public function postNewServerServiceVariables(Request $request) public function postNewServerOptionDetails(Request $request)
{ {
if(!$request->input('option')) { if(!$request->input('option')) {
@ -274,6 +274,7 @@ class ServersController extends Controller
->first(); ->first();
return response()->json([ return response()->json([
'packs' => Models\ServicePack::select('uuid', 'name', 'version')->where('option', $request->input('option'))->where('selectable', true)->get(),
'variables' => Models\ServiceVariables::where('option_id', $request->input('option'))->get(), 'variables' => Models\ServiceVariables::where('option_id', $request->input('option'))->get(),
'exec' => $option->executable, 'exec' => $option->executable,
'startup' => $option->startup 'startup' => $option->startup

View File

@ -146,8 +146,8 @@ class AdminRoutes {
'uses' => 'Admin\ServersController@postNewServerServiceOptions' 'uses' => 'Admin\ServersController@postNewServerServiceOptions'
]); ]);
$router->post('/new/service-variables', [ $router->post('/new/option-details', [
'uses' => 'Admin\ServersController@postNewServerServiceVariables' 'uses' => 'Admin\ServersController@postNewServerOptionDetails'
]); ]);
// End Assorted Page Helpers // End Assorted Page Helpers

View File

@ -201,6 +201,15 @@
<p class="text-muted"><small>Select the type of service that this server will be running.</small></p> <p class="text-muted"><small>Select the type of service that this server will be running.</small></p>
</div> </div>
</div> </div>
<div class="form-group col-md-12 hidden">
<label for="option" class="control-label">Service Pack</label>
<div>
<select name="pack" id="getPack" class="form-control">
<option disabled selected> -- Select a Service Pack</option>
</select>
<p class="text-muted"><small>Select the service pack that should be used for this server. This option can be changed later.</small></p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -392,6 +401,7 @@ $(document).ready(function () {
handleLoader('#load_services', true); handleLoader('#load_services', true);
$('#serviceOptions').slideUp(); $('#serviceOptions').slideUp();
$('#getOption').html('<option disabled selected> -- Select a Service Option</option>'); $('#getOption').html('<option disabled selected> -- Select a Service Option</option>');
$('#getPack').html('<option disabled selected> -- Select a Service Pack</option>');
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
@ -423,10 +433,11 @@ $(document).ready(function () {
handleLoader('#serviceOptions', true); handleLoader('#serviceOptions', true);
$('#serverVariables').html(''); $('#serverVariables').html('');
$('input[name="custom_image_name"]').val($(this).find(':selected').data('image')); $('input[name="custom_image_name"]').val($(this).find(':selected').data('image'));
$('#getPack').html('<option disabled selected> -- Select a Service Pack</option>');
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
url: '/admin/servers/new/service-variables', url: '/admin/servers/new/option-details',
headers: { headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}' 'X-CSRF-TOKEN': '{{ csrf_token() }}'
}, },
@ -436,6 +447,12 @@ $(document).ready(function () {
}).done(function (data) { }).done(function (data) {
$('#startupExec').html(data.exec); $('#startupExec').html(data.exec);
$('input[name="startup"]').val(data.startup); $('input[name="startup"]').val(data.startup);
$.each(data.packs, function (i, item) {
$('#getPack').append('<option value="' + item.uuid + '">' + item.name + ' (' + item.version + ')</option>');
});
$('#getPack').append('<option value="none">No Service Pack</option>').parent().parent().removeClass('hidden');
$.each(data.variables, function (i, item) { $.each(data.variables, function (i, item) {
var isRequired = (item.required === 1) ? '<span class="label label-primary">Required</span> ' : ''; var isRequired = (item.required === 1) ? '<span class="label label-primary">Required</span> ' : '';
var dataAppend = ' \ var dataAppend = ' \