diff --git a/app/Http/Controllers/Admin/Servers/ServerTransferController.php b/app/Http/Controllers/Admin/Servers/ServerTransferController.php index 096217418..4fc8aa100 100644 --- a/app/Http/Controllers/Admin/Servers/ServerTransferController.php +++ b/app/Http/Controllers/Admin/Servers/ServerTransferController.php @@ -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. */ diff --git a/app/Models/Server.php b/app/Models/Server.php index 5ad99151a..57cbde816 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -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 */ diff --git a/resources/lang/en/admin/server.php b/resources/lang/en/admin/server.php index 29cb72d18..dfbb0bf06 100644 --- a/resources/lang/en/admin/server.php +++ b/resources/lang/en/admin/server.php @@ -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.', ], ]; diff --git a/resources/views/admin/servers/view/manage.blade.php b/resources/views/admin/servers/view/manage.blade.php index e6177a43b..7fe1738cd 100644 --- a/resources/views/admin/servers/view/manage.blade.php +++ b/resources/views/admin/servers/view/manage.blade.php @@ -110,7 +110,7 @@ @else -
Transferring a server requires more than one node to be configured on your panel.
+You currently can't transfer any servers because you don't have at least a second node that's configured in your panel.
@endif @@ -129,7 +129,11 @@ @@ -190,6 +194,36 @@ + +