From f2215437a5f6ccac970f0b149b9f200c24bded9e Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 6 Nov 2022 12:15:06 -0500 Subject: [PATCH] Add server transfer cancellation --- .../Servers/ServerTransferController.php | 19 ++++++++++ resources/lang/en/admin/server.php | 2 ++ .../views/admin/servers/view/manage.blade.php | 36 ++++++++++++++++++- routes/admin.php | 1 + 4 files changed, 57 insertions(+), 1 deletion(-) 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/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..72e8a0e9e 100644 --- a/resources/views/admin/servers/view/manage.blade.php +++ b/resources/views/admin/servers/view/manage.blade.php @@ -129,7 +129,11 @@ @@ -190,6 +194,36 @@ + + @endsection @section('footer-scripts') diff --git a/routes/admin.php b/routes/admin.php index 4c6732e76..80317a9b7 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -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']);