Revert "rector: arrrrr"

This reverts commit 16c0cd10d8.
This commit is contained in:
Andras Bacsai
2025-01-07 15:31:43 +01:00
parent da07b4fdcf
commit 1fe4dd722b
349 changed files with 3689 additions and 4184 deletions

View File

@@ -10,7 +10,6 @@ use Carbon\Carbon;
use Illuminate\Process\InvokedProcess;
use Illuminate\Support\Facades\Process;
use Livewire\Component;
use Throwable;
class Deploy extends Component
{
@@ -39,7 +38,11 @@ class Deploy extends Component
public function mount()
{
$this->serverIp = $this->server->id === 0 ? base_ip() : $this->server->ip;
if ($this->server->id === 0) {
$this->serverIp = base_ip();
} else {
$this->serverIp = $this->server->ip;
}
$this->currentRoute = request()->route()->getName();
}
@@ -64,11 +67,9 @@ class Deploy extends Component
try {
$this->stop();
$this->dispatch('checkProxy');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function checkProxy()
@@ -77,11 +78,9 @@ class Deploy extends Component
CheckProxy::run($this->server, true);
$this->dispatch('startProxyPolling');
$this->dispatch('proxyChecked');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function startProxy()
@@ -91,11 +90,9 @@ class Deploy extends Component
$this->server->save();
$activity = StartProxy::run($this->server, force: true);
$this->dispatch('activityMonitor', $activity->id, ProxyStatusChanged::class);
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function stop(bool $forceStop = true)
@@ -117,7 +114,7 @@ class Deploy extends Component
}
$this->removeContainer($containerName);
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->server->proxy->force_stop = $forceStop;
@@ -125,8 +122,6 @@ class Deploy extends Component
$this->server->save();
$this->dispatch('proxyStatusUpdated');
}
return null;
}
private function stopContainer(string $containerName, int $timeout): InvokedProcess

View File

@@ -5,7 +5,6 @@ namespace App\Livewire\Server\Proxy;
use App\Models\Server;
use Illuminate\Support\Collection;
use Livewire\Component;
use Throwable;
class DynamicConfigurations extends Component
{
@@ -33,7 +32,7 @@ class DynamicConfigurations extends Component
{
$proxy_path = $this->server->proxyPath();
$files = instant_remote_process(["mkdir -p $proxy_path/dynamic && ls -1 {$proxy_path}/dynamic"], $this->server);
$files = collect(explode("\n", $files))->reject(fn ($file): bool => $file === '' || $file === '0');
$files = collect(explode("\n", $files))->filter(fn ($file) => ! empty($file));
$files = $files->map(fn ($file) => trim($file));
$files = $files->sort();
$contents = collect([]);
@@ -53,11 +52,9 @@ class DynamicConfigurations extends Component
if (is_null($this->server)) {
return redirect()->route('server.index');
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -4,7 +4,6 @@ namespace App\Livewire\Server\Proxy;
use App\Models\Server;
use Livewire\Component;
use Throwable;
class Logs extends Component
{
@@ -20,11 +19,9 @@ class Logs extends Component
if (is_null($this->server)) {
return redirect()->route('server.index');
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -6,7 +6,6 @@ use App\Enums\ProxyTypes;
use App\Models\Server;
use Livewire\Component;
use Symfony\Component\Yaml\Yaml;
use Throwable;
class NewDynamicConfiguration extends Component
{
@@ -54,7 +53,7 @@ class NewDynamicConfiguration extends Component
if ($this->fileName === 'coolify.yaml') {
$this->dispatch('error', 'File name is reserved.');
return null;
return;
}
} elseif ($proxy_type === 'CADDY') {
if (! str($this->fileName)->endsWith('.caddy')) {
@@ -68,7 +67,7 @@ class NewDynamicConfiguration extends Component
if ($exists == 1) {
$this->dispatch('error', 'File already exists');
return null;
return;
}
}
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
@@ -86,11 +85,9 @@ class NewDynamicConfiguration extends Component
$this->dispatch('loadDynamicConfigurations');
$this->dispatch('dynamic-configuration-added');
$this->dispatch('success', 'Dynamic configuration saved.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -4,7 +4,6 @@ namespace App\Livewire\Server\Proxy;
use App\Models\Server;
use Livewire\Component;
use Throwable;
class Show extends Component
{
@@ -24,11 +23,9 @@ class Show extends Component
$this->parameters = get_route_parameters();
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->firstOrFail();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -7,7 +7,6 @@ use App\Actions\Proxy\CheckProxy;
use App\Actions\Proxy\StartProxy;
use App\Models\Server;
use Livewire\Component;
use Throwable;
class Status extends Component
{
@@ -39,11 +38,9 @@ class Status extends Component
if ($this->numberOfPolls >= 10) {
$this->polling = false;
$this->numberOfPolls = 0;
if ($notification) {
$this->dispatch('error', 'Proxy is not running.');
}
$notification && $this->dispatch('error', 'Proxy is not running.');
return null;
return;
}
$this->numberOfPolls++;
}
@@ -54,25 +51,17 @@ class Status extends Component
$this->dispatch('proxyStatusUpdated');
if ($this->server->proxy->status === 'running') {
$this->polling = false;
if ($notification) {
$this->dispatch('success', 'Proxy is running.');
}
} elseif ($this->server->proxy->status === 'exited' && ! $this->server->proxy->force_stop) {
if ($notification) {
$this->dispatch('error', 'Proxy has exited.');
}
$notification && $this->dispatch('success', 'Proxy is running.');
} elseif ($this->server->proxy->status === 'exited' and ! $this->server->proxy->force_stop) {
$notification && $this->dispatch('error', 'Proxy has exited.');
} elseif ($this->server->proxy->force_stop) {
if ($notification) {
$this->dispatch('error', 'Proxy is stopped manually.');
}
} elseif ($notification) {
$this->dispatch('error', 'Proxy is not running.');
$notification && $this->dispatch('error', 'Proxy is stopped manually.');
} else {
$notification && $this->dispatch('error', 'Proxy is not running.');
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function getProxyStatus()
@@ -81,10 +70,8 @@ class Status extends Component
GetContainersStatus::run($this->server);
// dispatch_sync(new ContainerStatusJob($this->server));
$this->dispatch('proxyStatusUpdated');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
}