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

@@ -4,10 +4,8 @@ namespace App\Livewire\Server;
use App\Jobs\DockerCleanupJob;
use App\Models\Server;
use Exception;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Throwable;
class Advanced extends Component
{
@@ -48,11 +46,9 @@ class Advanced extends Component
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
$this->parameters = get_route_parameters();
$this->syncData();
} catch (Throwable) {
} catch (\Throwable) {
return redirect()->route('server.show');
}
return null;
}
public function syncData(bool $toModel = false)
@@ -87,11 +83,9 @@ class Advanced extends Component
try {
$this->syncData(true);
$this->dispatch('success', 'Server updated.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function manualCleanup()
@@ -99,11 +93,9 @@ class Advanced extends Component
try {
DockerCleanupJob::dispatch($this->server, true);
$this->dispatch('success', 'Manual cleanup job started. Depending on the amount of data, this might take a while.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function submit()
@@ -111,19 +103,17 @@ class Advanced extends Component
try {
if (! validate_cron_expression($this->dockerCleanupFrequency)) {
$this->dockerCleanupFrequency = $this->server->settings->getOriginal('docker_cleanup_frequency');
throw new Exception('Invalid Cron / Human expression for Docker Cleanup Frequency.');
throw new \Exception('Invalid Cron / Human expression for Docker Cleanup Frequency.');
}
if (! validate_cron_expression($this->serverDiskUsageCheckFrequency)) {
$this->serverDiskUsageCheckFrequency = $this->server->settings->getOriginal('server_disk_usage_check_frequency');
throw new Exception('Invalid Cron / Human expression for Disk Usage Check Frequency.');
throw new \Exception('Invalid Cron / Human expression for Disk Usage Check Frequency.');
}
$this->syncData(true);
$this->dispatch('success', 'Server updated.');
} 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;
use App\Models\Server;
use Livewire\Component;
use Throwable;
class Charts extends Component
{
@@ -24,11 +23,9 @@ class Charts extends Component
{
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function pollData()
@@ -52,11 +49,9 @@ class Charts extends Component
$this->dispatch("refreshChartData-{$this->chartId}-memory", [
'seriesData' => $memoryMetrics,
]);
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function setInterval()

View File

@@ -5,7 +5,6 @@ namespace App\Livewire\Server;
use App\Models\Server;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Throwable;
class CloudflareTunnels extends Component
{
@@ -22,11 +21,9 @@ class CloudflareTunnels extends Component
return redirect()->route('server.show', ['server_uuid' => $server_uuid]);
}
$this->isCloudflareTunnelsEnabled = $this->server->settings->is_cloudflare_tunnel;
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function instantSave()
@@ -36,11 +33,9 @@ class CloudflareTunnels extends Component
$this->server->settings->is_cloudflare_tunnel = $this->isCloudflareTunnelsEnabled;
$this->server->settings->save();
$this->dispatch('success', 'Server updated.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function manualCloudflareConfig()

View File

@@ -5,7 +5,6 @@ namespace App\Livewire\Server;
use App\Actions\Server\ConfigureCloudflared;
use App\Models\Server;
use Livewire\Component;
use Throwable;
class ConfigureCloudflareTunnels extends Component
{
@@ -23,11 +22,9 @@ class ConfigureCloudflareTunnels extends Component
$server->settings->save();
$this->dispatch('success', 'Cloudflare Tunnels configured successfully.');
$this->dispatch('refreshServerShow');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function submit()
@@ -45,11 +42,9 @@ class ConfigureCloudflareTunnels extends Component
$server->save();
$server->settings->save();
$this->dispatch('warning', 'Cloudflare Tunnels configuration started.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -9,7 +9,6 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component;
use Throwable;
class Delete extends Component
{
@@ -21,32 +20,32 @@ class Delete extends Component
{
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function delete($password)
{
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation') && ! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) {
if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return null;
return;
}
}
try {
$this->authorize('delete', $this->server);
if ($this->server->hasDefinedResources()) {
$this->dispatch('error', 'Server has defined resources. Please delete them first.');
return null;
return;
}
$this->server->delete();
DeleteServer::dispatch($this->server);
return redirect()->route('server.index');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
}

View File

@@ -7,7 +7,6 @@ use App\Models\StandaloneDocker;
use App\Models\SwarmDocker;
use Illuminate\Support\Collection;
use Livewire\Component;
use Throwable;
class Destinations extends Component
{
@@ -20,11 +19,9 @@ class Destinations extends Component
try {
$this->networks = collect();
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
private function createNetworkAndAttachToProxy()
@@ -41,31 +38,37 @@ class Destinations extends Component
$this->dispatch('error', 'Network already added to this server.');
return;
} else {
SwarmDocker::create([
'name' => $this->server->name.'-'.$name,
'network' => $this->name,
'server_id' => $this->server->id,
]);
}
SwarmDocker::query()->create([
'name' => $this->server->name.'-'.$name,
'network' => $this->name,
'server_id' => $this->server->id,
]);
} else {
$found = $this->server->standaloneDockers()->where('network', $name)->first();
if ($found) {
$this->dispatch('error', 'Network already added to this server.');
return;
} else {
StandaloneDocker::create([
'name' => $this->server->name.'-'.$name,
'network' => $name,
'server_id' => $this->server->id,
]);
}
StandaloneDocker::query()->create([
'name' => $this->server->name.'-'.$name,
'network' => $name,
'server_id' => $this->server->id,
]);
$this->createNetworkAndAttachToProxy();
}
}
public function scan()
{
$alreadyAddedNetworks = $this->server->isSwarm() ? $this->server->swarmDockers : $this->server->standaloneDockers;
if ($this->server->isSwarm()) {
$alreadyAddedNetworks = $this->server->swarmDockers;
} else {
$alreadyAddedNetworks = $this->server->standaloneDockers;
}
$networks = instant_remote_process(['docker network ls --format "{{json .}}"'], $this->server, false);
$this->networks = format_docker_command_output_to_json($networks)->filter(function ($network) {
return $network['Name'] !== 'bridge' && $network['Name'] !== 'host' && $network['Name'] !== 'none';

View File

@@ -7,7 +7,6 @@ use App\Actions\Server\StopLogDrain;
use App\Models\Server;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Throwable;
class LogDrains extends Component
{
@@ -45,11 +44,9 @@ class LogDrains extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
$this->syncData();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function syncDataNewRelic(bool $toModel = false)
@@ -107,16 +104,18 @@ class LogDrains extends Component
$this->syncDataCustom($toModel);
}
$this->server->settings->save();
} elseif ($type === 'newrelic') {
$this->syncDataNewRelic($toModel);
} elseif ($type === 'axiom') {
$this->syncDataAxiom($toModel);
} elseif ($type === 'custom') {
$this->syncDataCustom($toModel);
} else {
$this->syncDataNewRelic($toModel);
$this->syncDataAxiom($toModel);
$this->syncDataCustom($toModel);
if ($type === 'newrelic') {
$this->syncDataNewRelic($toModel);
} elseif ($type === 'axiom') {
$this->syncDataAxiom($toModel);
} elseif ($type === 'custom') {
$this->syncDataCustom($toModel);
} else {
$this->syncDataNewRelic($toModel);
$this->syncDataAxiom($toModel);
$this->syncDataCustom($toModel);
}
}
}
@@ -128,7 +127,7 @@ class LogDrains extends Component
'logDrainNewRelicLicenseKey' => ['required'],
'logDrainNewRelicBaseUri' => ['required', 'url'],
]);
} catch (Throwable $e) {
} catch (\Throwable $e) {
$this->isLogDrainNewRelicEnabled = false;
throw $e;
@@ -139,7 +138,7 @@ class LogDrains extends Component
'logDrainAxiomDatasetName' => ['required'],
'logDrainAxiomApiKey' => ['required'],
]);
} catch (Throwable $e) {
} catch (\Throwable $e) {
$this->isLogDrainAxiomEnabled = false;
throw $e;
@@ -150,7 +149,7 @@ class LogDrains extends Component
'logDrainCustomConfig' => ['required'],
'logDrainCustomConfigParser' => ['string', 'nullable'],
]);
} catch (Throwable $e) {
} catch (\Throwable $e) {
$this->isLogDrainCustomEnabled = false;
throw $e;
@@ -169,11 +168,9 @@ class LogDrains extends Component
StopLogDrain::run($this->server);
$this->dispatch('success', 'Log drain service stopped.');
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function submit(string $type)
@@ -181,11 +178,9 @@ class LogDrains extends Component
try {
$this->syncData(true, $type);
$this->dispatch('success', 'Settings saved.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -9,7 +9,6 @@ use Illuminate\Support\Collection;
use Livewire\Attributes\Locked;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Throwable;
class ByIp extends Component
{
@@ -53,7 +52,7 @@ class ByIp extends Component
public bool $is_swarm_worker = false;
#[Validate('nullable|integer', as: 'Swarm Cluster')]
public $selected_swarm_cluster;
public $selected_swarm_cluster = null;
#[Validate('required|boolean', as: 'Build Server')]
public bool $is_build_server = false;
@@ -85,7 +84,7 @@ class ByIp extends Component
{
$this->validate();
try {
if (Server::query()->where('team_id', currentTeam()->id)
if (Server::where('team_id', currentTeam()->id)
->where('ip', $this->ip)
->exists()) {
return $this->dispatch('error', 'This IP/Domain is already in use by another server in your team.');
@@ -112,7 +111,7 @@ class ByIp extends Component
if ($this->is_build_server) {
data_forget($payload, 'proxy');
}
$server = Server::query()->create($payload);
$server = Server::create($payload);
$server->proxy->set('status', 'exited');
$server->proxy->set('type', ProxyTypes::TRAEFIK->value);
$server->save();
@@ -127,7 +126,7 @@ class ByIp extends Component
$server->settings->save();
return redirect()->route('server.show', $server->uuid);
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
}

View File

@@ -4,9 +4,7 @@ namespace App\Livewire\Server\PrivateKey;
use App\Models\PrivateKey;
use App\Models\Server;
use Exception;
use Livewire\Component;
use Throwable;
class Show extends Component
{
@@ -21,11 +19,9 @@ class Show extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
$this->privateKeys = PrivateKey::ownedByCurrentTeam()->get()->where('is_git_related', false);
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function setPrivateKey($privateKeyId)
@@ -44,9 +40,9 @@ class Show extends Component
if ($uptime) {
$this->dispatch('success', 'Private key updated successfully.');
} else {
throw new Exception($error);
throw new \Exception($error);
}
} catch (Exception $e) {
} catch (\Exception $e) {
$this->server->update(['private_key_id' => $originalPrivateKeyId]);
$this->server->validateConnection();
$this->dispatch('error', $e->getMessage());
@@ -62,13 +58,11 @@ class Show extends Component
} else {
$this->dispatch('error', 'Server is not reachable.<br><br>Check this <a target="_blank" class="underline" href="https://coolify.io/docs/knowledge-base/server/openssh">documentation</a> for further help.<br><br>Error: '.$error);
return null;
return;
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -6,7 +6,6 @@ use App\Actions\Proxy\CheckConfiguration;
use App\Actions\Proxy\SaveConfiguration;
use App\Models\Server;
use Livewire\Component;
use Throwable;
class Proxy extends Component
{
@@ -14,7 +13,7 @@ class Proxy extends Component
public ?string $selectedProxy = null;
public $proxy_settings;
public $proxy_settings = null;
public bool $redirect_enabled = true;
@@ -51,11 +50,9 @@ class Proxy extends Component
$this->server->changeProxy($proxy_type, async: false);
$this->selectedProxy = $this->server->proxy->type;
$this->dispatch('reloadWindow');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function instantSave()
@@ -64,11 +61,9 @@ class Proxy extends Component
$this->validate();
$this->server->settings->save();
$this->dispatch('success', 'Settings saved.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function instantSaveRedirect()
@@ -78,11 +73,9 @@ class Proxy extends Component
$this->server->save();
$this->server->setupDefaultRedirect();
$this->dispatch('success', 'Proxy configuration saved.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function submit()
@@ -93,11 +86,9 @@ class Proxy extends Component
$this->server->save();
$this->server->setupDefaultRedirect();
$this->dispatch('success', 'Proxy configuration saved.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function reset_proxy_configuration()
@@ -107,11 +98,9 @@ class Proxy extends Component
SaveConfiguration::run($this->server, $this->proxy_settings);
$this->server->save();
$this->dispatch('success', 'Proxy configuration saved.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function loadProxyConfiguration()
@@ -123,10 +112,8 @@ class Proxy extends Component
} else {
$this->dispatch('traefikDashboardAvailable', false);
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
}

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;
}
}

View File

@@ -6,7 +6,6 @@ use App\Models\Server;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Collection;
use Livewire\Component;
use Throwable;
class Resources extends Component
{
@@ -66,11 +65,9 @@ class Resources extends Component
try {
$this->activeTab = 'managed';
$this->containers = $this->server->refresh()->definedResources();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function loadUnmanagedContainers()
@@ -78,11 +75,9 @@ class Resources extends Component
$this->activeTab = 'unmanaged';
try {
$this->containers = $this->server->loadUnmanagedContainers();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function mount()
@@ -95,11 +90,9 @@ class Resources extends Component
return redirect()->route('server.index');
}
$this->loadManagedContainers();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -6,11 +6,9 @@ use App\Actions\Server\StartSentinel;
use App\Actions\Server\StopSentinel;
use App\Events\ServerReachabilityChanged;
use App\Models\Server;
use Exception;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Throwable;
class Show extends Component
{
@@ -97,11 +95,9 @@ class Show extends Component
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
$this->syncData();
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
#[Computed]
@@ -118,12 +114,12 @@ class Show extends Component
if ($toModel) {
$this->validate();
if (Server::query()->where('team_id', currentTeam()->id)
if (Server::where('team_id', currentTeam()->id)
->where('ip', $this->ip)
->where('id', '!=', $this->server->id)
->exists()) {
$this->ip = $this->server->ip;
throw new Exception('This IP/Domain is already in use by another server in your team.');
throw new \Exception('This IP/Domain is already in use by another server in your team.');
}
$this->server->name = $this->name;
@@ -149,9 +145,10 @@ class Show extends Component
if (! validate_timezone($this->serverTimezone)) {
$this->serverTimezone = config('app.timezone');
throw new Exception('Invalid timezone.');
throw new \Exception('Invalid timezone.');
} else {
$this->server->settings->server_timezone = $this->serverTimezone;
}
$this->server->settings->server_timezone = $this->serverTimezone;
$this->server->settings->save();
} else {
@@ -192,11 +189,9 @@ class Show extends Component
$this->validationLogs = $this->server->validation_logs = null;
$this->server->save();
$this->dispatch('init', $install);
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function checkLocalhostConnection()
@@ -253,11 +248,9 @@ class Show extends Component
try {
$this->server->settings->generateSentinelToken();
$this->dispatch('success', 'Token regenerated & Sentinel restarted.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function instantSave()
@@ -270,11 +263,9 @@ class Show extends Component
try {
$this->syncData(true);
$this->dispatch('success', 'Server updated.');
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -5,9 +5,7 @@ namespace App\Livewire\Server;
use App\Actions\Proxy\CheckProxy;
use App\Actions\Proxy\StartProxy;
use App\Models\Server;
use Exception;
use Livewire\Component;
use Throwable;
class ValidateAndInstall extends Component
{
@@ -19,19 +17,19 @@ class ValidateAndInstall extends Component
public bool $install = true;
public $uptime;
public $uptime = null;
public $supported_os_type;
public $supported_os_type = null;
public $docker_installed;
public $docker_installed = null;
public $docker_compose_installed;
public $docker_compose_installed = null;
public $docker_version;
public $docker_version = null;
public $proxy_started = false;
public $error;
public $error = null;
public bool $ask = false;
@@ -75,16 +73,14 @@ class ValidateAndInstall extends Component
if ($proxy === 'OK') {
$this->proxy_started = true;
} else {
throw new Exception('Proxy could not be started.');
throw new \Exception('Proxy could not be started.');
}
} else {
$this->proxy_started = true;
}
} catch (Throwable $e) {
} catch (\Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function validateConnection()
@@ -121,28 +117,30 @@ class ValidateAndInstall extends Component
$this->docker_compose_installed = $this->server->validateDockerCompose();
if (! $this->docker_installed || ! $this->docker_compose_installed) {
if ($this->install) {
if ($this->number_of_tries === $this->max_tries) {
if ($this->number_of_tries == $this->max_tries) {
$this->error = 'Docker Engine could not be installed. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://docs.docker.com/engine/install/#server">documentation</a>.';
$this->server->update([
'validation_logs' => $this->error,
]);
return;
} else {
if ($this->number_of_tries <= $this->max_tries) {
$activity = $this->server->installDocker();
$this->number_of_tries++;
$this->dispatch('newActivityMonitor', $activity->id, 'init', $this->number_of_tries);
}
return;
}
if ($this->number_of_tries <= $this->max_tries) {
$activity = $this->server->installDocker();
$this->number_of_tries++;
$this->dispatch('newActivityMonitor', $activity->id, 'init', $this->number_of_tries);
}
} else {
$this->error = 'Docker Engine is not installed. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://docs.docker.com/engine/install/#server">documentation</a>.';
$this->server->update([
'validation_logs' => $this->error,
]);
return;
}
$this->error = 'Docker Engine is not installed. Please install Docker manually before continuing: <a target="_blank" class="underline" href="https://docs.docker.com/engine/install/#server">documentation</a>.';
$this->server->update([
'validation_logs' => $this->error,
]);
return;
}
$this->dispatch('validateDockerVersion');
}