Fix server image selection not... existing

This commit is contained in:
DaneEveritt 2022-05-13 22:09:20 -04:00
parent 3e1f70570b
commit 8791d681bc
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 10 additions and 9 deletions

View file

@ -82,12 +82,13 @@ $('#pEggId').on('change', function (event) {
let parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null); let parentChain = _.get(Pterodactyl.nests, $('#pNestId').val(), null);
let objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null); let objectChain = _.get(parentChain, 'eggs.' + $(this).val(), null);
const images = _.get(objectChain, 'docker_images', []) const images = _.get(objectChain, 'docker_images', {})
$('#pDefaultContainer').html(''); $('#pDefaultContainer').html('');
for (let i = 0; i < images.length; i++) { const keys = Object.keys(images);
for (let i = 0; i < keys.length; i++) {
let opt = document.createElement('option'); let opt = document.createElement('option');
opt.value = images[i]; opt.value = images[keys[i]];
opt.innerHTML = images[i]; opt.innerHTML = keys[i] + " (" + images[keys[i]] + ")";
$('#pDefaultContainer').append(opt); $('#pDefaultContainer').append(opt);
} }

View file

@ -118,15 +118,15 @@
var parentChain = _.get(Pterodactyl.nests, $("#pNestId").val()); var parentChain = _.get(Pterodactyl.nests, $("#pNestId").val());
var objectChain = _.get(parentChain, 'eggs.' + selectedEgg); var objectChain = _.get(parentChain, 'eggs.' + selectedEgg);
$('#setDefaultImage').html(_.get(objectChain, 'docker_images.0', 'undefined'));
const images = _.get(objectChain, 'docker_images', []) const images = _.get(objectChain, 'docker_images', [])
$('#pDockerImage').html(''); $('#pDockerImage').html('');
for (let i = 0; i < images.length; i++) { const keys = Object.keys(images);
for (let i = 0; i < keys.length; i++) {
let opt = document.createElement('option'); let opt = document.createElement('option');
opt.value = images[i]; opt.value = images[keys[i]];
opt.innerHTML = images[i]; opt.innerHTML = keys[i] + " (" + images[keys[i]] + ")";
if (objectChain.id === parseInt(Pterodactyl.server.egg_id) && Pterodactyl.server.image == opt.value) { if (objectChain.id === parseInt(Pterodactyl.server.egg_id) && Pterodactyl.server.image == opt.value) {
opt.checked = true opt.selected = true
} }
$('#pDockerImage').append(opt); $('#pDockerImage').append(opt);
} }