Skip to content

Commit c9e874d

Browse files
committed
Fix UI error changing a server's service, closes pterodactyl#1019
1 parent 36837df commit c9e874d

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ This file is a running track of new features and fixes to each version of the pa
33

44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

6+
## v0.7.6 (Derelict Dermodactylus)
7+
### Fixed
8+
* Fixes a UI error when attempting to change the default Nest and Egg for an existing server.
9+
610
## v0.7.5 (Derelict Dermodactylus)
711
### Fixed
812
* Fixes application API keys being created as a client API key.

resources/themes/pterodactyl/admin/servers/view/startup.blade.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,28 @@
134134
{!! Theme::js('vendor/lodash/lodash.js') !!}
135135
<script>
136136
$(document).ready(function () {
137-
$('#pNestId').select2({placeholder: 'Select a Nest'}).change();
138-
$('#pEggId').select2({placeholder: 'Select a Nest Egg'});
139137
$('#pPackId').select2({placeholder: 'Select a Service Pack'});
140-
});
141-
</script>
142-
<script>
143-
$('#pNestId').on('change', function (event) {
138+
$('#pNestId').select2({placeholder: 'Select a Nest'}).on('change', function () {
144139
$('#pEggId').html('').select2({
145140
data: $.map(_.get(Pterodactyl.nests, $(this).val() + '.eggs', []), function (item) {
146141
return {
147142
id: item.id,
148143
text: item.name,
149144
};
150145
}),
151-
}).val(Pterodactyl.server.egg_id).change();
152-
});
146+
});
153147
154-
$('#pEggId').on('change', function (event) {
155-
var parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null);
156-
var objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null);
148+
if (_.isObject(_.get(Pterodactyl.nests, $(this).val() + '.eggs.' + Pterodactyl.server.egg_id))) {
149+
$('#pEggId').val(Pterodactyl.server.egg_id);
150+
}
151+
152+
$('#pEggId').change();
153+
}).change();
154+
155+
$('#pEggId').select2({placeholder: 'Select a Nest Egg'}).on('change', function () {
156+
var selectedEgg = _.isNull($(this).val()) ? $(this).find('option').first().val() : $(this).val();
157+
var parentChain = _.get(Pterodactyl.nests, $("#pNestId").val());
158+
var objectChain = _.get(parentChain, 'eggs.' + selectedEgg);
157159
158160
$('#setDefaultImage').html(_.get(objectChain, 'docker_image', 'undefined'));
159161
$('#pDockerImage').val(_.get(objectChain, 'docker_image', 'undefined'));
@@ -168,7 +170,7 @@
168170
}
169171
170172
$('#pPackId').html('').select2({
171-
data: [{ id: '0', text: 'No Service Pack' }].concat(
173+
data: [{id: '0', text: 'No Service Pack'}].concat(
172174
$.map(_.get(objectChain, 'packs', []), function (item, i) {
173175
return {
174176
id: item.id,
@@ -202,9 +204,9 @@
202204
</div> \
203205
</div> \
204206
</div>';
205-
$('#appendVariablesTo').append(dataAppend);
206-
$('#appendVariablesTo').find('#egg_variable_' + item.env_variable).val(setValue);
207+
$('#appendVariablesTo').append(dataAppend).find('#egg_variable_' + item.env_variable).val(setValue);
207208
});
208209
});
210+
});
209211
</script>
210212
@endsection

0 commit comments

Comments
 (0)