mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 20:24:44 +02:00
Use daemonRepository
instead of BuildModificationService
(#1053)
This commit is contained in:
parent
5331c5abfa
commit
5512c10ee1
@ -17,9 +17,9 @@ use App\Models\Mount;
|
|||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\ServerVariable;
|
use App\Models\ServerVariable;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Repositories\Daemon\DaemonServerRepository;
|
||||||
use App\Services\Databases\DatabaseManagementService;
|
use App\Services\Databases\DatabaseManagementService;
|
||||||
use App\Services\Eggs\EggChangerService;
|
use App\Services\Eggs\EggChangerService;
|
||||||
use App\Services\Servers\BuildModificationService;
|
|
||||||
use App\Services\Servers\RandomWordService;
|
use App\Services\Servers\RandomWordService;
|
||||||
use App\Services\Servers\ReinstallServerService;
|
use App\Services\Servers\ReinstallServerService;
|
||||||
use App\Services\Servers\ServerDeletionService;
|
use App\Services\Servers\ServerDeletionService;
|
||||||
@ -52,6 +52,7 @@ use Filament\Notifications\Notification;
|
|||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||||
@ -62,11 +63,11 @@ class EditServer extends EditRecord
|
|||||||
|
|
||||||
private bool $errored = false;
|
private bool $errored = false;
|
||||||
|
|
||||||
private BuildModificationService $buildModificationService;
|
private DaemonServerRepository $daemonServerRepository;
|
||||||
|
|
||||||
public function boot(BuildModificationService $buildModificationService): void
|
public function boot(DaemonServerRepository $daemonServerRepository): void
|
||||||
{
|
{
|
||||||
$this->buildModificationService = $buildModificationService;
|
$this->daemonServerRepository = $daemonServerRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function form(Form $form): Form
|
public function form(Form $form): Form
|
||||||
@ -964,11 +965,12 @@ class EditServer extends EditRecord
|
|||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
/** @var Server $record */
|
||||||
$this->record = $this->buildModificationService->handle($record, $data, true);
|
$record = parent::handleRecordUpdate($record, $data);
|
||||||
|
|
||||||
return $this->record;
|
try {
|
||||||
} catch (Exception $exception) {
|
$this->daemonServerRepository->setServer($record)->sync();
|
||||||
|
} catch (ConnectionException) {
|
||||||
$this->errored = true;
|
$this->errored = true;
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@ -978,9 +980,9 @@ class EditServer extends EditRecord
|
|||||||
->icon('tabler-database')
|
->icon('tabler-database')
|
||||||
->warning()
|
->warning()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return parent::handleRecordUpdate($record, $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $record;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSavedNotification(): ?Notification
|
protected function getSavedNotification(): ?Notification
|
||||||
|
@ -8,7 +8,6 @@ use App\Models\Allocation;
|
|||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use App\Exceptions\DisplayException;
|
use App\Exceptions\DisplayException;
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
use App\Repositories\Daemon\DaemonServerRepository;
|
||||||
use Exception;
|
|
||||||
use Illuminate\Http\Client\ConnectionException;
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
|
||||||
class BuildModificationService
|
class BuildModificationService
|
||||||
@ -30,7 +29,7 @@ class BuildModificationService
|
|||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
* @throws \App\Exceptions\DisplayException
|
* @throws \App\Exceptions\DisplayException
|
||||||
*/
|
*/
|
||||||
public function handle(Server $server, array $data, ?bool $shouldThrow = false): Server
|
public function handle(Server $server, array $data): Server
|
||||||
{
|
{
|
||||||
/** @var \App\Models\Server $server */
|
/** @var \App\Models\Server $server */
|
||||||
$server = $this->connection->transaction(function () use ($server, $data) {
|
$server = $this->connection->transaction(function () use ($server, $data) {
|
||||||
@ -69,10 +68,6 @@ class BuildModificationService
|
|||||||
$this->daemonServerRepository->setServer($server)->sync();
|
$this->daemonServerRepository->setServer($server)->sync();
|
||||||
} catch (ConnectionException $exception) {
|
} catch (ConnectionException $exception) {
|
||||||
logger()->warning($exception, ['server_id' => $server->id]);
|
logger()->warning($exception, ['server_id' => $server->id]);
|
||||||
|
|
||||||
if ($shouldThrow) {
|
|
||||||
throw $exception;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user