diff --git a/app/Events/ApplicationStatusChanged.php b/app/Events/ApplicationStatusChanged.php new file mode 100644 index 000000000..4224d4a29 --- /dev/null +++ b/app/Events/ApplicationStatusChanged.php @@ -0,0 +1,34 @@ +user()->currentTeam()->id ?? null; + } + if (is_null($teamId)) { + throw new \Exception("Team id is null"); + } + $this->teamId = $teamId; + } + + public function broadcastOn(): array + { + return [ + new PrivateChannel("team.{$this->teamId}"), + ]; + } +} diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 4de85f6ae..08c388084 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -4,6 +4,7 @@ namespace App\Jobs; use App\Enums\ApplicationDeploymentStatus; use App\Enums\ProxyTypes; +use App\Events\ApplicationStatusChanged; use App\Models\Application; use App\Models\ApplicationDeploymentQueue; use App\Models\ApplicationPreview; @@ -266,6 +267,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted "ignore_errors" => true, ] ); + ApplicationStatusChanged::dispatch(data_get($this->application,'environment.project.team.id')); } } private function push_to_docker_registry() @@ -1246,6 +1248,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } private function build_by_compose_file() { + $this->application_deployment_queue->addLogEntry("Pulling & building required images."); if ($this->application->build_pack === 'dockerimage') { $this->application_deployment_queue->addLogEntry("Pulling latest images from the registry."); $this->execute_remote_command( diff --git a/app/Livewire/Project/Application/Heading.php b/app/Livewire/Project/Application/Heading.php index 0762c5105..3db5fc9c4 100644 --- a/app/Livewire/Project/Application/Heading.php +++ b/app/Livewire/Project/Application/Heading.php @@ -3,6 +3,7 @@ namespace App\Livewire\Project\Application; use App\Actions\Application\StopApplication; +use App\Events\ApplicationStatusChanged; use App\Jobs\ContainerStatusJob; use App\Jobs\ServerStatusJob; use App\Models\Application; @@ -15,13 +16,19 @@ class Heading extends Component public array $parameters; protected string $deploymentUuid; - + public function getListeners() + { + $teamId = auth()->user()->currentTeam()->id; + return [ + "echo-private:team.{$teamId},ApplicationStatusChanged" => 'check_status', + ]; + } public function mount() { $this->parameters = get_route_parameters(); } - public function check_status() + public function check_status($showNotification = false) { if ($this->application->destination->server->isFunctional()) { dispatch(new ContainerStatusJob($this->application->destination->server)); @@ -32,6 +39,7 @@ class Heading extends Component } else { dispatch(new ServerStatusJob($this->application->destination->server)); } + if ($showNotification) $this->dispatch('success', 'Application status updated.'); } public function force_deploy_without_cache() diff --git a/app/Livewire/Project/Database/Heading.php b/app/Livewire/Project/Database/Heading.php index 59ddf2644..76b36a5ba 100644 --- a/app/Livewire/Project/Database/Heading.php +++ b/app/Livewire/Project/Database/Heading.php @@ -34,10 +34,11 @@ class Heading extends Component $this->check_status(); } - public function check_status() + public function check_status($showNotification = false) { dispatch_sync(new ContainerStatusJob($this->database->destination->server)); $this->database->refresh(); + if ($showNotification) $this->dispatch('success', 'Database status updated.'); } public function mount() diff --git a/app/Livewire/Project/Service/Navbar.php b/app/Livewire/Project/Service/Navbar.php index 71ec4e702..3e2c3485c 100644 --- a/app/Livewire/Project/Service/Navbar.php +++ b/app/Livewire/Project/Service/Navbar.php @@ -41,9 +41,11 @@ class Navbar extends Component { return view('livewire.project.service.navbar'); } - public function checkStatus() + public function check_status($showNotification = false) { + dispatch_sync(new ContainerStatusJob($this->service->destination->server)); $this->service->refresh(); + if ($showNotification) $this->dispatch('success', 'Service status updated.'); } public function deploy() { diff --git a/resources/views/components/status/index.blade.php b/resources/views/components/status/index.blade.php index 67fef1282..050025f94 100644 --- a/resources/views/components/status/index.blade.php +++ b/resources/views/components/status/index.blade.php @@ -5,3 +5,11 @@ @else @endif +@if (!str($status)->contains('exited')) + +@endif diff --git a/resources/views/components/status/services.blade.php b/resources/views/components/status/services.blade.php index 71ea08411..dfcec7480 100644 --- a/resources/views/components/status/services.blade.php +++ b/resources/views/components/status/services.blade.php @@ -7,3 +7,11 @@ @else @endif +@if (!str($complexStatus)->contains('exited')) + +@endif diff --git a/resources/views/livewire/project/application/heading.blade.php b/resources/views/livewire/project/application/heading.blade.php index ca76d38e8..2b9f189c2 100644 --- a/resources/views/livewire/project/application/heading.blade.php +++ b/resources/views/livewire/project/application/heading.blade.php @@ -1,4 +1,4 @@ -