diff --git a/app/Http/Livewire/Project/Application/Deployments.php b/app/Http/Livewire/Project/Application/Deployments.php index 1c16d82c5..3ab123635 100644 --- a/app/Http/Livewire/Project/Application/Deployments.php +++ b/app/Http/Livewire/Project/Application/Deployments.php @@ -10,16 +10,32 @@ class Deployments extends Component public int $application_id; public $deployments = []; public string $current_url; + public int $skip = 0; + public int $default_take = 8; + public bool $show_next = true; + public function mount() { $this->current_url = url()->current(); } - public function reloadDeployments() + public function reload_deployments() { - $this->loadDeployments(); + $this->load_deployments(); } - public function loadDeployments() + public function load_deployments(int|null $take = null) { - $this->deployments = Application::find($this->application_id)->deployments(); + ray('Take' . $take); + if ($take) { + ray('Take is not null'); + $this->skip = $this->skip + $take; + } + + $take = $this->default_take; + $this->deployments = Application::find($this->application_id)->deployments($this->skip, $take); + + if (count($this->deployments) !== 0 && count($this->deployments) < $take) { + $this->show_next = false; + return; + } } } diff --git a/app/Models/Application.php b/app/Models/Application.php index e3dbe0706..46f7956a1 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -144,9 +144,10 @@ class Application extends BaseModel return $this->morphMany(LocalPersistentVolume::class, 'resource'); } - public function deployments() + public function deployments(int $skip = 0, int $take = 10) { - return ApplicationDeploymentQueue::where('application_id', $this->id)->orderBy('created_at', 'desc')->get(); + ray('Skip ' . $skip . ' Take ' . $take); + return ApplicationDeploymentQueue::where('application_id', $this->id)->orderBy('created_at', 'desc')->skip($skip)->take($take)->get(); } public function get_deployment(string $deployment_uuid) { diff --git a/resources/views/livewire/project/application/deployments.blade.php b/resources/views/livewire/project/application/deployments.blade.php index bcb74b296..d8f7ae2c8 100644 --- a/resources/views/livewire/project/application/deployments.blade.php +++ b/resources/views/livewire/project/application/deployments.blade.php @@ -1,7 +1,15 @@ -
-
- +
+
+

Actions

+ @if ($show_next) + Load More + Deployments + @else + No More Deployments + @endif
+

Deployments

@foreach ($deployments as $deployment)
+
+ {{ $deployment->deployment_uuid }} > + {{ $deployment->status }} +
@if (data_get($deployment, 'pull_request_id'))
Pull Request #{{ data_get($deployment, 'pull_request_id') }} @@ -27,29 +39,57 @@ @endif
@elseif (data_get($deployment, 'is_webhook')) -
Webhook (commit +
Webhook (sha @if (data_get($deployment, 'commit')) {{ data_get($deployment, 'commit') }}) @else HEAD) @endif
- @else -
Commit: - @if (data_get($deployment, 'commit')) - {{ data_get($deployment, 'commit') }} - @else - HEAD - @endif -
@endif -
- {{ $deployment->status }} -
-
- {{ $deployment->created_at }} + +
+
Finished 0s in 0s
@endforeach + + + + +