diff --git a/app/Http/Livewire/Project/Application/Revert.php b/app/Http/Livewire/Project/Application/Revert.php new file mode 100644 index 000000000..f1917ef85 --- /dev/null +++ b/app/Http/Livewire/Project/Application/Revert.php @@ -0,0 +1,43 @@ +application->uuid; + $output = instantRemoteProcess([ + "docker inspect --format='{{.Config.Image}}' {$this->application->uuid}", + ], $this->application->destination->server, throwError: false); + $current_tag = Str::of($output)->trim()->explode(":"); + $this->current = data_get($current_tag, 1); + + $output = instantRemoteProcess([ + "docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}'", + ], $this->application->destination->server); + $this->images = Str::of($output)->trim()->explode("\n")->filter(function ($item) use ($image) { + return Str::of($item)->contains($image); + })->map(function ($item) { + $item = Str::of($item)->explode('#'); + if ($item[1] === $this->current) { + $item[1] = $item[1] . " (current)"; + } + return [ + 'tag' => $item[1], + 'createdAt' => $item[2], + ]; + })->toArray(); + } catch (\Throwable $e) { + return generalErrorHandler($e, $this); + } + } +} diff --git a/app/Models/Application.php b/app/Models/Application.php index df4b47c9d..57ef28501 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -73,7 +73,6 @@ public function gitCommits(): Attribute return "{$this->source->html_url}/{$this->git_repository}/commits/{$this->git_branch}"; } } - ); } public function baseDirectory(): Attribute diff --git a/resources/views/components/proxy/loading.blade.php b/resources/views/components/loading.blade.php similarity index 100% rename from resources/views/components/proxy/loading.blade.php rename to resources/views/components/loading.blade.php diff --git a/resources/views/livewire/project/application/revert.blade.php b/resources/views/livewire/project/application/revert.blade.php new file mode 100644 index 000000000..2ca8e5e29 --- /dev/null +++ b/resources/views/livewire/project/application/revert.blade.php @@ -0,0 +1,27 @@ +