$(document).ready(function() { $('#pEggId').select2({ placeholder: 'Select an Egg', }).change(); $('#pPackId').select2({ placeholder: 'Select a Service Pack', }); $('#pNodeId').select2({ placeholder: 'Select a Node', }).change(); $('#pAllocation').select2({ placeholder: 'Select a Default Allocation', }); $('#pAllocationAdditional').select2({ placeholder: 'Select Additional Allocations', }); }); let lastActiveBox = null; $(document).on('click', function (event) { if (lastActiveBox !== null) { lastActiveBox.removeClass('box-primary'); } lastActiveBox = $(event.target).closest('.box'); lastActiveBox.addClass('box-primary'); }); $('#pNodeId').on('change', function () { currentNode = $(this).val(); $.each(Panel.nodeData, function (i, v) { if (v.id == currentNode) { $('#pAllocation').html('').select2({ data: v.allocations, placeholder: 'Select a Default Allocation', }); updateAdditionalAllocations(); } }); }); $('#pEggId').on('change', function (event) { let objectChain = _.get(Panel.eggs, $('#pEggId').val(), null); const images = _.get(objectChain, 'docker_images', {}) $('#pDefaultContainer').html(''); const keys = Object.keys(images); for (let i = 0; i < keys.length; i++) { let opt = document.createElement('option'); opt.value = images[keys[i]]; opt.innerHTML = keys[i] + " (" + images[keys[i]] + ")"; $('#pDefaultContainer').append(opt); } $('#pStartup').val(_.get(objectChain, 'startup')); $('#pPackId').html('').select2({ data: [{ id: 0, text: 'No Service Pack' }].concat( $.map(_.get(objectChain, 'packs', []), function (item, i) { return { id: item.id, text: item.name + ' (' + item.version + ')', }; }) ), }); const variableIds = {}; $('#appendVariablesTo').html(''); $.each(_.get(objectChain, 'variables', []), function (i, item) { variableIds[item.env_variable] = 'var_ref_' + item.id; let isRequired = (item.required === 1) ? 'Required ' : ''; let dataAppend = ' \
' + item.description + '
\
Access in Startup: {{' + item.env_variable + '}}
\
Validation Rules: ' + item.rules + '