Skip to content

Commit fb96d94

Browse files
committed
Prevent primary allocation from being an additional allocation at the same time when creating a server
1 parent 25f18dc commit fb96d94

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

public/themes/pterodactyl/js/admin/new-server.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,23 @@ $(document).ready(function() {
2121
$('#pNestId').select2({
2222
placeholder: 'Select a Nest',
2323
}).change();
24+
2425
$('#pEggId').select2({
2526
placeholder: 'Select a Nest Egg',
2627
});
28+
2729
$('#pPackId').select2({
2830
placeholder: 'Select a Service Pack',
2931
});
32+
3033
$('#pNodeId').select2({
3134
placeholder: 'Select a Node',
3235
}).change();
36+
3337
$('#pAllocation').select2({
3438
placeholder: 'Select a Default Allocation',
3539
});
40+
3641
$('#pAllocationAdditional').select2({
3742
placeholder: 'Select Additional Allocations',
3843
});
@@ -97,10 +102,8 @@ $('#pNodeId').on('change', function () {
97102
data: v.allocations,
98103
placeholder: 'Select a Default Allocation',
99104
});
100-
$('#pAllocationAdditional').html('').select2({
101-
data: v.allocations,
102-
placeholder: 'Select Additional Allocations',
103-
})
105+
106+
updateAdditionalAllocations();
104107
}
105108
});
106109
});
@@ -154,3 +157,31 @@ $('#pEggId').on('change', function (event) {
154157
$('#appendVariablesTo').append(dataAppend);
155158
});
156159
});
160+
161+
$('#pAllocation').on('change', function () {
162+
updateAdditionalAllocations();
163+
});
164+
165+
function updateAdditionalAllocations() {
166+
let currentAllocation = $('#pAllocation').val();
167+
let currentNode = $('#pNodeId').val();
168+
169+
$.each(Pterodactyl.nodeData, function (i, v) {
170+
if (v.id == currentNode) {
171+
let allocations = [];
172+
173+
for (let i = 0; i < v.allocations.length; i++) {
174+
const allocation = v.allocations[i];
175+
176+
if (allocation.id != currentAllocation) {
177+
allocations.push(allocation);
178+
}
179+
}
180+
181+
$('#pAllocationAdditional').html('').select2({
182+
data: allocations,
183+
placeholder: 'Select Additional Allocations',
184+
});
185+
}
186+
});
187+
}

0 commit comments

Comments
 (0)