Compare commits

...

4 commits

Author SHA1 Message Date
Lance Pioch
d3e88f23f9 php-cs-fixer 2022-11-08 21:38:12 -05:00
Lance Pioch
527f3cc457 Update wording 2022-11-06 12:15:15 -05:00
Lance Pioch
f2215437a5 Add server transfer cancellation 2022-11-06 12:15:06 -05:00
Lance Pioch
aa40521055 Simplify doc blocks 2022-11-05 23:04:54 -04:00
5 changed files with 108 additions and 49 deletions

View file

@ -79,6 +79,25 @@ class ServerTransferController extends Controller
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Cancels the specified server's transfer.
*/
public function cancel(Request $request, Server $server): RedirectResponse
{
if (!$transfer = $server->transfer) {
$this->alert->danger(trans('admin/server.alerts.transfer_does_not_exist'))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);
}
$transfer->successful = true;
$transfer->save();
$this->alert->success(trans('admin/server.alerts.transfer_cancelled'))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Assigns the specified allocations to the specified server.
*/

View file

@ -2,9 +2,12 @@
namespace Pterodactyl\Models;
use Illuminate\Support\Carbon;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause;
use Znck\Eloquent\Traits\BelongsToThrough;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -40,65 +43,65 @@ use Pterodactyl\Exceptions\Http\Server\ServerStateConflictException;
* @property int|null $allocation_limit
* @property int|null $database_limit
* @property int $backup_limit
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $installed_at
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\ActivityLog[] $activity
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $installed_at
* @property Collection|ActivityLog[] $activity
* @property int|null $activity_count
* @property \Pterodactyl\Models\Allocation|null $allocation
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Allocation[] $allocations
* @property Allocation|null $allocation
* @property Collection|Allocation[] $allocations
* @property int|null $allocations_count
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Backup[] $backups
* @property Collection|Backup[] $backups
* @property int|null $backups_count
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Database[] $databases
* @property Collection|Database[] $databases
* @property int|null $databases_count
* @property \Pterodactyl\Models\Egg|null $egg
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Mount[] $mounts
* @property Egg|null $egg
* @property Collection|Mount[] $mounts
* @property int|null $mounts_count
* @property \Pterodactyl\Models\Nest $nest
* @property \Pterodactyl\Models\Node $node
* @property Nest $nest
* @property Node $node
* @property \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
* @property int|null $notifications_count
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Schedule[] $schedules
* @property Collection|Schedule[] $schedules
* @property int|null $schedules_count
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Subuser[] $subusers
* @property Collection|Subuser[] $subusers
* @property int|null $subusers_count
* @property \Pterodactyl\Models\ServerTransfer|null $transfer
* @property \Pterodactyl\Models\User $user
* @property \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\EggVariable[] $variables
* @property ServerTransfer|null $transfer
* @property User $user
* @property Collection|EggVariable[] $variables
* @property int|null $variables_count
*
* @method static \Database\Factories\ServerFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Builder|Server newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Server newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Server query()
* @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereAllocationLimit($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereBackupLimit($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereCpu($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereDatabaseLimit($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereDisk($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereEggId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereExternalId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereImage($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereIo($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereMemory($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereNestId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereNodeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereOomDisabled($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereOwnerId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereSkipScripts($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereStartup($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereSwap($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereThreads($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUuid($value)
* @method static \Illuminate\Database\Eloquent\Builder|Server whereUuidShort($value)
* @method static Builder|Server newModelQuery()
* @method static Builder|Server newQuery()
* @method static Builder|Server query()
* @method static Builder|Server whereAllocationId($value)
* @method static Builder|Server whereAllocationLimit($value)
* @method static Builder|Server whereBackupLimit($value)
* @method static Builder|Server whereCpu($value)
* @method static Builder|Server whereCreatedAt($value)
* @method static Builder|Server whereDatabaseLimit($value)
* @method static Builder|Server whereDescription($value)
* @method static Builder|Server whereDisk($value)
* @method static Builder|Server whereEggId($value)
* @method static Builder|Server whereExternalId($value)
* @method static Builder|Server whereId($value)
* @method static Builder|Server whereImage($value)
* @method static Builder|Server whereIo($value)
* @method static Builder|Server whereMemory($value)
* @method static Builder|Server whereName($value)
* @method static Builder|Server whereNestId($value)
* @method static Builder|Server whereNodeId($value)
* @method static Builder|Server whereOomDisabled($value)
* @method static Builder|Server whereOwnerId($value)
* @method static Builder|Server whereSkipScripts($value)
* @method static Builder|Server whereStartup($value)
* @method static Builder|Server whereStatus($value)
* @method static Builder|Server whereSwap($value)
* @method static Builder|Server whereThreads($value)
* @method static Builder|Server whereUpdatedAt($value)
* @method static Builder|Server whereUuid($value)
* @method static Builder|Server whereUuidShort($value)
*
* @mixin \Eloquent
*/

View file

@ -22,6 +22,8 @@ return [
'node_required' => 'You must have at least one node configured before you can add a server to this panel.',
'transfer_nodes_required' => 'You must have at least two nodes configured before you can transfer servers.',
'transfer_started' => 'Server transfer has been started.',
'transfer_cancelled' => 'Server transfer has been cancelled.',
'transfer_not_viable' => 'The node you selected does not have the required disk space or memory available to accommodate this server.',
'transfer_does_not_exist' => 'There is no current transfers for this server.',
],
];

View file

@ -110,7 +110,7 @@
<button class="btn btn-success" data-toggle="modal" data-target="#transferServerModal">Transfer Server</button>
@else
<button class="btn btn-success disabled">Transfer Server</button>
<p style="padding-top: 1rem;">Transferring a server requires more than one node to be configured on your panel.</p>
<p style="padding-top: 1rem; font-style: italic;">You currently can't transfer any servers because you don't have at least a second node that's configured in your panel.</p>
@endif
</div>
</div>
@ -129,7 +129,11 @@
</div>
<div class="box-footer">
<button class="btn btn-success disabled">Transfer Server</button>
<button class="btn btn-success" data-toggle="modal" data-target="#cancelTransferModal">Cancel Transfer</button>
<p style="padding-top: 1rem; font-style: italic;">
<span style="font-weight: bold;">Warning</span>, only use this in cases of last resort such as a connection failure.
This may allow you to successfully transfer your server again.
</p>
</div>
</div>
</div>
@ -190,6 +194,36 @@
</div>
</div>
</div>
<div class="modal fade" id="cancelTransferModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="{{ route('admin.servers.view.manage.transfer.cancel', $server->id) }}" method="POST">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Cancel Transfer</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="form-group col-md-12">
This action will force the transfer to a successful state.
However, please try to allow some time for your transfer to finish normally.
This is a last resort action that can allow you to try to start the transfer again.
You will most likely need to manually reset the allocations for these servers.
</div>
</div>
</div>
<div class="modal-footer">
{!! csrf_field() !!}
<button type="button" class="btn btn-default btn-sm pull-left" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger btn-sm">Confirm</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@section('footer-scripts')

View file

@ -129,6 +129,7 @@ Route::group(['prefix' => 'servers'], function () {
Route::post('/view/{server:id}/manage/suspension', [Admin\ServersController::class, 'manageSuspension'])->name('admin.servers.view.manage.suspension');
Route::post('/view/{server:id}/manage/reinstall', [Admin\ServersController::class, 'reinstallServer'])->name('admin.servers.view.manage.reinstall');
Route::post('/view/{server:id}/manage/transfer', [Admin\Servers\ServerTransferController::class, 'transfer'])->name('admin.servers.view.manage.transfer');
Route::post('/view/{server:id}/manage/transfer/cancel', [Admin\Servers\ServerTransferController::class, 'cancel'])->name('admin.servers.view.manage.transfer.cancel');
Route::post('/view/{server:id}/delete', [Admin\ServersController::class, 'delete']);
Route::patch('/view/{server:id}/details', [Admin\ServersController::class, 'setDetails']);