From 0add4155abbc9d3660d1425ab1f206c2f5ad99b3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Jun 2023 10:55:50 +0200 Subject: [PATCH] updates --- app/Http/Livewire/Project/Application/Deploy.php | 9 +++++++++ app/Jobs/ApplicationContainerStatusJob.php | 8 +------- .../views/components/status/restarting.blade.php | 5 +++++ .../views/components/status/running.blade.php | 5 +++++ .../views/components/status/stopped.blade.php | 5 +++++ .../livewire/project/application/deploy.blade.php | 7 ++++--- .../project/application/previews.blade.php | 12 ++++-------- .../livewire/project/application/status.blade.php | 14 ++++---------- .../views/livewire/server/proxy/status.blade.php | 14 ++++---------- 9 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 resources/views/components/status/restarting.blade.php create mode 100644 resources/views/components/status/running.blade.php create mode 100644 resources/views/components/status/stopped.blade.php diff --git a/app/Http/Livewire/Project/Application/Deploy.php b/app/Http/Livewire/Project/Application/Deploy.php index c37e33913..460a0ba11 100644 --- a/app/Http/Livewire/Project/Application/Deploy.php +++ b/app/Http/Livewire/Project/Application/Deploy.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire\Project\Application; +use App\Jobs\ApplicationContainerStatusJob; use App\Jobs\ContainerStopJob; use App\Models\Application; use Livewire\Component; @@ -68,4 +69,12 @@ class Deploy extends Component $this->application->save(); $this->emit('applicationStatusChanged'); } + + public function pollStatus() + { + dispatch(new ApplicationContainerStatusJob( + application: $this->application, + container_name: generate_container_name($this->application->uuid), + )); + } } diff --git a/app/Jobs/ApplicationContainerStatusJob.php b/app/Jobs/ApplicationContainerStatusJob.php index 78145eb1c..f31f067b4 100644 --- a/app/Jobs/ApplicationContainerStatusJob.php +++ b/app/Jobs/ApplicationContainerStatusJob.php @@ -35,6 +35,7 @@ class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique { try { $status = get_container_status(server: $this->application->destination->server, container_id: $this->container_name, throwError: false); + ray('ApplicationContainerStatusJob', $status); if ($this->pull_request_id) { $preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id); $preview->status = $status; @@ -47,11 +48,4 @@ class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique Log::error($e->getMessage()); } } - protected function check_container_status() - { - if ($this->application->destination->server) { - $this->application->status = get_container_status(server: $this->application->destination->server, container_id: $this->application->uuid); - $this->application->save(); - } - } } diff --git a/resources/views/components/status/restarting.blade.php b/resources/views/components/status/restarting.blade.php new file mode 100644 index 000000000..1074411de --- /dev/null +++ b/resources/views/components/status/restarting.blade.php @@ -0,0 +1,5 @@ + +
+
+
Stopped
+
diff --git a/resources/views/components/status/running.blade.php b/resources/views/components/status/running.blade.php new file mode 100644 index 000000000..2389415fb --- /dev/null +++ b/resources/views/components/status/running.blade.php @@ -0,0 +1,5 @@ + +
+
+
Running
+
diff --git a/resources/views/components/status/stopped.blade.php b/resources/views/components/status/stopped.blade.php new file mode 100644 index 000000000..1074411de --- /dev/null +++ b/resources/views/components/status/stopped.blade.php @@ -0,0 +1,5 @@ + +
+
+
Stopped
+
diff --git a/resources/views/livewire/project/application/deploy.blade.php b/resources/views/livewire/project/application/deploy.blade.php index e513ee8eb..bf431cc7f 100644 --- a/resources/views/livewire/project/application/deploy.blade.php +++ b/resources/views/livewire/project/application/deploy.blade.php @@ -1,4 +1,4 @@ -
+