Allow deleting default allocation and setting new default at the same time.
This commit is contained in:
parent
776220636b
commit
3acc7b338b
3 changed files with 27 additions and 18 deletions
|
@ -15,6 +15,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Deleting a server safely now continues even if the daemon reports a `HTTP/404` missing server error (requires `Daemon@0.4.0-beta.2.1`)
|
* Deleting a server safely now continues even if the daemon reports a `HTTP/404` missing server error (requires `Daemon@0.4.0-beta.2.1`)
|
||||||
|
* Changed behavior when modifying server allocation information. You can now remove the default allocation assuming you assing a new allocation at the same time. Reduces the number of steps to change the default allocation for a server.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Server listing and view in Admin CP now shows the SFTP username/Docker container name.
|
* Server listing and view in Admin CP now shows the SFTP username/Docker container name.
|
||||||
|
|
|
@ -518,23 +518,7 @@ class ServerRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
$newPorts = false;
|
$newPorts = false;
|
||||||
// Remove Assignments
|
$firstNewAllocation = null;
|
||||||
if (isset($data['remove_allocations'])) {
|
|
||||||
foreach ($data['remove_allocations'] as $allocation) {
|
|
||||||
// Can't remove the assigned IP/Port combo
|
|
||||||
if ((int) $allocation === $server->allocation_id) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$newPorts = true;
|
|
||||||
Models\Allocation::where('id', $allocation)->where('server_id', $server->id)->update([
|
|
||||||
'server_id' => null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$server->load('allocations');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add Assignments
|
// Add Assignments
|
||||||
if (isset($data['add_allocations'])) {
|
if (isset($data['add_allocations'])) {
|
||||||
foreach ($data['add_allocations'] as $allocation) {
|
foreach ($data['add_allocations'] as $allocation) {
|
||||||
|
@ -544,6 +528,7 @@ class ServerRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
$newPorts = true;
|
$newPorts = true;
|
||||||
|
$firstNewAllocation = (is_null($firstNewAllocation)) ? $model->id : $firstNewAllocation;
|
||||||
$model->update([
|
$model->update([
|
||||||
'server_id' => $server->id,
|
'server_id' => $server->id,
|
||||||
]);
|
]);
|
||||||
|
@ -552,6 +537,29 @@ class ServerRepository
|
||||||
$server->load('allocations');
|
$server->load('allocations');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove Assignments
|
||||||
|
if (isset($data['remove_allocations'])) {
|
||||||
|
foreach ($data['remove_allocations'] as $allocation) {
|
||||||
|
// Can't remove the assigned IP/Port combo
|
||||||
|
if ((int) $allocation === $server->allocation_id) {
|
||||||
|
// No New Allocation
|
||||||
|
if (is_null($firstNewAllocation)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// New Allocation, set as the default.
|
||||||
|
$server->allocation_id = $firstNewAllocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newPorts = true;
|
||||||
|
Models\Allocation::where('id', $allocation)->where('server_id', $server->id)->update([
|
||||||
|
'server_id' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$server->load('allocations');
|
||||||
|
}
|
||||||
|
|
||||||
if ($newPorts) {
|
if ($newPorts) {
|
||||||
$newBuild['ports|overwrite'] = $server->allocations->groupBy('ip')->map(function ($item) {
|
$newBuild['ports|overwrite'] = $server->allocations->groupBy('ip')->map(function ($item) {
|
||||||
return $item->pluck('port');
|
return $item->pluck('port');
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
<div>
|
<div>
|
||||||
<select name="remove_allocations[]" class="form-control" multiple id="pRemoveAllocations">
|
<select name="remove_allocations[]" class="form-control" multiple id="pRemoveAllocations">
|
||||||
@foreach ($assigned as $assignment)
|
@foreach ($assigned as $assignment)
|
||||||
<option value="{{ $assignment->id }}" @if($server->allocation_id === $assignment->id)disabled @endif>{{ $assignment->alias }}:{{ $assignment->port }}</option>
|
<option value="{{ $assignment->id }}">{{ $assignment->alias }}:{{ $assignment->port }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue