forked from Alex/Pterodactyl-Panel
Persist service variables
This commit is contained in:
parent
dec6868a55
commit
a7dab69711
@ -101,8 +101,11 @@ $('#pEggId').on('change', function (event) {
|
||||
),
|
||||
});
|
||||
|
||||
const variableIds = {};
|
||||
$('#appendVariablesTo').html('');
|
||||
$.each(_.get(objectChain, 'variables', []), function (i, item) {
|
||||
variableIds[item.env_variable] = 'var_ref_' + item.id;
|
||||
|
||||
let isRequired = (item.required === 1) ? '<span class="label label-danger">Required</span> ' : '';
|
||||
let dataAppend = ' \
|
||||
<div class="form-group col-sm-6"> \
|
||||
@ -115,6 +118,10 @@ $('#pEggId').on('change', function (event) {
|
||||
';
|
||||
$('#appendVariablesTo').append(dataAppend);
|
||||
});
|
||||
|
||||
// If you receive a warning on this line, it should be fine to ignore. this function is
|
||||
// defined in "resources/views/admin/servers/new.blade.php" near the bottom of the file.
|
||||
serviceVariablesUpdated($('#pEggId').val(), variableIds);
|
||||
});
|
||||
|
||||
$('#pAllocation').on('change', function () {
|
||||
|
@ -309,11 +309,31 @@
|
||||
@section('footer-scripts')
|
||||
@parent
|
||||
{!! Theme::js('vendor/lodash/lodash.js') !!}
|
||||
|
||||
<script type="application/javascript">
|
||||
// Persist 'Service Variables'
|
||||
function serviceVariablesUpdated(eggId, ids) {
|
||||
@if (old('egg_id'))
|
||||
// Check if the egg id matches.
|
||||
if (eggId != '{{ old('egg_id') }}') {
|
||||
return;
|
||||
}
|
||||
|
||||
@if (old('environment'))
|
||||
@foreach (old('environment') as $key => $value)
|
||||
$('#' + ids['{{ $key }}']).val('{{ $value }}');
|
||||
@endforeach
|
||||
@endif
|
||||
@endif
|
||||
}
|
||||
// END Persist 'Service Variables'
|
||||
</script>
|
||||
|
||||
{!! Theme::js('js/admin/new-server.js') !!}
|
||||
|
||||
<script type="application/javascript">
|
||||
$(document).ready(function() {
|
||||
<!-- Persist 'Server Owner' select2 -->
|
||||
// Persist 'Server Owner' select2
|
||||
@if (old('owner_id'))
|
||||
$.ajax({
|
||||
url: '/admin/users/accounts.json?user_id={{ old('owner_id') }}',
|
||||
@ -324,19 +344,19 @@
|
||||
@else
|
||||
initUserIdSelect();
|
||||
@endif
|
||||
<!-- END Persist 'Server Owner' select2 -->
|
||||
// END Persist 'Server Owner' select2
|
||||
|
||||
<!-- Persist 'Node' select2 -->
|
||||
// Persist 'Node' select2
|
||||
@if (old('node_id'))
|
||||
$('#pNodeId').val('{{ old('node_id') }}').change();
|
||||
|
||||
<!-- Persist 'Default Allocation' select2 -->
|
||||
// Persist 'Default Allocation' select2
|
||||
@if (old('allocation_id'))
|
||||
$('#pAllocation').val('{{ old('allocation_id') }}').change();
|
||||
@endif
|
||||
<!-- END Persist 'Default Allocation' select2 -->
|
||||
// END Persist 'Default Allocation' select2
|
||||
|
||||
<!-- Persist 'Additional Allocations' select2 -->
|
||||
// Persist 'Additional Allocations' select2
|
||||
@if (old('allocation_additional'))
|
||||
const additional_allocations = [];
|
||||
|
||||
@ -346,27 +366,27 @@
|
||||
|
||||
$('#pAllocationAdditional').val(additional_allocations).change();
|
||||
@endif
|
||||
<!-- END Persist 'Additional Allocations' select2 -->
|
||||
// END Persist 'Additional Allocations' select2
|
||||
@endif
|
||||
<!-- END Persist 'Node' select2 -->
|
||||
// END Persist 'Node' select2
|
||||
|
||||
<!-- Persist 'Nest' select2 -->
|
||||
// Persist 'Nest' select2
|
||||
@if (old('nest_id'))
|
||||
$('#pNestId').val('{{ old('nest_id') }}').change();
|
||||
|
||||
<!-- Persist 'Egg' select2 -->
|
||||
// Persist 'Egg' select2
|
||||
@if (old('egg_id'))
|
||||
$('#pEggId').val('{{ old('egg_id') }}').change();
|
||||
@endif
|
||||
<!-- END Persist 'Egg' select2 -->
|
||||
// END Persist 'Egg' select2
|
||||
|
||||
<!-- Persist 'Data Pack' select2 -->
|
||||
// Persist 'Data Pack' select2
|
||||
@if (old('pack_id'))
|
||||
$('#pPackId').val('{{ old('pack_id') }}').change();
|
||||
@endif
|
||||
<!-- END Persist 'Data Pack' select2 -->
|
||||
// END Persist 'Data Pack' select2
|
||||
@endif
|
||||
<!-- END Persist 'Nest' select2 -->
|
||||
// END Persist 'Nest' select2
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
Loading…
Reference in New Issue
Block a user