From fe8a7fc54f0ac091ba88b3d3f16ba26c442c796e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 27 Sep 2023 21:14:13 +0200 Subject: [PATCH] fix: services view --- app/Http/Controllers/ProjectController.php | 3 +- app/Http/Livewire/Project/Service/Index.php | 15 ++---- app/Models/Service.php | 52 +++++++++---------- .../components/navbar-subscription.blade.php | 4 +- resources/views/components/navbar.blade.php | 4 +- .../livewire/project/service/index.blade.php | 9 ++-- 6 files changed, 38 insertions(+), 49 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 827052ad9..48bf7909e 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -73,7 +73,6 @@ class ProjectController extends Controller if ($oneClickDotEnvs) { $oneClickDotEnvs = Str::of(base64_decode($oneClickDotEnvs))->split('/\r\n|\r|\n/'); } - ray($oneClickDotEnvs); if ($oneClickService) { $service = Service::create([ 'name' => "$oneClickServiceName-" . Str::random(10), @@ -83,7 +82,7 @@ class ProjectController extends Controller ]); $service->name = "$oneClickServiceName-" . $service->uuid; $service->save(); - if ($oneClickDotEnvs->count() > 0) { + if ($oneClickDotEnvs?->count() > 0) { $oneClickDotEnvs->each(function ($value) use ($service) { $key = Str::before($value, '='); $value = Str::of(Str::after($value, '=')); diff --git a/app/Http/Livewire/Project/Service/Index.php b/app/Http/Livewire/Project/Service/Index.php index 017c878e7..0a09484ff 100644 --- a/app/Http/Livewire/Project/Service/Index.php +++ b/app/Http/Livewire/Project/Service/Index.php @@ -9,7 +9,6 @@ use Livewire\Component; class Index extends Component { - use WithRateLimiting; public Service $service; public $applications; public $databases; @@ -21,26 +20,22 @@ class Index extends Component 'service.name' => 'required', 'service.description' => 'nullable', ]; - public function manualRefreshStack() { - try { - $this->rateLimit(5); - dispatch_sync(new ContainerStatusJob($this->service->server)); - $this->refreshStack(); - } catch(\Throwable $e) { - return handleError($e, $this); - } + public function checkStatus() { + dispatch_sync(new ContainerStatusJob($this->service->server)); + $this->refreshStack(); } public function refreshStack() { $this->applications = $this->service->applications->sort(); $this->applications->each(function ($application) { + $application->refresh(); $application->configuration_required = $application->configurationRequired(); }); $this->databases = $this->service->databases->sort(); $this->databases->each(function ($database) { + $database->refresh(); $database->configuration_required = $database->configurationRequired(); }); - $this->emit('success', 'Stack refreshed successfully.'); } public function mount() { diff --git a/app/Models/Service.php b/app/Models/Service.php index f03ef8a86..2b1819366 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -115,30 +115,30 @@ class Service extends BaseModel } return "{$server->ip}.sslip.io"; } - private function generateFqdn($serviceVariables, $serviceName, Collection $configuration) - { - // Add sslip.io to the service - $defaultUsableFqdn = null; - $sslip = $this->sslip($this->server); - if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) { - $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}"; - } - if ($configuration->count() > 0) { - foreach ($configuration as $requiredFqdn) { - $requiredFqdn = (array)$requiredFqdn; - $name = data_get($requiredFqdn, 'name'); - $path = data_get($requiredFqdn, 'path'); - $customFqdn = data_get($requiredFqdn, 'customFqdn'); - if ($serviceName === $name) { - $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}{$path}"; - if ($customFqdn) { - $defaultUsableFqdn = "http://$customFqdn-{$this->uuid}.{$sslip}{$path}"; - } - } - } - } - return $defaultUsableFqdn ?? null; - } + // private function generateFqdn($serviceVariables, $serviceName, Collection $configuration) + // { + // // Add sslip.io to the service + // $defaultUsableFqdn = null; + // $sslip = $this->sslip($this->server); + // if (Str::of($serviceVariables)->contains('SERVICE_FQDN') || Str::of($serviceVariables)->contains('SERVICE_URL')) { + // $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}"; + // } + // if ($configuration->count() > 0) { + // foreach ($configuration as $requiredFqdn) { + // $requiredFqdn = (array)$requiredFqdn; + // $name = data_get($requiredFqdn, 'name'); + // $path = data_get($requiredFqdn, 'path'); + // $customFqdn = data_get($requiredFqdn, 'customFqdn'); + // if ($serviceName === $name) { + // $defaultUsableFqdn = "http://$serviceName-{$this->uuid}.{$sslip}{$path}"; + // if ($customFqdn) { + // $defaultUsableFqdn = "http://$customFqdn-{$this->uuid}.{$sslip}{$path}"; + // } + // } + // } + // } + // return $defaultUsableFqdn ?? null; + // } public function parse(bool $isNew = false): Collection { // ray()->clearAll(); @@ -376,14 +376,10 @@ class Service extends BaseModel $generatedServiceFQDNS->put($key->value(), $fqdn); } } else { - ray($key, $fqdn); $generatedServiceFQDNS->put($key->value(), $fqdn); } $fqdn = "http://$containerName.$sslip$path"; - - ray($fqdn); } - if (!$isDatabase) { $savedService->fqdn = $fqdn; $savedService->save(); diff --git a/resources/views/components/navbar-subscription.blade.php b/resources/views/components/navbar-subscription.blade.php index 91629f99e..ddb9d1a44 100644 --- a/resources/views/components/navbar-subscription.blade.php +++ b/resources/views/components/navbar-subscription.blade.php @@ -11,9 +11,9 @@ -
  • +
  • - + diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 4a86f7dd5..ca0410284 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -115,9 +115,9 @@
  • @endif @if (isSubscriptionActive() || isDev()) -
  • +
  • - + diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.php index 8c08f1ff2..8494115b9 100644 --- a/resources/views/livewire/project/service/index.blade.php +++ b/resources/views/livewire/project/service/index.blade.php @@ -1,7 +1,7 @@ -
    +