Improve logic handle auto-allocation of ports for a server

This commit is contained in:
Dane Everitt 2020-10-31 14:58:15 -07:00
parent 7638ffccde
commit c6bd7ff661
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
10 changed files with 201 additions and 79 deletions

View file

@ -2,10 +2,8 @@ import { Allocation } from '@/api/server/getServer';
import http from '@/api/http';
import { rawDataToServerAllocation } from '@/api/transformers';
export default (uuid: string): Promise<Allocation> => {
return new Promise((resolve, reject) => {
http.get(`/api/client/servers/${uuid}/network/allocations/new`)
.then(({ data }) => resolve(rawDataToServerAllocation(data)))
.catch(reject);
});
export default async (uuid: string): Promise<Allocation> => {
const { data } = await http.post(`/api/client/servers/${uuid}/network/allocations`);
return rawDataToServerAllocation(data);
};

View file

@ -114,24 +114,24 @@
<div class="form-group col-md-4">
<label class="control-label">Status</label>
<div>
<select class="form-control" name="allocation:enabled">
<select class="form-control" name="pterodactyl:client_features:allocations:enabled">
<option value="false">Disabled</option>
<option value="true" @if(old('allocation:enabled', config('allocation.enabled'))) selected @endif>Enabled</option>
<option value="true" @if(old('pterodactyl:client_features:allocations:enabled', config('pterodactyl.client_features.allocations.enabled'))) selected @endif>Enabled</option>
</select>
<p class="text-muted small">If enabled, the panel will attempt to auto create a new allocation in the range specified if there are no more allocations already created on the node.</p>
<p class="text-muted small">If enabled users will have the option to automatically create new allocations for their server via the frontend.</p>
</div>
</div>
<div class="form-group col-md-4">
<label class="control-label">Starting Port</label>
<div>
<input type="number" required class="form-control" name="pterodactyl:allocation:start" value="{{ old('pterodactyl:allocation:start', config('pterodactyl.allocation.start')) }}">
<input type="number" required class="form-control" name="pterodactyl:client_features:allocations:range_start" value="{{ old('pterodactyl:client_features:allocations:range_start', config('pterodactyl.client_features.allocations.range_start')) }}">
<p class="text-muted small">The starting port in the range that can be automatically allocated.</p>
</div>
</div>
<div class="form-group col-md-4">
<label class="control-label">Ending Port</label>
<div>
<input type="number" required class="form-control" name="pterodactyl:allocation:stop" value="{{ old('pterodactyl:allocation:stop', config('pterodactyl.allocation.stop')) }}">
<input type="number" required class="form-control" name="pterodactyl:client_features:allocations:range_end" value="{{ old('pterodactyl:client_features:allocations:range_end', config('pterodactyl.client_features.allocations.range_end')) }}">
<p class="text-muted small">The ending port in the range that can be automatically allocated.</p>
</div>
</div>