rector: arrrrr

This commit is contained in:
Andras Bacsai
2025-01-07 14:52:08 +01:00
parent c702ebff6d
commit 16c0cd10d8
349 changed files with 4204 additions and 3712 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Livewire\Project\Service;
use App\Actions\Docker\GetContainersStatus;
use App\Models\Service;
use Exception;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
@@ -71,9 +72,11 @@ class Configuration extends Component
$application->restart();
$this->dispatch('success', 'Service application restarted successfully.');
}
} catch (\Exception $e) {
} catch (Exception $e) {
return handleError($e, $this);
}
return null;
}
public function restartDatabase($id)
@@ -84,9 +87,11 @@ class Configuration extends Component
$database->restart();
$this->dispatch('success', 'Service database restarted successfully.');
}
} catch (\Exception $e) {
} catch (Exception $e) {
return handleError($e, $this);
}
return null;
}
public function check_status()
@@ -100,8 +105,10 @@ class Configuration extends Component
$database->refresh();
});
$this->dispatch('$refresh');
} catch (\Exception $e) {
} catch (Exception $e) {
return handleError($e, $this);
}
return null;
}
}

View File

@@ -6,6 +6,7 @@ use App\Actions\Database\StartDatabaseProxy;
use App\Actions\Database\StopDatabaseProxy;
use App\Models\ServiceDatabase;
use Livewire\Component;
use Throwable;
class Database extends Component
{
@@ -95,7 +96,7 @@ class Database extends Component
$this->database->save();
updateCompose($this->database);
$this->dispatch('success', 'Database saved.');
} catch (\Throwable) {
} catch (Throwable) {
} finally {
$this->dispatch('generateDockerCompose');
}

View File

@@ -31,12 +31,12 @@ class EditCompose extends Component
public function refreshEnvs()
{
$this->service = Service::find($this->serviceId);
$this->service = Service::query()->find($this->serviceId);
}
public function mount()
{
$this->service = Service::find($this->serviceId);
$this->service = Service::query()->find($this->serviceId);
}
public function saveEditedCompose()

View File

@@ -5,6 +5,7 @@ namespace App\Livewire\Project\Service;
use App\Models\ServiceApplication;
use Livewire\Component;
use Spatie\Url\Url;
use Throwable;
class EditDomain extends Component
{
@@ -19,7 +20,7 @@ class EditDomain extends Component
public function mount()
{
$this->application = ServiceApplication::find($this->applicationId);
$this->application = ServiceApplication::query()->find($this->applicationId);
}
public function submit()
@@ -43,13 +44,13 @@ class EditDomain extends Component
updateCompose($this->application);
if (str($this->application->fqdn)->contains(',')) {
$this->dispatch('warning', 'Some services do not support multiple domains, which can lead to problems and is NOT RECOMMENDED.<br><br>Only use multiple domains if you know what you are doing.');
} else {
! $warning && $this->dispatch('success', 'Service saved.');
} elseif (! $warning) {
$this->dispatch('success', 'Service saved.');
}
$this->application->service->parse();
$this->dispatch('refresh');
$this->dispatch('configurationChanged');
} catch (\Throwable $e) {
} catch (Throwable $e) {
$originalFqdn = $this->application->getOriginal('fqdn');
if ($originalFqdn !== $this->application->fqdn) {
$this->application->fqdn = $originalFqdn;
@@ -57,6 +58,8 @@ class EditDomain extends Component
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -18,6 +18,7 @@ use App\Models\StandaloneRedis;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component;
use Throwable;
class FileStorage extends Component
{
@@ -61,11 +62,13 @@ class FileStorage extends Component
$this->fileStorage->is_based_on_git = false;
$this->fileStorage->save();
$this->fileStorage->saveStorageOnServer();
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
} finally {
$this->dispatch('refreshStorages');
}
return null;
}
public function convertToFile()
@@ -79,21 +82,21 @@ class FileStorage extends Component
}
$this->fileStorage->save();
$this->fileStorage->saveStorageOnServer();
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
} finally {
$this->dispatch('refreshStorages');
}
return null;
}
public function delete($password)
{
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) {
if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation') && ! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return;
}
return null;
}
try {
@@ -107,11 +110,13 @@ class FileStorage extends Component
}
$this->fileStorage->delete();
$this->dispatch('success', $message);
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
} finally {
$this->dispatch('refreshStorages');
}
return null;
}
public function submit()
@@ -125,12 +130,14 @@ class FileStorage extends Component
$this->fileStorage->save();
$this->fileStorage->saveStorageOnServer();
$this->dispatch('success', 'File updated.');
} catch (\Throwable $e) {
} catch (Throwable $e) {
$this->fileStorage->setRawAttributes($original);
$this->fileStorage->save();
return handleError($e, $this);
}
return null;
}
public function instantSave()

View File

@@ -7,6 +7,7 @@ use App\Models\ServiceApplication;
use App\Models\ServiceDatabase;
use Illuminate\Support\Collection;
use Livewire\Component;
use Throwable;
class Index extends Component
{
@@ -45,9 +46,11 @@ class Index extends Component
$this->serviceDatabase->getFilesFromServer();
}
$this->s3s = currentTeam()->s3s;
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function generateDockerCompose()

View File

@@ -10,6 +10,7 @@ use App\Models\Service;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use Spatie\Activitylog\Models\Activity;
use Throwable;
class Navbar extends Component
{
@@ -70,14 +71,10 @@ class Navbar extends Component
try {
// TODO: This is a temporary solution. We need to refactor this.
// We need to delete null bytes somehow.
$activity = Activity::where('properties->type_uuid', $this->service->uuid)->latest()->first();
$activity = Activity::query()->where('properties->type_uuid', $this->service->uuid)->latest()->first();
$status = data_get($activity, 'properties.status');
if ($status === 'queued' || $status === 'in_progress') {
$this->isDeploymentProgress = true;
} else {
$this->isDeploymentProgress = false;
}
} catch (\Throwable) {
$this->isDeploymentProgress = $status === 'queued' || $status === 'in_progress';
} catch (Throwable) {
$this->isDeploymentProgress = false;
}
}

View File

@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Livewire\Component;
use Spatie\Url\Url;
use Throwable;
class ServiceApplicationView extends Component
{
@@ -50,12 +51,10 @@ class ServiceApplicationView extends Component
public function delete($password)
{
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation')) {
if (! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
if (! data_get(InstanceSettings::get(), 'disable_two_step_confirmation') && ! Hash::check($password, Auth::user()->password)) {
$this->addError('password', 'The provided password is incorrect.');
return;
}
return null;
}
try {
@@ -63,7 +62,7 @@ class ServiceApplicationView extends Component
$this->dispatch('success', 'Application deleted.');
return redirect()->route('project.service.configuration', $this->parameters);
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
}
}
@@ -94,11 +93,11 @@ class ServiceApplicationView extends Component
updateCompose($this->application);
if (str($this->application->fqdn)->contains(',')) {
$this->dispatch('warning', 'Some services do not support multiple domains, which can lead to problems and is NOT RECOMMENDED.<br><br>Only use multiple domains if you know what you are doing.');
} else {
! $warning && $this->dispatch('success', 'Service saved.');
} elseif (! $warning) {
$this->dispatch('success', 'Service saved.');
}
$this->dispatch('generateDockerCompose');
} catch (\Throwable $e) {
} catch (Throwable $e) {
$originalFqdn = $this->application->getOriginal('fqdn');
if ($originalFqdn !== $this->application->fqdn) {
$this->application->fqdn = $originalFqdn;
@@ -106,6 +105,8 @@ class ServiceApplicationView extends Component
return handleError($e, $this);
}
return null;
}
public function render()

View File

@@ -3,8 +3,10 @@
namespace App\Livewire\Project\Service;
use App\Models\Service;
use Exception;
use Illuminate\Support\Collection;
use Livewire\Component;
use Throwable;
class StackForm extends Component
{
@@ -78,7 +80,7 @@ class StackForm extends Component
$this->validate();
$isValid = validateComposeFile($this->service->docker_compose_raw, $this->service->server->id);
if ($isValid !== 'OK') {
throw new \Exception("Invalid docker-compose file.\n$isValid");
throw new Exception("Invalid docker-compose file.\n$isValid");
}
$this->service->save();
$this->service->saveExtraFields($this->fields);
@@ -87,7 +89,7 @@ class StackForm extends Component
$this->service->saveComposeConfigs();
$this->dispatch('refreshEnvs');
$notify && $this->dispatch('success', 'Service saved.');
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
} finally {
if (is_null($this->service->config_hash)) {
@@ -96,6 +98,8 @@ class StackForm extends Component
$this->dispatch('configurationChanged');
}
}
return null;
}
public function render()

View File

@@ -4,6 +4,7 @@ namespace App\Livewire\Project\Service;
use App\Models\LocalPersistentVolume;
use Livewire\Component;
use Throwable;
class Storage extends Component
{
@@ -42,7 +43,7 @@ class Storage extends Component
public function addNewVolume($data)
{
try {
LocalPersistentVolume::create([
LocalPersistentVolume::query()->create([
'name' => $data['name'],
'mount_path' => $data['mount_path'],
'host_path' => $data['host_path'],
@@ -53,9 +54,11 @@ class Storage extends Component
$this->dispatch('success', 'Storage added successfully');
$this->dispatch('clearAddStorage');
$this->dispatch('refreshStorages');
} catch (\Throwable $e) {
} catch (Throwable $e) {
return handleError($e, $this);
}
return null;
}
public function render()